ViciousXUSMC Posted March 15, 2017 Share Posted March 15, 2017 I have been looking over GDI stuff this morning, examples and our wiki pages and have not had much luck luck yet. What I am trying to do is grab an application window, ultimately it will be different applications but lets just use notepad for an example. I want to grab the applications window and use that as my handle so I can draw ontop of it. Since different users have different sizes in the application I want to be able to highlight or draw different marks ontop of the application for guide/tutorial purposes but it needs to scale to the current height/width of the application window. So I think all I need to get started would be the basic how to on say grab Notepad's window, and draw a circle in the center of it and no matter where on the screen notepad is placed or how big I resize it, it always will find the center. After I can get started with the basics I can come back with some code and ask for more advanced help if needed. Link to comment Share on other sites More sharing options...
InnI Posted March 15, 2017 Share Posted March 15, 2017 2 hours ago, ViciousXUSMC said: grab Notepad's window, and draw a circle in the center of it #include <GDIPlus.au3> Run("notepad.exe") $hWnd = WinWaitActive("[class:Notepad]") $iX = ControlGetPos($hWnd, "", "Edit1")[2] / 2 $iY = ControlGetPos($hWnd, "", "Edit1")[3] / 2 _GDIPlus_Startup() $hGraph = _GDIPlus_GraphicsCreateFromHWND(ControlGetHandle($hWnd, "", "Edit1")) $iW = 100 $iH = 100 _GDIPlus_GraphicsDrawEllipse($hGraph, $iX - $iW / 2, $iY - $iH / 2, $iW, $iH) _GDIPlus_GraphicsDispose($hGraph) _GDIPlus_Shutdown() ViciousXUSMC 1 Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted March 15, 2017 Author Share Posted March 15, 2017 Wow that is so close to what I had tried, wonder what I did wrong. Thanks for the help! Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted March 16, 2017 Author Share Posted March 16, 2017 (edited) So making some progress. One of my ultimate goals for this is to create tutorials for fire fighters to learn how to use new programs and highlight areas in the software for them to click on or focus on. I am just using Spotify right now since it is on my computer to get working script and learn more about GDIPlus, one issue I see that I know must have an easy answer is how to prevent the drawn shapes from disappearing when the client window updates or the mouse moves over them. I think drawing in a loop is probably the wrong way to do this. Also while now I am using manual shapes, I remember when I was working with the IUIAutomation stuff that the demo scripts drew red outlines around the controls it was interfacing with, that may be a lot easier as long as the software has controls, some of it may not I have not gotten that far into it yet. I am pretty sure it was using GDIPlus to do that, so I may see if I can learn from that code as well. Anyways back to the first point here is my current code just want to figure out how to make these lines/shapes stay ontop until dismissed. #include <GDIPlus.au3> If WinExists("[class:SpotifyMainWindow]") Then WinActivate("[class:SpotifyMainWindow]") Else Exit EndIf $hWnd = WinWaitActive("[class:SpotifyMainWindow]") $iX = ControlGetPos($hWnd, "", "[class:Chrome_RenderWidgetHostHWND]")[2] / 2 $iY = ControlGetPos($hWnd, "", "[class:Chrome_RenderWidgetHostHWND]")[3] / 2 _GDIPlus_Startup() $hPen = _GDIPlus_PenCreate(0xFFFF0000, 5) $hGraph = _GDIPlus_GraphicsCreateFromHWND(ControlGetHandle($hWnd, "", "[class:Chrome_RenderWidgetHostHWND]")) $iW = 100 $iH = 100 _GDIPlus_GraphicsDrawEllipse($hGraph, $iX - $iW / 2, $iY - $iH / 2, $iW, $iH, $hPen) _GDIPlus_GraphicsDrawLine($hGraph, 0, 0, $iX, $iY) ;_GDIPlus_GraphicsDrawLine($hGraph, 20, 20, 300, 300) _GDIPlus_GraphicsDrawRect($hGraph, 10, 10, 50, 20, $hPen) _GDIPlus_GraphicsDrawRect($hGraph, 10, 10, 110, 20, $hPen) _GDIPlus_GraphicsDrawRect($hGraph, 10, 10, 150, 20, $hPen) _GDIPlus_GraphicsDrawRect($hGraph, 10, 10, 200, 20, $hPen) _GDIPlus_GraphicsDrawRect($hGraph, 10, 10, 250, 20, $hPen) _GDIPlus_GraphicsDispose($hGraph) _GDIPlus_Shutdown() Edited March 16, 2017 by ViciousXUSMC Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now