Using Winkey + Click In An Image Search Script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Jrdixon_
Posts: 7
Joined: 09 Jul 2020, 19:41

Using Winkey + Click In An Image Search Script

10 Jul 2020, 15:29

Hey guys and girls.

I've just started messing around with some scripts today to incorporate into my Pro tools workflow and need some advice on perfecting this AHK Script.

Using imagesearch I've been able to get my mouse to click a button in the software perfectly, however I'd like to windows key + Click it instead. Below is the code

Code: Select all

+1::
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
MouseGetPos, PrevX, PrevY
loop, 2 ; wait a maximum of 1 seconds (10 * 100ms) for render button to appear
{
	ImageSearch, ImX, ImY, 0, 0, A_ScreenWidth, A_ScreenHeight, drums.png
	Sleep, 100
} until !ErrorLevel
if ErrorLevel
	run Show_Only_Drums_2.ahk
else
	Click, %ImX%, %ImY%
MouseMove, PrevX, PrevY
Sleep, 500

if WinExist("ahk_class DigiFloaterClass")
	WinKill

Return
As you can see I have figured out a way around the fact that the button is sometimes a different colour so it runs a different script which has the image in that colour instead.

Thanks in advance!
User avatar
boiler
Posts: 16965
Joined: 21 Dec 2014, 02:44

Re: Using Winkey + Click In An Image Search Script

10 Jul 2020, 16:36

Try this:

Code: Select all

+1::
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
MouseGetPos, PrevX, PrevY
loop, 2 ; wait a maximum of 1 seconds (10 * 100ms) for render button to appear
{
	ImageSearch, ImX, ImY, 0, 0, A_ScreenWidth, A_ScreenHeight, drums.png
	Sleep, 100
} until !ErrorLevel
if ErrorLevel
	run Show_Only_Drums_2.ahk
else
{
	Send, {LWin down}
	Click, %ImX%, %ImY%
	Send, {LWin up}
}
MouseMove, PrevX, PrevY
Sleep, 500

if WinExist("ahk_class DigiFloaterClass")
	WinKill

Return
Jrdixon_
Posts: 7
Joined: 09 Jul 2020, 19:41

Re: Using Winkey + Click In An Image Search Script

10 Jul 2020, 18:24

@boiler No joy with that :facepalm:

It just clicks it normally. I tried some other commands like ctrl click to see if it would work with those and it's still just clicking

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Google [Bot], OrangeCat and 180 guests