Resolved Interactable graphics draw over a different process window

sbondo1234

Member
Joined
Jan 21, 2020
Messages
8
Programming Experience
1-3
<div class="bbWrapper">My main goal is to be able to move a window that doesn&#039;t have borders, the window is for a different process that wasn&#039;t made with the same c# script. If this is the wrong way to go about it please tell.<br /> <br /> Is it possible to draw graphics over a different processes window that is interactable?<br /> <br /> When I say interactable I mainly mean that the user is able to move the window around by using the drawn graphics.<br /> <br /> <b>Edit (Found some code that kind of helps):</b><br /> <br /> This code keeps drawing a box onto the desktop:<br /> <br /> <div class="bbCodeBlock bbCodeBlock--screenLimited bbCodeBlock--code language-csharp " data-xf-init="CMTV-code-block"> <div class="bbCodeBlock-header"> <div class="bbCodeBlock-title"> <span title=""> C#: </span> </div> <div class="bbCodeBlock-actions"> <i class="fa--xf far fa-expand-alt action action--expand action--hidden"><svg xmlns="http://www.w3.org/2000/svg" role="img" data-xf-init="tooltip" data-xf-click="CMTV-code-block-expand"><title>Expand</title><use href="/data/local/icons/regular.svg?v=1757593269#expand-alt"></use></svg></i> <i class="fa--xf far fa-compress-alt action action--collapse action--hidden"><svg xmlns="http://www.w3.org/2000/svg" role="img" data-xf-init="tooltip" data-xf-click="CMTV-code-block-collapse"><title>Collapse</title><use href="/data/local/icons/regular.svg?v=1757593269#compress-alt"></use></svg></i> <i class="fa--xf far fa-paste action action--copy"><svg xmlns="http://www.w3.org/2000/svg" role="img" data-xf-init="tooltip"><title>Copy</title><use href="/data/local/icons/regular.svg?v=1757593269#paste"></use></svg></i> </div> </div> <div class="bbCodeBlock-content" dir="ltr"> <pre class="bbCodeCode line-numbers" dir="ltr" data-line="" data-xf-init="CMTV-code-block-extend" data-lang="csharp"><code>[DllImport(&quot;User32.dll&quot;)] public static extern IntPtr GetDC(IntPtr hwnd); [DllImport(&quot;User32.dll&quot;)] public static extern void ReleaseDC(IntPtr hwnd, IntPtr dc); while (true) { IntPtr desktopPtr = GetDC(IntPtr.Zero); Graphics g = Graphics.FromHdc(desktopPtr); SolidBrush b = new SolidBrush(Color.Red); g.FillRectangle(b, new Rectangle(0, 0, 192, 108)); g.Dispose(); ReleaseDC(IntPtr.Zero, desktopPtr); }</code></pre> </div> <div class="bbCodeBlock-grip resizer--hidden" data-xf-init="CMTV-code-block-resizer"> <i class="fa--xf far fa-grip-horizontal "><svg xmlns="http://www.w3.org/2000/svg" role="img" aria-hidden="true" ><use href="/data/local/icons/regular.svg?v=1757593269#grip-horizontal"></use></svg></i> </div> </div><br /> Is there a way to make it draw over a window, instead of just directly onto the desktop?<br /> <br /> More importantly, is there a way to check if the user click/drags on the graphic and then call another function when that happens?</div>
 
Last edited:
<div class="bbWrapper">I&#039;ve never drawn outside my own app but GDI+ is just pixels on the screen. There are no objects to interact with. I did write some code that allowed a user to drag GDI+ drawing around but that relied on events raised by the object it was drawn on. If you can&#039;t get feedback from the other app about mouse interactions then you&#039;re out of luck but, if you can, the drawing may be no value in the first place.</div>
 
<div class="bbWrapper"><blockquote data-attributes="member: 3" data-quote="jmcilhinney" data-source="post: 14055" class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch"> <div class="bbCodeBlock-title"> <a href="/goto/post?id=14055" class="bbCodeBlock-sourceJump" rel="nofollow" data-xf-click="attribution" data-content-selector="#post-14055">jmcilhinney said:</a> </div> <div class="bbCodeBlock-content"> <div class="bbCodeBlock-expandContent js-expandContent "> I&#039;ve never drawn outside my own app but GDI+ is just pixels on the screen. There are no objects to interact with. I did write some code that allowed a user to drag GDI+ drawing around but that relied on events raised by the object it was drawn on. If you can&#039;t get feedback from the other app about mouse interactions then you&#039;re out of luck but, if you can, the drawing may be no value in the first place. </div> <div class="bbCodeBlock-expandLink js-expandLink"><a role="button" tabindex="0">Click to expand...</a></div> </div> </blockquote>Alright, thanks. I might look into events to check where the user&#039;s mouse is dragging.</div>
 
