Dear Autohotkey community,
I am a beginner trying almost a week to solve this problem but unsuccessful.
My screen is 1920x1080.
I need a Numpad5 to activate
a mouse left click and hold when the mouse pointer is on outside the box
and mouse right click in every 0.5 second when the mouse pointer is inside the box.
Could anyone help me this please? Thank you in advance.
Need help about a region of the screen, please.
Re: Need help about a region of the screen, please.
Welcome to this AutoHotkey forum!
Ideas:
Ideas:
Code: Select all
#Requires AutoHotkey v2.0
winTitle := "ahk_class MSPaintApp"
rclik := () => Send('{LButton up}{RButton}')
OnExit done
#HotIf WinActive(winTitle)
Numpad5::SetTimer check, 100
#HotIf
Esc::ExitApp
check() {
Static last := "", inside := "", str := ""
MouseGetPos &x, &y
last := inside, inside := x > 800 && x < 1120 && y > 400 && y < 680
If !inside { ; Outside box
SetTimer rclik, 0
Send GetKeyState("LButton") ? "" : "{LButton down}"
str := 'LButton down'
} Else (inside != last) && (SetTimer(rclik, 500), rclik(), str := 'RButton')
ToolTip('(' x ', ' y ')`n' str)
}
done(exitReason, exitCode) {
Click 'U'
SoundBeep 1500
}
Re: Need help about a region of the screen, please.
Thank you so much for your wonderful code. It works perfectly. Thank you.mikeyww wrote: ↑08 Feb 2023, 20:54Welcome to this AutoHotkey forum!
Ideas:
Code: Select all
#Requires AutoHotkey v2.0 winTitle := "ahk_class MSPaintApp" rclik := () => Send('{LButton up}{RButton}') OnExit done #HotIf WinActive(winTitle) Numpad5::SetTimer check, 100 #HotIf Esc::ExitApp check() { Static last := "", inside := "", str := "" MouseGetPos &x, &y last := inside, inside := x > 800 && x < 1120 && y > 400 && y < 680 If !inside { ; Outside box SetTimer rclik, 0 Send GetKeyState("LButton") ? "" : "{LButton down}" str := 'LButton down' } Else (inside != last) && (SetTimer(rclik, 500), rclik(), str := 'RButton') ToolTip('(' x ', ' y ')`n' str) } done(exitReason, exitCode) { Click 'U' SoundBeep 1500 }