HankHell Posted October 4, 2019 Posted October 4, 2019 (edited) been messing with this for a while now trying to get leftclick to disable clicking on windows, but at the same time able to activate functions. Just a simple screenshot program... I know HotKeySet disables the key while in use. Trying to mimic it with _IsPressed though, is another story... expandcollapse popup#include <ScreenCapture.au3> #include <Misc.au3> ;click upper left to lower right HotKeySet("{ESC}", "End") Global $Mpos1_x Global $Mpos1_y Global $Mpos2_x Global $Mpos2_y Global $check = 0 FindCoords() Func FindCoords() While 1 If $check = 0 Then Get1() EndIf If $check = 1 Then Get2() EndIf WEnd EndFunc Func Get1() If _IsPressed("01") Then $check = 1 $Mpos1 = MouseGetPos() $Mpos1_x = $Mpos1[0] $Mpos1_y = $Mpos1[1] Sleep(150) EndIf EndFunc Func Get2() If _IsPressed("01") Then $check = 3 $Mpos2 = MouseGetPos() $Mpos2_x = $Mpos2[0] $Mpos2_y = $Mpos2[1] Sleep(150) Capture() EndIf EndFunc Func Capture() Local $randomness = Random(0, 999999) $randomnumber = Round($randomness) _ScreenCapture_Capture("V:\location\"&$randomnumber&".jpg", $Mpos1_x, $Mpos1_y, $Mpos2_x, $Mpos2_y) Exit EndFunc Func End() Exit EndFunc Edited October 4, 2019 by HankHell double paste
Nine Posted October 4, 2019 Posted October 4, 2019 You could use my UDF : “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
mikell Posted October 4, 2019 Posted October 4, 2019 (edited) Or use a combination key + mouse hook expandcollapse popup#include <WinAPI.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <ScreenCapture.au3> Global $hHook, $hFunc, $pFunc, $hMod Global $check, $pos1, $pos2 HotKeySet('{ESC}', '_Close') $hFunc = DllCallbackRegister('_MouseProc', 'lresult', 'int;int;int') $pFunc = DllCallbackGetPtr($hFunc) $hMod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, $pFunc, $hMod) While 1 If $check = 2 Then $check = 0 ; Return MsgBox(4096, "", $pos1[0]&"x"&$pos1[1]&@crlf &$pos2[0]&"x"&$pos2[1]) _ScreenCapture_Capture(@scriptdir&"\test.jpg", $pos1[0], $pos1[1], $pos2[0], $pos2[1]) ShellExecute(@scriptdir&"\test.jpg") EndIf WEnd Func _MouseProc($iCode, $iwParam, $ilParam) If $iCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam) If _IsPressed("10") Then ; SHIFT Switch $iwParam Case $WM_LBUTTONUP If $check = 0 Then $pos1 = MouseGetPos() $check = 1 ElseIf $check = 1 Then $pos2 = MouseGetPos() $check = 2 EndIf Case $WM_RBUTTONDOWN ; reset at any time $check = 0 EndSwitch Return 1 EndIf Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam) EndFunc ;==>_MouseProc Func _Close() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hHook) Exit EndFunc ;==>_Close Edited October 4, 2019 by mikell comment
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