So i'm new to AutoHotkey, and i mainly use it for Maya (3d software)
I created a script to search for a slider i use (this one -> https://puu.sh/BPDqq/0a828ad5f1.png)
The script searches the logo with the TW at the center and sends the cursor on it, then clicks and hold, until i release the f key, then it sends the cursor back to its original position.
It's this one
Code: Select all
f::
CoordMode, Mouse, Screen
IfWinActive, ahk_exe maya.exe
{
MouseGetPos x, y
CoordMode Pixel
ImageSearch, FoundX, FoundY, 2, 840, 844, 1079, *50 D:\tw.jpg
if ErrorLevel = 2
MsgBox Could not conduct the search.
else if ErrorLevel = 1
MsgBox Image could not be found on the screen
else
BlockInput, MouseMove
CoordMode, Mouse, Screen
MouseMove, %FoundX%, %FoundY%, 0
MouseMove, 15, 15, 0, R
Click, down
BlockInput, MouseMoveOff
KeyWait, f
Click, up
MouseMove %x%, %y%, 0
return
}
else
SendInput {Blind}{Text}f
I wanted to try to keep my cursor between the boundaries of the cursor while i'm pressing the F key.
So i searched and found the ClipCursor function, which seems to work, but i don't know how to to turn it off except by pressing Alt+Tab or a Windows Key.
And all the scripts i found that use ClipCursor suggest to stop it by pressing another key or press the same key again to toggle it
It's not practical at all, because the whole purpose of the first script was to have only to press F, slide, and then release it to get my cursor back to its original position.
So basically i'm looking to get this script inside my first one
Code: Select all
Confine := !Confine
MouseGetPos, GetX, GetY
VarX1 := GetX - 90
VarX2 := GetX + 90
VarY1 := GetY - 0
VarY2 := GetY + 0
ClipCursor( 1, VarX1, VarY2, VarX2, VarY2)
return
ClipCursor( Confine := 1, x1=0 , y1=0, x2=1, y2=1 ) {
VarSetCapacity(R,16,0), NumPut(x1,&R+0),NumPut(y1,&R+4),NumPut(x2,&R+8),NumPut(y2,&R+12)
Return Confine ? DllCall( "ClipCursor", UInt,&R ) : DllCall( "ClipCursor" )
}
I tried to look on the forum but found nothing, i may have not searched for the right terms or something like that.
I'd be glad if you'd have a solution !
Cheers