CyNDeR Posted November 12, 2007 Share Posted November 12, 2007 I'm trying to write a script that will get the size of a window and set _MouseTrap() to keep the mouse within the window. My code so far is: #include <Misc.au3> HotKeySet("{END}", "Quit") HotKeySet("{PGUP}", "Enable") HotKeySet("{PGDN}", "Disable") While 1 WEnd Func Enable() $Pos = WinGetPos("") _MouseTrap($Pos[0], $Pos[1], $Pos[2], $Pos[3]) EndFunc Func Disable() _MouseTrap() EndFunc Func Quit() Exit EndFunc The left and top works fine, but the right and bottom are off. I've tried on several windows and still the same result. Any suggestions? My scripts: Random Painter Link to comment Share on other sites More sharing options...
Generator Posted November 12, 2007 Share Posted November 12, 2007 (edited) #include <Misc.au3> HotKeySet("{END}", "Quit") HotKeySet("{PGUP}", "Enable") HotKeySet("{PGDN}", "Disable") While 1 WEnd Func Enable() $Pos = WinGetPos("") _MouseTrap($Pos[0], $Pos[1], $Pos[0]+$Pos[2], $Pos[1]+$Pos[3]) EndFunc Func Disable() _MouseTrap() EndFunc Func Quit() Exit EndFunc Edited November 12, 2007 by Generator Link to comment Share on other sites More sharing options...
CyNDeR Posted November 13, 2007 Author Share Posted November 13, 2007 Oh yeah. X + Width and Y + Height. Thanks. My scripts: Random Painter Link to comment Share on other sites More sharing options...
Valuater Posted November 13, 2007 Share Posted November 13, 2007 (edited) Oh yeah. X + Width and Y + Height. Thanks.Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client????8) Edited November 13, 2007 by Valuater Link to comment Share on other sites More sharing options...
CyNDeR Posted November 13, 2007 Author Share Posted November 13, 2007 Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client????8)Tried that, it didnt work. My scripts: Random Painter Link to comment Share on other sites More sharing options...
Valuater Posted November 13, 2007 Share Posted November 13, 2007 Hmmm!!!...??? Works for me!! #include <Misc.au3> Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client Dim $enable HotKeySet("{END}", "Quit") HotKeySet("{PGUP}", "Enable") HotKeySet("{PGDN}", "Disable") While 1 Sleep(20) If $enable Then $Pos = WinGetPos("") _MouseTrap($Pos[0], $Pos[1], $Pos[0]+$Pos[2], $Pos[1]+$Pos[3]) EndIf WEnd Func Enable() $enable = 1 EndFunc ;==>Enable Func Disable() $enable = 0 _MouseTrap() EndFunc ;==>Disable Func Quit() Exit EndFunc ;==>Quit 8) Link to comment Share on other sites More sharing options...
CyNDeR Posted November 13, 2007 Author Share Posted November 13, 2007 (edited) And this: #include <Misc.au3> HotKeySet("{END}", "Quit") HotKeySet("{PGUP}", "Enable") HotKeySet("{PGDN}", "Disable") While 1 Sleep(100) WEnd Func Enable() $Pos = WinGetPos("") _MouseTrap($Pos[0], $Pos[1], $Pos[0] + $Pos[2], $Pos[1] + $Pos[3]) EndFunc ;==>Enable Func Disable() _MouseTrap() EndFunc ;==>Disable Func Quit() Exit EndFunc ;==>Quit ... is working fine for me. EDIT: Posted wrong code. Edited November 13, 2007 by CyNDeR My scripts: Random Painter Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now