-
Posts
152 -
Joined
-
Last visited
Everything posted by queensoft
-
Yes, I know it's an old thread, but what can I do, I need this script and it almost works. Just changed some Sleep, added console output: #include <Misc.au3> #include <MsgBoxConstants.au3> Global Const $hDLL = DllOpen("user32.dll") Global Const $sList = "abcdefghijklmnopqrstuvwxyz" Global Const $aList = StringSplit($sList,"",$STR_NOCOUNT) Global $bTreat = False OnAutoItExitRegister (_Bye) HotKeySet ("{ESC}", _Exit) For $c in $aList HotKeySet ($c,_Alpha) Next While True Sleep (10) WEnd Func _Alpha() If $bTreat Then Return $bTreat = True Local Const $iStart = Asc ("a"), $iVK = Dec("41"), $char = @HotKeyPressed Local $sVK = Hex(Asc($char) - $iStart + $iVK,2), $iCount = 0 HotKeySet (@HotKeyPressed) While _IsPressed($sVK, $hDLL) $iCount += 1 Sleep (10) WEnd ConsoleWrite($iCount*10 & " ms.") Send ($iCount > 3 ? StringUpper($char) : $char) HotKeySet ($char, _Alpha) $bTreat = False EndFunc Func _Exit () Exit EndFunc Func _Bye () DllClose ($hDLL) EndFunc Now the problem. Here's a sample output This was all done with CAPS off. Single / quick press = upper letter most of the times. Long press = a row of lower case + last letter upper. I just need the script to pass the lettrs exactly (upper / lower). The count (long/short press) is working just fine for me. Thanks.
-
Here you go:
-
Using standard _IsPressed function. Quick and dirty. #include <Misc.au3> Opt("MouseClickDownDelay", 0) Opt("MouseClickDownDelay", 0) Opt("MouseClickDragDelay", 0) HotKeySet("+{ESC}", "Terminate") Global $click = False ; variable to keep if mouse left still pressed (for drag&drop) Global $pos01[2]=[-1,-1] ; drag start position / left click position Global $pos02[2]=[-1,-1] ; drop end position while 1 if (_IsPressed(01)) Then ; left mouse click if (not($click)) Then ; if not clicked = first click $pos01 = MouseGetPos() ; record position $click = True ; mouse is clicked Sleep(1) EndIf While _IsPressed("01") ; while left mouse clicked, just repeat Sleep(1) WEnd EndIf $pos02 = MouseGetPos() ; get end position If ($pos01[0]<>$pos02[0]) or ($pos01[1]<>$pos02[1]) And ($pos01[0]<>-1) and ($pos01[1]<>-1) Then ; compare start / end positions, at least 2 different = drag&drop ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Drag & drop from ' & $pos01[0] & "x" & $pos01[1] & " to " & $pos02[0] & "x" & $pos02[1] & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $pos01[0]=-1 ; reset all values $pos01[1]=-1 $pos02[0]=-1 $pos02[1]=-1 $click = False EndIf If ($pos01[0]=$pos02[0]) and ($pos01[1]=$pos02[1]) And ($pos01[0]<>-1) and ($pos01[1]<>-1) Then ; compare start / end positions, if equal = left click ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Click at ' & $pos01[0] & "x" & $pos01[1] & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $pos01[0]=-1 ; reset all values $pos01[1]=-1 $pos02[0]=-1 $pos02[1]=-1 $click = False EndIf sleep(1) wend Func Terminate() MsgBox(0, "End", "End", 2) Exit EndFunc
-
It's working, I'll post a cleaned script tomorrow. Or better yet, make a separate thread.
-
Already used _IsPressed for left click. But it cannot detect drag&drop, right? Maybe detect click > record position > detect release > record position > if the 2 are different = drag&drop?! I'll have to check tomorrow evening.
-
Doesn't really matter to me, to me .... Right now I'm testing using 4 paint instances, one for each corner / quarter of the screen. But script should work with any other program, just replicating clicks / drags, pressing buttons, painting, selecting..... anything really. If you have other script / ideeas, that's also fine, I don't need to use this one exactly. Just detect left click and drag&drop, then replicate on different locations, then move cursor back to original position.
-
Well, yeah, that's what I thought too. And asked: how do I pause / resume the hook processing ?? I already tried using the start / stop functions from the script, but no luck.
-
I know OP is gone since 2015, but I'm hoping for a reply here from someone else. I use this script to detect left click and left drag&drop. Works great so far, I'm able to record mouse position for each operation (left click, start of drag, end of drop): see lines 77-82, 149-153, 182-189 Now, after each of these I need to replicate the operation: left click or drag&drop, on 3 different positions - lines 306-311 WARNING: the Form1 program window will freeze. You can stop the script using Tools > Stop executing menu, but the autoit3.exe (running window) process will not close, you have to restart computer. Cursor is moved to first position - line 308, but no click and Form1 freeze. And now the question: how to I pause the script, execute 3 clicks, resume script? I have tried using pause = OnAutoItExit line 324 and resume - Register callback lines (38-40) - before and after the clicks - but still no luck, Opt("MouseClickDownDelay", 1) Opt("MouseClickDragDelay", 1) #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Sleep(2000) Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" Global $currentEvent[2] Global $iLBUTTONDOWN = 0 Global $iRBUTTONDOWN = 0 Global $iMBUTTONDOWN = 0 Global $LRClickStatus = 0 Global $RLClickStatus = 0 Global $LRDrag = 0 Global $RLDrag = 0 Global $LMDrag = 0 Global $RMDrag = 0 Global $doubleClickTime = 400 Global $click = false, $drag = false, $drag01[2]=[-1, -1], $drop01[2]=[-1, -1] $Form1 = GUICreate("Form1", 633, 447, 192, 124) $Label1 = GUICtrlCreateLabel("Label1", 200, 8, 300, 100) GUISetState(@SW_SHOW) ;Register callback Global $hKey_Proc = DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr") Global $hM_Module = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0) Global $hM_Hook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE_LL, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hM_Module[0], "dword", 0) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE OnAutoItExit() Exit EndSwitch WEnd Func _Mouse_Proc($nCode, $wParam, $lParam) Local $info, $mouseData, $time, $timeDiff If $nCode < 0 Then $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndIf $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) $mouseData = DllStructGetData($info, 3) $time = DllStructGetData($info, 5) $timeDiff = $time - $currentEvent[1] Select Case $wParam = $WM_MOUSEMOVE ;Test for Drag in here If $currentEvent[0] <> "LDrag" Or $currentEvent[0] <> "LRDrag" Or $currentEvent[0] <> "LMDrag" Then If $iLBUTTONDOWN = 1 Then $currentEvent[0] = "LDrag" $p = MouseGetPos() If $drag = False Then $drag = True $drag01[0] = $p[0] $drag01[1] = $p[1] EndIf If $iRBUTTONDOWN = 1 Then $currentEvent[0] = "LRDrag" $LRDrag = 2 EndIf EndIf EndIf If $currentEvent[0] <> "RDrag" Or $currentEvent[0] <> "RMDrag" Or $currentEvent[0] <> "LRDrag" Then If $iRBUTTONDOWN = 1 Then $currentEvent[0] = "RDrag" EndIf EndIf If $currentEvent[0] <> "MDrag" Then If $iMBUTTONDOWN = 1 Then $currentEvent[0] = "MDrag" $currentEvent[1] = $time EndIf EndIf If $iRBUTTONDOWN = 1 And $iMBUTTONDOWN = 1 And $currentEvent[0] <> "RMDrag" Then $RMDrag = 2 $currentEvent[0] = "RMDrag" $currentEvent[1] = $time EndIf If $iLBUTTONDOWN = 1 And $iMBUTTONDOWN = 1 And $currentEvent[0] <> "LMDrag" Then $LMDrag = 2 $currentEvent[0] = "LMDrag" $currentEvent[1] = $time EndIf Case $wParam = $WM_MOUSEWHEEL If _WinAPI_HiWord($mouseData) > 0 Then ;Wheel Up $currentEvent[0] = "WheelUp" $currentEvent[1] = $time Else ;Wheel Down $currentEvent[0] = "WheelDown" $currentEvent[1] = $time EndIf Case $wParam = $WM_LBUTTONDOWN ;Register Button Down, check for Right/Left If $currentEvent[0] = "RClick" Then $LRClickStatus = 1 EndIf $iLBUTTONDOWN = 1 Case $wParam = $WM_LBUTTONUP ;Update $iLBUTTONDOWN $iLBUTTONDOWN = 0 ;Test for Right/Left Click If $RLClickStatus = 1 And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "RLClick" $currentEvent[1] = $time EndIf If $currentEvent[0] = "LClick" And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "LDClick" $currentEvent[1] = $time EndIf ;Test for Drops If $currentEvent[0] = "LDrag" Then $currentEvent[0] = "LDrop" $p = MouseGetPos() $drag = False $drop01[0] = $p[0] $drop01[1] = $p[1] $click = True $currentEvent[1] = $time EndIf If $LRDrag = 2 And $iRBUTTONDOWN = 1 Then $LRDrag = 1 ; Denote $LRDrag as still having one button clicked, need to register the drop on RButton up EndIf If $LRDrag = 1 And $iRBUTTONDOWN = 0 Then $currentEvent[0] = "LRDrop" $currentEvent[1] = $time $LRDrag = 0 EndIf If $LMDrag = 2 And $iMBUTTONDOWN = 1 Then $LMDrag = 1 ; Denote $LMDrag as still having one button clicked, need to register the drop on MButton up EndIf If $LMDrag = 1 And $iMBUTTONDOWN = 0 Then $currentEvent[0] = "LMDrop" $currentEvent[1] = $time $LMDrag = 0 EndIf ;Set LClick if other events haven't fired If $currentEvent[1] <> $time Then $currentEvent[0] = "LClick" $p = MouseGetPos() $currentEvent[1] = $time $drag01[0] = -1 $drag01[1] = -1 $drag = False $drop01[0] = $p[0] $drop01[1] = $p[1] $click = True EndIf ;Negate $LRClickStatus $RLClickStatus = 0 Case $wParam = $WM_RBUTTONDOWN ;Register Button Down If $currentEvent[0] = "LClick" Then $RLClickStatus = 1 EndIf $iRBUTTONDOWN = 1 Case $wParam = $WM_RBUTTONUP ;Test for Left, Right, and Right Doubleclick here ;Update $iRBUTTONDOWN $iRBUTTONDOWN = 0 ;Test for Right/Left Click If $LRClickStatus = 1 And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "LRClick" $currentEvent[1] = $time EndIf If $currentEvent[0] = "RClick" And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "RDClick" $currentEvent[1] = $time EndIf ;Test for Drops If $currentEvent[0] = "RDrag" Then $currentEvent[0] = "RDrop" $currentEvent[1] = $time EndIf If $LRDrag = 2 And $iLBUTTONDOWN = 1 Then $LRDrag = 1 ; Denote $LRDrag as still having one button clicked, need to register the drop on RButton up EndIf If $LRDrag = 1 And $iLBUTTONDOWN = 0 Then $currentEvent[0] = "LRDrop" $currentEvent[1] = $time $LRDrag = 0 EndIf If $RMDrag = 2 And $iMBUTTONDOWN = 1 Then $RMDrag = 1 ; Denote $LMDrag as still having one button clicked, need to register the drop on MButton up EndIf If $RMDrag = 1 And $iMBUTTONDOWN = 0 Then $currentEvent[0] = "RMDrop" $currentEvent[1] = $time $RMDrag = 0 EndIf ;Set LClick if other events haven't fired If $currentEvent[1] <> $time Then $currentEvent[0] = "RClick" $currentEvent[1] = $time EndIf ;Negate $LRClickStatus $LRClickStatus = 0 Case $wParam = $WM_MBUTTONDOWN ;Register Button Down $iMBUTTONDOWN = 1 Case $wParam = $WM_MBUTTONUP ;Test for Middle Double Click here ;Update $iRBUTTONDOWN $iMBUTTONDOWN = 0 ;Test for Right/Left Click If $currentEvent[0] = "MClick" And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "MDClick" $currentEvent[1] = $time EndIf ;Test for Drops If $currentEvent[0] = "MDrag" Then $currentEvent[0] = "MDrop" $currentEvent[1] = $time EndIf If $LMDrag = 2 And $iLBUTTONDOWN = 1 Then $LMDrag = 1 ; Denote $LRDrag as still having one button clicked, need to register the drop on RButton up EndIf If $LMDrag = 1 And $iLBUTTONDOWN = 0 Then $currentEvent[0] = "LMDrop" $currentEvent[1] = $time $LMDrag = 0 EndIf If $RMDrag = 2 And $iRBUTTONDOWN = 1 Then $RMDrag = 1 ; Denote $LMDrag as still having one button clicked, need to register the drop on MButton up EndIf If $RMDrag = 1 And $iRBUTTONDOWN = 0 Then $currentEvent[0] = "RMDrop" $currentEvent[1] = $time $RMDrag = 0 EndIf ;Set MClick if other events haven't fired If $currentEvent[1] <> $time Then $currentEvent[0] = "MClick" $currentEvent[1] = $time EndIf EndSelect ;~ GUICtrlSetData($Label1, $currentEvent[0] & @CRLF & $currentEvent[1]) if $click Then GUICtrlSetData($Label1, $currentEvent[0] & @CRLF & $currentEvent[1] & @CRLF & $drag01[0] & ' x ' & $drag01[1] & @CRLF & $drop01[0] & ' x ' & $drop01[1]) $click = False If $drag01[0]=-1 Then MouseClick("left", $drop01[0] + @DesktopWidth/2, $drop01[1], 1, 0) MouseClick("left", $drop01[0] + @DesktopWidth/2, $drop01[1] + @DesktopHeight/2, 1, 0) MouseClick("left", $drop01[0], $drop01[1] + @DesktopHeight/2, 1, 0) MouseMove($drop01[0], $drop01[1]) Else EndIf EndIf $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndFunc ;==>_Mouse_Proc Func OnAutoItExit() DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hM_Hook[0]) $hM_Hook[0] = 0 DllCallbackFree($hKey_Proc) $hKey_Proc = 0 EndFunc ;==>OnAutoItExit
-
Tried it. It's only for detection, which is already OK. This also works OK, same Handle, Class, Instance.... But as far as click..... still no luck. I tried like this: #include "UIAutomation.au3" WinActivate("actual window title") Sleep(333) _UIA_ControlClick(0x000801DE, 0x000C0C48, "left", 1) ; window handle, control handle, button, number of clicks _UIA_ControlClick(0x000801DE, 0x000C0C48, "invoke", 1) _UIA_ControlSend(0x000801DE, 0x000C0C48, "xxxx")
-
I'm on admin account, UAC disabled, everything runs as admin (no worries, I've been doing this for a while, like .... years, did Windows 3.1 even had admin rights ?! , and nothing bad happened)
-
I can get the control properties just fine: handle, position, Instance, Class, ClassNN - verified by 3 different sources. There are no Name, ID properties. What I cannot do is I cannot control (click, focus, send text) any of the controls. I will try your suggestion in 10-15 minutes, I seed it's based on UIAWrappers.au3
-
Tried just now - not working. Of course, there are other options, like MouseClick into several positions, but they are not very elegant.
-
I have a custom made Python script (both .py source code and .exe compiled versions. I need to fill in the text fields and click some buttons. Detection works perfectly, actual ControlClick / ControlSend does not. * Au3Info_x64.exe = OK - see attached image. One quick note here: when I drag & hover the target cursor, to get the info, the control is not selected / highlighted (like most other windows). It's just a quick flash, but the info is presented perfectly. * WinActivate / WinExists = OK #RequireAdmin is present, as is Opt('WinTitleMatchMode', 2) * This script works perfectly, I get the exact same info as Au3Info_x64.exe, all controls Handles, ClassNN, positions, everything Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default) If Not IsHWnd($hCallersWindow) Then ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF) Return False EndIf ; Get all list of controls If $bOnlyVisible = Default Then $bOnlyVisible = False If $sStringIncludes = Default Then $sStringIncludes = "" If $sClass = Default Then $sClass = "" $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 If StringLen($sClass)>0 Then For $i = UBound($aClassList)-1 To 0 Step - 1 If $aClassList[$i]<>$sClass Then _ArrayDelete($aClassList,$i) EndIf Next EndIf For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible") If $bOnlyVisible And Not $bIsVisible Then $iTotalCounter += 1 ContinueLoop EndIf If StringLen($sStringIncludes) > 0 Then If Not StringInStr($text, $sStringIncludes) Then $iTotalCounter += 1 ContinueLoop EndIf EndIf If IsArray($aPos) Then ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF) Else ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>GetAllWindowsControls * As far as I remember, IUIAutomation - detection part - also works OK, but not the click part. I'll try to work on this a bit more. And yet, after all this detection working OK, ControlClick / ControlSend does not. ControlClick just quickly flashes the buttons, but no action is performed (like open Browse dialog or show cursor inside text field)
-
Read File to Byte Array - very very slow
queensoft replied to queensoft's topic in AutoIt General Help and Support
Holy cow, this is fast !!!!!!! Working great now !! -
Read File to Byte Array - very very slow
queensoft replied to queensoft's topic in AutoIt General Help and Support
There's a small problem: Running:(3.3.16.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "D:\..........................\_testF15.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. !>16:53:46 AutoIt3.exe ended.rc:-1073741819 +>16:53:46 AutoIt3Wrapper Finished. >Exit code: 3221225477 Time: 2.101 Files are .bin, 2 Mb each (please do not share): https://drive.google.com/file/d/1ZquEnq_l-avs60WodgqSr9q2pdafrTeu/view?usp=sharing Testing with another pair of .bine files, 4 Mb each = same error. The .bin files are OK, I have already processed them using my script and there were checked by client. Testing with .jpg and .au3 (180, 250 Kb) / .exe & .dll (0.9 Mb each) = OK. Testing with 2 .exe files (2.0 & 2.3 Mb) = OK !!!! Also, how do I get the result? I know it's in the $nResult / $pResult variables, but I need to research DllStructGetData, right? Hmmm, nevermind, I have found the code to display the results, but it does not display anything. Tested with various random files, it seems to work, it shows Time: ......., but no results. -
Read File to Byte Array - very very slow
queensoft replied to queensoft's topic in AutoIt General Help and Support
Dude, you da man!!! Maybe I'll use it on version 2. Right now, program is working just fine as is. -
Read File to Byte Array - very very slow
queensoft replied to queensoft's topic in AutoIt General Help and Support
In the end, I used UEZ function + jchd FC.exe - everything works great -
Read File to Byte Array - very very slow
queensoft replied to queensoft's topic in AutoIt General Help and Support
It's coming along just fine, no worries! -
Read File to Byte Array - very very slow
queensoft replied to queensoft's topic in AutoIt General Help and Support
When I'm stoopid, I'm stoopid!!! I was still reading the 2 files into arrays before using fc.exe!!!! I didn't realized fc.exe is working with the original files directly. But I will still need to read the files, because I have to process & save them. In the end, I think a simple For loop - direct compare between the 2 arrays (files) - is fast enough for my needs. And it eliminates the need to capture & parse fc.exe output. -
Read File to Byte Array - very very slow
queensoft replied to queensoft's topic in AutoIt General Help and Support
I will surely try that, thanks. I'm working right now on the compare part, this is also tricky / slow..... -
Read File to Byte Array - very very slow
queensoft replied to queensoft's topic in AutoIt General Help and Support
That IS the real purpose. Read 2 files, same size, very similar content. Find differences between files, extract those differences (from file 2, position and value). Put those differences in another file. Just like Total Commander > Compare files, but instead of showing the differences, extract & save them. -
Read File to Byte Array - very very slow
queensoft replied to queensoft's topic in AutoIt General Help and Support
I need the entire file (files - 2, see reply above) at once. -
Read File to Byte Array - very very slow
queensoft replied to queensoft's topic in AutoIt General Help and Support
The _ArrayDisplay is just for checking the results. -
Read File to Byte Array - very very slow
queensoft replied to queensoft's topic in AutoIt General Help and Support
I'm well under the 16 Mb file size. The purpose is to compare / extract / save the differences between 2 .bin files, rinse, repeat with thousands of files. -
Read File to Byte Array - very very slow
queensoft replied to queensoft's topic in AutoIt General Help and Support
Holy Cow! Indeed faster, about 15-25% faster, down to 0.75 seconds.