I tried
Code: Select all
mousegetpos, xpos, ypos
if (xpos > 1000)
{
mousemove, 900, ypos, 0
}
but it doesn't stay running. it just checks and closes itself..
Code: Select all
mousegetpos, xpos, ypos
if (xpos > 1000)
{
mousemove, 900, ypos, 0
}
Code: Select all
mousegetpos, xpos, ypos
if (xpos > 1000)
{
mousemove, 900, %ypos%, 0
}
no change. I mean I want to keep the script running , not just oncew0z wrote: ↑26 Sep 2020, 08:29Code: Select all
mousegetpos, xpos, ypos if (xpos > 1000) { mousemove, 900, %ypos%, 0 }
Code: Select all
Loop
{
mousegetpos, xpos, ypos
if (xpos > 1000)
{
mousemove, 900, %ypos%, 0
}
}
Esc::ExitApp ; stop the loop by exit the script
w0z wrote: ↑26 Sep 2020, 08:51Code: Select all
Loop { mousegetpos, xpos, ypos if (xpos > 1000) { mousemove, 900, %ypos%, 0 } } Esc::Reload ; stop the loop by reloading the script
Code: Select all
myFunction() {
MouseGetPos, mx, my
if (mx > 1000)
MouseMove, 900, % my
}
winTitle := "ahk_class Notepad" ; https://www.autohotkey.com/docs/misc/WinTitle.htm
coordModeMouse := "Screen" ;https://www.autohotkey.com/docs/commands/CoordMode.htm
; <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
CoordMode, Mouse, % coordModeMouse
WinWait % winTitle
EVENT_OBJECT_LOCATIONCHANGE := 0x800B
WinGet, PID, PID
hWinEventHook := DllCall("SetWinEventHook", "UInt", EVENT_OBJECT_LOCATIONCHANGE
, "UInt", EVENT_OBJECT_LOCATIONCHANGE
, "Ptr", 0
, "Ptr", RegisterCallback("WinEventProc")
, "UInt", PID
, "UInt", 0
, "UInt", 0) ; https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwineventhook
#Persistent
OnExit, handleExit
return
handleExit:
if (hWinEventHook)
DllCall("UnhookWinEvent", "Ptr", hWinEventHook) ; https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-unhookwinevent
ExitApp
WinEventProc(hWinEventHook, event, hwnd, idObject, idChild, idEventThread, dwmsEventTime) {
; https://docs.microsoft.com/en-us/windows/win32/api/winuser/nc-winuser-wineventproc
static OBJID_CURSOR := 0xFFFFFFF7
; https://docs.microsoft.com/en-us/windows/win32/winauto/object-identifiers
; https://www.autohotkey.com/boards/viewtopic.php?t=32039&p=167451#p264043
static bufferInfluxThreshold := 10
static f := Func("myFunction")
Critical
if (idObject <> OBJID_CURSOR)
return
SetTimer % f, % -bufferInfluxThreshold
}