<div class="bbWrapper"><blockquote data-attributes="member: 12371" data-quote="sbondo1234" data-source="post: 14050" class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch"> <div class="bbCodeBlock-title"> <a href="/goto/post?id=14050" class="bbCodeBlock-sourceJump" rel="nofollow" data-xf-click="attribution" data-content-selector="#post-14050">sbondo1234 said:</a> </div> <div class="bbCodeBlock-content"> <div class="bbCodeBlock-expandContent js-expandContent "> Is it possible to draw graphics over a different processes window that is interactable? </div> <div class="bbCodeBlock-expandLink js-expandLink"><a role="button" tabindex="0">Click to expand...</a></div> </div> </blockquote>For what reason would you want to do that? Even though its highly unlikely going to be any use to you at all. <br /> <blockquote data-attributes="member: 12371" data-quote="sbondo1234" data-source="post: 14050" class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch"> <div class="bbCodeBlock-title"> <a href="/goto/post?id=14050" class="bbCodeBlock-sourceJump" rel="nofollow" data-xf-click="attribution" data-content-selector="#post-14050">sbondo1234 said:</a> </div> <div class="bbCodeBlock-content"> <div class="bbCodeBlock-expandContent js-expandContent "> When I say interactable I mainly mean that the user is able to move the window around by using the drawn graphics. </div> <div class="bbCodeBlock-expandLink js-expandLink"><a role="button" tabindex="0">Click to expand...</a></div> </div> </blockquote>I don&#039;t think that is possible. Nor would that work on it&#039;s own. You will likely need to call on pinvoke at some point, and to actually achieve what you&#039;re trying to do is likely going to require a whole new application. <br /> <blockquote data-attributes="member: 12371" data-quote="sbondo1234" data-source="post: 14058" class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch"> <div class="bbCodeBlock-title"> <a href="/goto/post?id=14058" class="bbCodeBlock-sourceJump" rel="nofollow" data-xf-click="attribution" data-content-selector="#post-14058">sbondo1234 said:</a> </div> <div class="bbCodeBlock-content"> <div class="bbCodeBlock-expandContent js-expandContent "> I might look into events to check where the user&#039;s mouse is dragging. </div> <div class="bbCodeBlock-expandLink js-expandLink"><a role="button" tabindex="0">Click to expand...</a></div> </div> </blockquote>It&#039;s not the events you need to be looking at. Focus instead on the pinvoke calls you can make to acquire all the needed inputs such as mouse clicks mouse location, and set window position etc. They can all be looked up on pinvoke.net.</div>
 
<div class="bbWrapper">Together and using GDi, you could maybe draw objects on the screen and upon clicking these objects, it can move the window you acquired the handle of and place it wherever you want to put it. Looks like there might be some DLL injecting needed as well. And just so you know, its not the easiest of tasks to undertake with 1-3 years experience.</div>
 
<div class="bbWrapper"><blockquote data-attributes="member: 11331" data-quote="Sheepings" data-source="post: 14060" class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch"> <div class="bbCodeBlock-title"> <a href="/goto/post?id=14060" class="bbCodeBlock-sourceJump" rel="nofollow" data-xf-click="attribution" data-content-selector="#post-14060">Sheepings said:</a> </div> <div class="bbCodeBlock-content"> <div class="bbCodeBlock-expandContent js-expandContent "> Together and using GDi, you could maybe draw objects on the screen and upon clicking these objects, it can move the window you acquired the handle of and place it wherever you want to put it. Looks like there might be some DLL injecting needed as well. And just so you know, its not the easiest of tasks to undertake with 1-3 years experience. </div> <div class="bbCodeBlock-expandLink js-expandLink"><a role="button" tabindex="0">Click to expand...</a></div> </div> </blockquote><br /> Ok, I have decided to just move the window in the code itself without an option to move it whilst the code is running.<br /> <br /> Got help from this post: <a href="https://www.pinvoke.net/default.aspx/user32.movewindow" target="_blank" class="link link--external" rel="nofollow ugc noopener">pinvoke.net: movewindow (user32)</a></div>
 
Back
Top Bottom