WARNING PERSONAL USE CODE AHEAD
Personal use code is code written for the personal use of the coder, therefore it may be buggy, lack comments, or be written in a lazy manner.
Code: Select all
#Region-Splash-And-Icon---------------------------------------------------------
#AutoIt3Wrapper_Res_LegalCopyright=Copyright 2010-2011 by Milo Christiansen
#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Res_Comment=
#AutoIt3Wrapper_Res_Fileversion=2.0
#AutoIt3Wrapper_Res_Field=Company|Double Click Technologies
#EndRegion-Splash-And-Icon------------------------------------------------------
;Header-Start-------------------------------------------------------------------
;
; AutoIt Version: 3.3.0.0
; Author: Milo Christiansen
;
; Script Function:
;
;
;Header-End---------------------------------------------------------------------
;Includes-Start-----------------------------------------------------------------
#Include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
;Includes-End-------------------------------------------------------------------
;Options-Start------------------------------------------------------------------
Opt("MustDeclareVars", 1)
Opt("TrayAutoPause",0)
;Options-End--------------------------------------------------------------------
;General-Declerations-Start-----------------------------------------------------
Dim $hDisplay
Dim $Count
; These coords define the area to trap the cursor in
; You will probably have to change these to fit your computer
Dim $ULX = 0
Dim $ULY = 0
Dim $BRX = 1280
Dim $BRY = 1024
;General-Declerations-End-------------------------------------------------------
;Input-Start--------------------------------------------------------------------
;Input-End----------------------------------------------------------------------
;Main-Script-Start--------------------------------------------------------------
_MouseTrap($ULX, $ULY, $BRX, $BRY)
;GUI
GUICreate("Mouse Restrictor v2", 234, 22, 0, 0, -1, $WS_EX_TOOLWINDOW)
$hDisplay = GUICtrlCreateLabel(" Mouse Confined to Primary Monitor", 1, 1, 232, 20, $SS_SUNKEN)
GUICtrlSetFont($hDisplay, 11, 400, 0, "Arial")
GUISetState()
_MouseTrap($ULX, $ULY, $BRX, $BRY)
;main loop
While 1
Local $MSG = GUIGetMsg()
Select
Case $MSG = $GUI_EVENT_CLOSE
; MouseTrap with no args untraps cursor
_MouseTrap()
Exit
Case Else
; This is called every few ms because any click ouside of a
; window owned be the calling aplication untraps the mouse.
; if call frequently this is not apperent to the user
If $Count > 20 Then $Count = 1 And _MouseTrap($ULX, $ULY, $BRX, $BRY)
$Count += 1
EndSelect
WEnd
;Main-Script-End----------------------------------------------------------------
;Function-Decleration-Start-----------------------------------------------------
;Function-Decleration-End-------------------------------------------------------consider this CC0
