Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/30/2022 in all areas

  1. #include <WinAPIvkeysConstants.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #include <Misc.au3> Init() Do Until GUIGetMsg()=-3 Func Init() Global $hWndKeybd = GUICreate('') Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'UsagePage', 0x01) ; Generic Desktop Controls DllStructSetData($tRID, 'Usage', 0x06) ; Keyboard DllStructSetData($tRID, 'Flags', $RIDEV_INPUTSINK) DllStructSetData($tRID, 'hTarget', $hWndKeybd) _WinAPI_RegisterRawInputDevices($tRID) GUIRegisterMsg($WM_INPUT, WM_INPUT) GUISetState(@SW_SHOW) EndFunc Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Switch $hWnd Case $hWndKeybd Local $tRIK = DllStructCreate($tagRAWINPUTKEYBOARD) If _WinAPI_GetRawInputData($lParam, $tRIK, DllStructGetSize($tRIK), $RID_INPUT) Then KeystrokeLogic($tRIK) EndSwitch If $wParam Then Return 0 EndFunc Func KeystrokeLogic($tRIK) If $VK_SPACE = DllStructGetData($tRIK,'VKey') And BitAnd(1, DllStructGetData($tRIK,'Flags')) Then ; on spacebar release Local $tKeys = _WinAPI_GetKeyboardState() Local $chord = ( BitAnd(128,DllStructGetData($tkeys,1,1+$VK_Q)) ? 1 : 0 ) _ + ( BitAnd(128,DllStructGetData($tkeys,1,1+$VK_W)) ? 2 : 0 ) _ + ( BitAnd(128,DllStructGetData($tkeys,1,1+$VK_E)) ? 4 : 0 ) ; add one due to DllStructGetData being 1-based while the byte array is 0-based Switch $chord Case 1 Q() Case 2 W() Case 3 QW() Case 4 E() Case 5 EQ() Case 6 WE() Case 7 QWE() EndSwitch EndIf EndFunc Func Q() Beep(384,200) EndFunc Func W() Beep(432,200) EndFunc Func E() Beep(512,200) EndFunc Func QW() Beep(480,200) EndFunc Func WE() Beep(640,200) EndFunc Func EQ() Beep(576,200) EndFunc Func QWE() Beep(720,200) EndFunc _WinAPI_GetKeyboardState does not seem to have any example, I quickly whipped up this one demonstrating key chording actions for it. Hold a combination of Q+W+E and press spacebar to activate different actions (beeps on a diatonic scale, in this case)
    1 point
  2. You should test on another machine but as previously mentioned, the coordinates for the controlclick function are relative to the control as compared to mousemove that is relative to the screen. We seem to be just repeating the same info at this point so I am going to wish you the best with the project.
    1 point
  3. Didn't it work on your machine / monitor when you ran the code? You said "I don't know why, but your code works as I wanted." Did you have to adjust anything to make it work? I already answered the other thread you posted (please keep posts/threads separate) you should try the approach I linked.
    1 point
  4. SeanGozlan

    check radio buttons

    I have also problem with the radio button. There is any good example how to click on a radio button, but without using cordinate. This is odd. because the autoit tool find the radio button instances and the class easly. If there is a way to take the cordinate of class ? and then I can use to click on it. Please help.
    1 point
  5. Because I adjusted X. We are not using MouseMove which you have referenced a couple of times in the code. We are using parameters as part of the ControlClick function that tell the code where to click within the targeted control. X is one of those parameters. Not sure what you are seeing about the mouse moving outside the control, I don't see that. If your code has MouseMove then that could cause that issue because it is not relative to the control per se, rather to the screen.
    1 point
  6. Calculator's buttons can't be identified in that manner any longer because they moved to WPF in Windows 10. So you need to understand the applications that you are trying to automate and which technology can be used to identify the controls to interact with them. In the example of Calculator - UIAutomation should work. It should also work on other applications.
    1 point
  7. when you run the code I posted you should see this as output: This is This is text and i is $i2text and i is $i1 It is selecting "some" and replacing it with a carriage return. Of course, you can also solve this problem by editing the text before you send it to Notepad,
    1 point
  8. try the code in my edited post, yours works that way too but you are highlighting / selecting the very last text on the line instead of "some" because your X value is off
    1 point
  9. Double clicking the word in Notepad only selects it. Then when you send enter you are basically erasing that word and replacing it with a carriage return which moves everything after that to the next line (while preserving everything before it on the line which had the selected word). EDIT: and it does remove that word when it is replaced with the carriage return if that is the problem you are trying to solve. Change the value of x to 100 and run the code. Here it is with a sleep so you can see what is happening: Run('notepad.exe') WinWaitActive("Notepad", '', '1') Local $x = 100; position is 'some' Local $y = 142 ; position is 'some' Local $i = 1 While $i <= 2 Send('This is some text and i is $i' & $i) ControlClick('[Class:Notepad]', '', '', 'left', '2', $x, $y) sleep(1000) $i = $i + 1 Send('{ENTER}') WEnd MouseMove($x, $y)
    1 point
  10. Not sure I follow you 100% but it goes to the next line because you are sending the enter key to Notepad
    1 point
  11. I believe they changed calculator in Win 10. I think you need to use UIAutomation now:
    1 point
  12. Nine

    check radio buttons

    Man, take you time, and read carefully the code and the au3info. There is a difference (a 4 instead of a 9)
    0 points
  13. Nine

    check radio buttons

    First statement did not work, so all the rest is of course will not... Use the right class indicated in the au3info tool of the window
    0 points
×
×
  • Create New...