Skip to content

Instantly share code, notes, and snippets.

@wildbook
Created June 13, 2017 12:42
Show Gist options
  • Save wildbook/ca1f785e1798651faa422a9eb9a37aa0 to your computer and use it in GitHub Desktop.
Save wildbook/ca1f785e1798651faa422a9eb9a37aa0 to your computer and use it in GitHub Desktop.
#include <Misc.au3>
#include <WinAPIGdi.au3>
#include <WinAPISys.au3>
HotKeySet("§", "TempAllow")
; Hotkey --^
While (True)
Local $tPos = _WinAPI_GetMousePos() ;Get mouse position
Local $hMonitor = _WinAPI_MonitorFromPoint($tPos) ;Get which monitor the mouse is on
Local $aData = _WinAPI_GetMonitorInfo($hMonitor) ;Get info about that monitor
; |Current monitor start x pos | Current monitor start y pos | Current monitor end x pos | Current monitor end y pos |
_MouseTrap(DllStructGetData($aData[0], 1), DllStructGetData($aData[0], 2), DllStructGetData($aData[0], 3), DllStructGetData($aData[0], 4)) ;Lock it there
Sleep(50) ;Sleep to avoid 100% CPU usage
WEnd
Func TempAllow()
_MouseTrap() ;Unlock the mouse
While (_IsPressed(0xA7)) ;Get decimal code at http://elv1s.ru/files/js/key-code-detector.html and convert to hex. (Must match "Hotkey" above)
Sleep(10) ;Sleep to avoid 100% CPU usage
WEnd
EndFunc ;==>TempAllow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment