Code: Select all
CursorSTOP = 0
SetTimer, MouseCheck, 50 ; Check mouse position every 50 ms
MouseCheck:
MouseGetPos, MouseX, MouseY
IfWinActive, ApplicationTitle1
{
IsInsideB1 = 0
IsInsideB2 = 0
; Box 1 - An area inside the App, the allowed region
; ----------
B1_leftX = 0
B1_rightX = 370
B1_topY = 85
B1_bottomY = 485
If MouseX > %B1_leftX%
{
If MouseX < %B1_rightX%
{
If MouseY > %B1_topY%
{
If MouseY < %B1_bottomY%
{
IsInsideB1 = 1
}
}
}
}
; ----------
; Box 2 - The area of the entire App
; ----------
B2_leftX = 0
B2_rightX = 830
B2_topY = 0
B2_bottomY = 630
If MouseX > %B2_leftX%
{
If MouseX < %B2_rightX%
{
If MouseY > %B2_topY%
{
If MouseY < %B2_bottomY%
{
IsInsideB2 = 1
}
}
}
}
; ----------
If (IsInsideB1 = 0)
{
If (IsInsideB2 = 1)
{
If CursorSTOP = 0 ; If we are not inside the allowed region and are inside the app, then set the pointer to stop symbol
{
SetSystemCursor()
CursorSTOP = 1
}
}
Else
{
RestoreCursors()
CursorSTOP = 0
}
}
Else
{
RestoreCursors()
CursorSTOP = 0
}
}
Else
{
RestoreCursors()
CursorSTOP = 0
}
Return
Pause::
ExitApp
LButton::
If (CursorSTOP = 0) ; If the pointer is not the stop symbol, click as normal and otherwise just return
{
MouseClick, Left,,,,, D
KeyWait, LButton
MouseClick, Left,,,,, U
}
return
RButton::
If (CursorSTOP = 0)
{
MouseClick, Right,,,,, D
KeyWait, RButton
MouseClick, Right,,,,, U
}
return
SetSystemCursor()
{
IDC_NO := 32648
CursorHandle := DllCall( "LoadCursor", Uint, 0, Int, IDC_NO )
Cursors = 32512,32513,32514,32515,32516,32640,32641,32642,32643,32644,32645,32646,32648,32649,32650,32651
Loop, Parse, Cursors, `,
{
DllCall( "SetSystemCursor", Uint, CursorHandle, Int, A_Loopfield )
}
}
RestoreCursors()
{
SPI_SETCURSORS := 0x57
DllCall( "SystemParametersInfo", UInt, SPI_SETCURSORS, UInt, 0, UInt, 0, UInt, 0 )
}