ImageSearch headless Windows 10 PC

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Tasm1
Posts: 2
Joined: 29 Jul 2021, 06:27

ImageSearch headless Windows 10 PC

29 Jul 2021, 06:42

Hi all!

I've got a basic script that does some ImageSearch clicks of a PC as part of a routine function to bridge a few programs' datasets. It's just on a windows scheduler event every day to make this occur.

I don't mind leaving the PC on and logged in 24/7, so it shouldn't have to wake the computer or any fancy stuff, but I would be open to any ideas too :D

Basically I just want to control some GUI's with mouseclicks on a headless PC. I seem to be able to do this fine with remote desktop as the Windows GUI is updates as it's pushing a display. The problem comes when I disconnect RDP, or turn a connected screen off (I want to run headless). The Windows GUI does not draw.

I'm looking to get around this by forcing the screen to update between my image searches & program launches.

Here is a snippet, it's basically a bunch of ImageSearches on an IF error logic. My question is, how would I go about making the Windows GUI forcibly refresh to allow image searches to continue? Where would I put these refreshes? Also I'm calling other .exe's to run certain things in-between, which would need to refresh the GUI afterwards too, because I'll be doing even more searches after that.

Code: Select all

{
	Sleep 5000
	{
	CoordMode, Pixel, Window
	ImageSearch, X1, X2, 1, 0, 1920, 1080, *50 excelopen.PNG
		If ErrorLevel = 0
			{
				sleep 100
				Random, Random1, 1, 10
				MouseClick, right, X1+1, X2+10,, 0
			}
	Else If ErrorLevel > 0
			{
				Sleep 200
					ImageSearch, X1, X2, 1, 0, 1920, 1080, *50 open.PNG
					If ErrorLevel = 0
					{
					sleep 10
					Random, Random1, 1, 10
					MouseClick, right, X1+1, X2+10,, 0
					}
			}
		
						{
						CoordMode, Pixel, Window
						ImageSearch, X1, X2, 1, 0, 1920, 1080, *50 master.PNG
						If ErrorLevel > 0
							{
							sleep 1000
							CoordMode, Pixel, Window
							ImageSearch, X1, X2, 1, 0, 1920, 1080, *50 master2.PNG
							If ErrorLevel > 0
								{
								sleep 100
								Random, Random1, 1, 10
								MouseClick, left, X1+1, X2+10,, 0
								}
							}
							Else If ErrorLevel = 0
							{
							Random, Random1, 1, 10
							MouseClick, left, X1+1, X2+1,, 0
							sleep 500
							}
						}
						
						etc
						
						etc
						
						etc
						
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: ImageSearch headless Windows 10 PC

29 Jul 2021, 17:27

You posted AHK v1 code, and this is the section for questions regarding v2, which is in beta testing. You probably would get more response if you posted this in the v1 (main) section of Ask For Help.

Regarding your question, one way around this that I've used is to have two layers of RDP with the script running on the "inner" one if you have access to another machine (virtual or otherwise). That would allow you to disconnect from the "outer" RDP, but the inner one is still running with its screen resolution definition and various windows still intact because there is still a connection to it from the outer RDP, so the various windows should still be updating and available to be searched as usual. When you connect to the outer RDP again, there should still be the inner RDP window there with everything inside of it running.
Tasm1
Posts: 2
Joined: 29 Jul 2021, 06:27

Re: ImageSearch headless Windows 10 PC

29 Jul 2021, 17:52

Ah shit, sorry! Can this topic be moved?

Also, that's a novel way around it. It would work for sure, however if the network goes down it's kaput.

Is there any way to get a virtual display or remote into itself?

Fun update! I didn't know these existed LOL, seems like it could solve my problem !
https://www.amazon.com/Displayport-Display-Emulator-Headless-4096x2160/dp/B074FT1P8M
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: ImageSearch headless Windows 10 PC

29 Jul 2021, 18:03

Tasm1 wrote: Ah shit, sorry! Can this topic be moved?
The mods can move it if they see it. You could report it to them by clicking the ! icon next to the post.
Tasm1 wrote: Is there any way to get a virtual display or remote into itself?
You could run a virtual machine on your machine and run your script inside it, allowing you to turn off the monitor or whatever.
Tasm1 wrote: Fun update! I didn't know these existed LOL, seems like it could solve my problem !
https://www.amazon.com/Displayport-Display-Emulator-Headless-4096x2160/dp/B074FT1P8M
I wasn’t aware of that either. That’s good to know. Thanks. :thumbup:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Joey5, RandomBoy and 356 guests