Blog
Main » 2011 April 11 » WinCapture1:57 PM WinCapture |
This is a script to make a mouse capture or mouse trapper or whatever it calls. I added comments so I will not explain them one by one. You can download the script here, WinCapture.ahk. Script Code: Code ; This script is based on Bkid's script. #Persistent #NoEnv #SingleInstance ignore Menu, Tray, NoStandard ; Removes Tray Menu Standard Items. Menu, Tray, Add, Exit, ExitSub ; Adds an 'Exit' menu ; Hotkey to be used depends of the coder. SetScrollLockState, Off ; Makes the capslock state off. TrayTip, Mouse Capture, Press ScrollLock to start/stop mouse capture., 10 ; Tray tip notice SetTimer, Label, 5 ; Turns on the timer with 5 milliseconds check. return ExitSub: ExitApp ; Exits the application ; The label which will call the function. ; This is only a sample. You can change them in any way you want. Label: GetKeyState, State, ScrollLock, T if(State = "D"){ WinCapture("ahk_class Warcraft III", "", 4, 4, 24) ; See the function below. WinActivate, ahk_class Warcraft III ; Activates the script. Suspend, Off ; Activates the script. TrayTip, Mouse Capture, Mouse Capture activated. Press ScrollLock to stop., 10 ; Tray tip notice }else{ WinCapture() Suspend, On ; Suspends the script TrayTip, Mouse Capture, Mouse Capture deactivated. Press ScrollLock to start., 10 ; Tray tip notice } return ; Make a function to call for locking the mouse into a window. ; Syntax of the function: ; WinCapture("WinTitle", "WinText", "vBorder", "hBorder", "tBorder") ; WinTitle = The title or class of the window. Use ahk_class if window's class will be used. ; WinText = If present, this parameter must be a substring from a single text element of the target window. ; vBorder = The vertical border. The left and right borders of a window. Commonly about 4 pixels in size. ; hBorder = The horizontal border. The bottom border of a window. Commonly about 4 pixels in size. ; tBorder = The title bar border. Commonly about 24 pixels in size. ; The function. WinCapture(WinTitle = "", WinText = "", vBorder = "", hBorder = "", tBorder = "") ; => Start of function. { ; Enlarges a variable's holding capacity or frees its memory. Normally, this is necessary only for unusual circumstances such as DllCall. VarSetCapacity(VarSetA, 16) ; Gets the position of the window. WinGetPos, sX, sY, sWidth, sHeight, %WinTitle%, %WinText% if(!sWidth and !sHeight){ DllCall("ClipCursor") return, False } Loop, 4 { ; DLL Calls DllCall("RtlFillMemory", UInt,&VarSetA+0+A_Index-1, UInt,1, UChar,(sX + hBorder) >> 8*A_Index-8) DllCall("RtlFillMemory", UInt,&VarSetA+4+A_Index-1, UInt,1, UChar,(sY + tBorder) >> 8*A_Index-8) DllCall("RtlFillMemory", UInt,&VarSetA+8+A_Index-1, UInt,1, UChar,(sWidth + sX - vBorder)>> 8*A_Index-8) DllCall("RtlFillMemory", UInt,&VarSetA+12+A_Index-1, UInt,1, UChar,(sHeight + sY - vBorder) >> 8*A_Index-8) } DllCall("ClipCursor", "UInt", &VarSetA) return, True } ; End of function. |
|
Total comments: 0 | |