Hello,
I'm trying to make a macro that captures the screen of an inactive window and clicks it.
Through many Google posts, I found that the following Windows api function is needed, and I want to apply it to the macro scheduler.
The procedure is as below.
1. user32.dll FindWindowA function //can replace it with the GetWindowHandle of the macro scheduler.
2.user32.dll GetDC function
3. user32.dll GetWindowRect function // can replace it with the GetWindowSize of the macro scheduler.
4. user32.dll PrintWindow function
5. user32.dll Post/SendMessageA function // Use user32.dll to click instead of Mouse_Event.
Any help would be appreciated.
#Below is the site I referenced.
https://intrepidgeeks.com/tutorial/c-ca ... ve-windows
Inactive window capture
Moderators: Dorian (MJT support), JRL
- Dorian (MJT support)
- Automation Wizard
- Posts: 1358
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: Inactive window capture
This example will take a screenshot of "Untitled - Notepad" and then click in the top left corner of that window. It saves to a unique file name each time, based on the date and time it was created.
It may be slightly over-engineered for your needs. I adapted it from a script I use regularly to take a screenshot of whichever window is active (I've removed that part).
Hopefully the comments will suffice and you'll find this a good starting point for your project...
It may be slightly over-engineered for your needs. I adapted it from a script I use regularly to take a screenshot of whichever window is active (I've removed that part).
Hopefully the comments will suffice and you'll find this a good starting point for your project...
Code: Select all
//Note. Works best if you assign this macro a Hot Key.
//Click on window?
Let>WindowClick=yes
//Show the screenshot in Windows Explorer? yes/no
Let>ShowInFolder=no
//Open the screenshot in MS Paint? yes/no
Let>EditFile=no
//Get the window size and pos (using Notepad as a test)
GetWindowPos>Untitled - Notepad,Xpos,Ypos
GetWindowSize>Untitled - Notepad,Width,Height
//Calculate the window coordinates
Let>BottomRightX=Xpos+Width
Let>BottomRightY=Ypos+Height
//Get time and date for the filename (for unique file name)
Year>TheYear
Month>TheMonth
Day>TheDay
Hour>TheHour
Min>TheMin
Sec>TheSec
//Set file path and name
Let>FilePath=%USERDOCUMENTS_DIR%\Screenshots
Let>FileName=%FilePath%\Screenshot-%TheYear%-%TheMonth%-%TheDay%-%TheHour%-%TheMin%-%TheSec%.png
//Create the output folder if it doesn't exist
IfNotDirExists>%FilePath%
CreateDir>%FilePath%
Endif
//Capture the screenshot
ScreenCapture>Xpos,Ypos,%BottomRightX%,%BottomRightY%,%FileName%
//Show the screenshot in Windows Explorer if ShowInFolder = yes
if>ShowInFolder=yes
RunProgram>Explorer /select,%FileName%
Endif
//Edit the screenshot in MS Paint if EditFile = yes
If>EditFile=yes
RunProgram>msPaint.exe %FileName%
Wait>1
WindowAction>1,Paint*
Endif
//Click on top left corner of window (add to Xpos and Ypos if you want to click further down or in)
If>WindowClick=yes
mousemove>Xpos,Ypos
lclick
Endif
Yes, we have a Custom Scripting Service. Message me or go here