Jump to content

Proton

Active Members
  • Posts

    25
  • Joined

  • Last visited

Everything posted by Proton

  1. Jos, Then there's the explanation. There are a lot of autoit scripts that recognize a piece of the picture on the screen. But there are no autoit scripts that recognize a piece of melody. However, there are a huge number of programs that recognize audio SPEECH. It is essentially the same sound, only more complicated. So I'm wondering why you can recognize speech, but can't recognize a regular audio file. For this reason, I decided to write my question on the forum to find out the reason for this contradiction. And find out how such an algorithm can be done in autoit (or impossible).
  2. Jos, What do you mean, "what am I doing here" ? I ask a question on the forum: Advise me how to get the autoit script to react on the sound on the computer for a certain tune long 2 seconds (it's a melody, not voice) ? Is that a forbidden question to ask ? Is he some kind of criminal ?
  3. czardas, Well, not a computer game, and let the film or program excel. So it is probably the rules of the forum - not a contradiction ? I mean ANY program that periodically produces a certain sound.
  4. czardas, I mean ANY program that periodically produces a certain sound.
  5. orbs, No. Requires a reaction to the sound itself and only sound.
  6. czardas, I found this a script that simply responds to any sound. How to configure it to respond to the sound of tada (using PixelSearch) ? #include <GuiConstants.au3> #include <ProgressConstants.au3> Global Const $S_OK = 0 ;=============================================================================== #interface "IMMDeviceEnumerator" Global Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}" Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}" ; Definition Global Const $tagIMMDeviceEnumerator = "EnumAudioEndpoints hresult(dword;dword;ptr*);" & _ "GetDefaultAudioEndpoint hresult(dword;dword;ptr*);" & _ "GetDevice hresult(wstr;ptr*);" & _ "RegisterEndpointNotificationCallback hresult(ptr);" & _ "UnregisterEndpointNotificationCallback hresult(ptr);" ;=============================================================================== ;=============================================================================== #interface "IMMDevice" Global Const $sIID_IMMDevice = "{D666063F-1587-4E43-81F1-B948E807363F}" ; Definition Global Const $tagIMMDevice = "Activate hresult(clsid;dword;variant*;ptr*);" & _ "OpenPropertyStore hresult(dword;ptr*);" & _ "GetId hresult(ptr*);" & _ "GetState hresult(dword*);" ;=============================================================================== ;=============================================================================== #interface "IAudioMeterInformation" Global Const $sIID_IAudioMeterInformation = "{C02216F6-8C67-4B5B-9D00-D008E73E0064}" ; Definition Global Const $tagIAudioMeterInformation = "GetPeakValue hresult(float*);" & _ "GetMeteringChannelCount hresult(dword*);" & _ "GetChannelsPeakValues hresult(dword;float*);" & _ "QueryHardwareSupport hresult(dword*);" ;=============================================================================== Global $oAudioMeterInformation = _AudioVolObject() If Not IsObj($oAudioMeterInformation) Then Exit -1 ; Will happen on non-supported systems Global $hGUI Global $hControl = _MakePeakMeterInWindow($hGUI) ; Register function to periodically update the progress control AdlibRegister("_LevelMeter", 45) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd AdlibUnRegister() ; Bye, bye... Func _MakePeakMeterInWindow($hWindow) $hWindow = GUICreate("ABC", 150, 400) Return GUICtrlCreateProgress(20, 70, 15, 200, $PBS_VERTICAL) EndFunc Func _LevelMeter() Local $iPeak If $oAudioMeterInformation.GetPeakValue($iPeak) = $S_OK Then $iCurrentRead = 100 * $iPeak GUICtrlSetData($hControl, $iCurrentRead + 1) GUICtrlSetData($hControl, $iCurrentRead) EndIf EndFunc Func _AudioVolObject() ; Sequences of code below are taken from the source of plugin written for AutoIt for setting master volume on Vista and above systems. ; Code was written by wraithdu in C++. ; MMDeviceEnumerator Local $oMMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $tagIMMDeviceEnumerator) If @error Then Return SetError(1, 0, 0) Local Const $eRender = 0 Local Const $eConsole = 0 ; DefaultAudioEndpoint Local $pDefaultDevice $oMMDeviceEnumerator.GetDefaultAudioEndpoint($eRender, $eConsole, $pDefaultDevice) If Not $pDefaultDevice Then Return SetError(2, 0, 0) ; Turn that pointer into object Local $oDefaultDevice = ObjCreateInterface($pDefaultDevice, $sIID_IMMDevice, $tagIMMDevice) Local Const $CLSCTX_INPROC_SERVER = 0x1 ; AudioMeterInformation Local $pAudioMeterInformation $oDefaultDevice.Activate($sIID_IAudioMeterInformation, $CLSCTX_INPROC_SERVER, 0, $pAudioMeterInformation) If Not $pAudioMeterInformation Then Return SetError(3, 0, 0) Return ObjCreateInterface($pAudioMeterInformation, $sIID_IAudioMeterInformation, $tagIAudioMeterInformation) EndFunc
  7. orbs, I didn't mean the reaction to any sound produced by the sound card. I mean , a reaction to a particular tune.
  8. Hello, friends. Advise me how to get the autoit script to react on the sound on the computer for a certain tune long 2 seconds (it's a melody, not voice) ? This file C:\Windows\Media\tada.wav (provided of course that there are no sounds from any other processes) But the script should not react to the launch of this file or the appearance of a window with this name, or a process with this address - namely, this sound. How can this be done with autoit ? (That is, apparently this sound should be stored somewhere in memory, and the script should always hang in the tray - not to miss this sound)
  9. Hello friends. Advise me how to script autoit remove the password to print the document-from the pdf file ? Now I use the online tool https://pdf.io/unlock/
  10. Hello, friends. Advise how to code autoit to recognize the coordinates of the points on the graph and put them in a table ?
  11. careca, Your script works ! But this script disables keys on all keyboards. How to use your script for only one keyboard (marked "Different Device Pressed") ?
  12. argumentum,It doesn't work. When triggered, the script still prints an unnecessary "a". ;Bilgus 2018 ;Determine which keyboard was pressed #include <Array.au3> #include <WinAPISys.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> Global Const $HWND_MESSAGE = (-3) ;create a message-only window when set as Parent ;RAWINPUTDEVICE Constants Global Const $HID_USAGE_PAGE_GENERIC = 0x1 Global Const $HID_USAGE_GENERIC_KEYBOARD = 0x6 Global $ghSelectedDevice Global $gaKeyboards = EnumRawKeyboards("\HID") If IsArray($gaKeyboards) And $gaKeyboards[0][0] >= 1 Then $ghSelectedDevice = $gaKeyboards[1][0] ; hard coded change to suit ;_ArrayDisplay($gaKeyboards, '_WinAPI_EnumRawInputDevices', "", 0, Default, "Handle|Type|VID|Keys") ;Not Needed... Global $hTarget = GUICreate("main", 10, 10, Default, Default, Default, Default, $HWND_MESSAGE) ;Dummy window to recieve messages Register_RawInput($HID_USAGE_PAGE_GENERIC, $HID_USAGE_GENERIC_KEYBOARD, $RIDEV_INPUTSINK, $hTarget) ;$RIDEV_INPUTSINK recieves input when not foreground ; Register WM_INPUT message GUIRegisterMsg($WM_INPUT, 'WM_INPUT') While 1 Sleep(1000) WEnd Func Device_Pressed() ConsoleWrite("Device Pressed" & @CRLF) EndFunc ;==>Device_Pressed Func _Exit() Exit EndFunc ;==>_Exit Func Register_RawInput($iUsagePage, $iUsage, $iFlags, $hTargetHwnd) Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'UsagePage', $iUsagePage) DllStructSetData($tRID, 'Usage', $iUsage) DllStructSetData($tRID, 'Flags', $iFlags) DllStructSetData($tRID, 'hTarget', $hTargetHwnd) ; Register HID input to obtain info from devices _WinAPI_RegisterRawInputDevices($tRID) EndFunc ;==>Register_RawInput Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) ;Callback from RawInput #forceref $iMsg, $wParam Local $tInfo, $aData = _WinAPI_EnumRawInputDevices() Local $_tagRID_INFO_KEYBOARD = $tagRID_INFO_KEYBOARD Local $tInfo, $tDeviceName, $sDeviceName ;'struct;dword Type;dword Size;handle hDevice;wparam wParam;endstruct' Local $tRIH = DllStructCreate($tagRAWINPUTHEADER) If _WinAPI_GetRawInputData($lParam, $tRIH, DllStructGetSize($tRIH), $RID_HEADER) And DllStructGetData($tRIH, "Type") = $RIM_TYPEKEYBOARD Then ;ConsoleWrite("0x" & Hex(DllStructGetData($tRIH, "hDevice")) & @CRLF) If $ghSelectedDevice = DllStructGetData($tRIH, "hDevice") Then ;ConsoleWrite("Device Pressed" & @CRLF) Else ;ConsoleWrite("Different Device Pressed" & @CRLF) EndIf If _ispressed('41') = 1 And DllStructGetData($tRIH, "hDevice") = 0x00010049 Then ;ConsoleWrite('Yes A' &@CRLF) MsgBox(64, 'Result', 'Key А - PS2') EndIf If _ispressed('41') = 1 And DllStructGetData($tRIH, "hDevice") = $HandleX Then ;ConsoleWrite('Yes A' &@CRLF) MsgBox(64, 'Result', 'Key А - USB') EndIf EndIf Return 1 Return $GUI_RUNDEFMSG ;Pass on to default winproc EndFunc ;==>WM_INPUT Func EnumRawKeyboards($sDeviceNameMatch = "") ;Returns array of keyboard device IDs Local $tInfo, $aData = _WinAPI_EnumRawInputDevices() If IsArray($aData) Then Local $aKeyboards[$aData[0][0] + 1][4] ;'dword Size;dword Type;';'struct;dword KbType;dword KbSubType;dword KeyboardMode;dword NumberOfFunctionKeys;dword NumberOfIndicators;dword NumberOfKeysTotal;endstruc' Local $_tagRID_INFO_KEYBOARD = $tagRID_INFO_KEYBOARD If StringRight($_tagRID_INFO_KEYBOARD, 1) <> "t" Then $_tagRID_INFO_KEYBOARD &= "t" ; t is missing from endstruct Local $iCt = 0, $iSz Local $tInfo, $tDeviceName, $sDeviceName For $i = 1 To $aData[0][0] $tInfo = DllStructCreate($_tagRID_INFO_KEYBOARD) If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tInfo, DllStructGetSize($tInfo), $RIDI_DEVICEINFO) And $aData[$i][1] = $RIM_TYPEKEYBOARD Then $iSz = _WinAPI_GetRawInputDeviceInfo($aData[$i][0], 0, 0, $RIDI_DEVICENAME) ;Get bytes needed $tDeviceName = DllStructCreate('wchar[' & $iSz + 1 & ']') ;Holds device name string If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tDeviceName, DllStructGetSize($tDeviceName), $RIDI_DEVICENAME) Then $sDeviceName = DllStructGetData($tDeviceName, 1) If $sDeviceNameMatch <> "" And Not StringInStr($sDeviceName, $sDeviceNameMatch) Then ContinueLoop $iCt += 1 $aKeyboards[$iCt][0] = $aData[$i][0] ;Handle $aKeyboards[$iCt][1] = $aData[$i][1] ;Type $aKeyboards[$iCt][2] = $sDeviceName $aKeyboards[$iCt][3] = DllStructGetData($tInfo, "NumberOfKeysTotal") Global $HandleX = $aData[1][0] EndIf EndIf Next $aKeyboards[0][0] = $iCt ; Write count of keyboard devices to array ReDim $aKeyboards[$iCt + 1][4] ;Resize array EndIf Return $aKeyboards EndFunc ;==>EnumRawKeyboards
  13. careca, That's clear. Now the hotkeys are working. But at the same time, after pressing the keys, letters are still entered. So I ask this question.
  14. One more question. This code temporarily freezes the key after it is activated. If _ispressed('41') = 1 And DllStructGetData($tRIH, "hDevice") = 0x00010049 Then _BlockInputEx(3, "", "[a]") AdlibRegister("_Quit", 10000) MsgBox(64, 'Result', 'key А - PS2') EndIf #include <BlockInputEx.au3> http://www.autoitscript.com/forum/index.php?s=&showtopic=87735 How to prevent entering text from the keyboard (with handle number 0x00010049) from the moment the code is run ?
  15. One more question. This code temporarily freezes the key after it is activated. If _ispressed('41') = 1 And DllStructGetData($tRIH, "hDevice") = 0x00010049 Then _BlockInputEx(3, "", "[a]") AdlibRegister("_Quit", 10000) MsgBox(64, 'Result', 'key А - PS2') EndIf How to prevent entering text from the keyboard (with handle number 0x00010049) from the moment the code is run ?
  16. Melba23, I understood. This is protection against hackers.
  17. Then I want to ask a question. This code responds to buttons on different keyboards. ;Bilgus 2018 ;Determine which keyboard was pressed #include <Array.au3> #include <WinAPISys.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global Const $HWND_MESSAGE = (-3) ;create a message-only window when set as Parent ;RAWINPUTDEVICE Constants Global Const $HID_USAGE_PAGE_GENERIC = 0x1 Global Const $HID_USAGE_GENERIC_KEYBOARD = 0x6 Global $ghSelectedDevice Global $gaKeyboards = EnumRawKeyboards("\HID") If IsArray($gaKeyboards) And $gaKeyboards[0][0] >= 1 Then $ghSelectedDevice = $gaKeyboards[1][0] ; hard coded change to suit _ArrayDisplay($gaKeyboards, '_WinAPI_EnumRawInputDevices', "", 0, Default, "Handle|Type|VID|Keys") ;Not Needed... Global $hTarget = GUICreate("main", 10, 10, Default, Default, Default, Default, $HWND_MESSAGE) ;Dummy window to recieve messages Register_RawInput($HID_USAGE_PAGE_GENERIC, $HID_USAGE_GENERIC_KEYBOARD, $RIDEV_INPUTSINK, $hTarget) ;$RIDEV_INPUTSINK recieves input when not foreground ; Register WM_INPUT message GUIRegisterMsg($WM_INPUT, 'WM_INPUT') HotKeySet("{ESC}", _Exit) While 1 Sleep(1000) WEnd Func Device_Pressed() ConsoleWrite("Device Pressed" & @CRLF) EndFunc ;==>Device_Pressed Func _Exit() Exit EndFunc ;==>_Exit Func Register_RawInput($iUsagePage, $iUsage, $iFlags, $hTargetHwnd) Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'UsagePage', $iUsagePage) DllStructSetData($tRID, 'Usage', $iUsage) DllStructSetData($tRID, 'Flags', $iFlags) DllStructSetData($tRID, 'hTarget', $hTargetHwnd) ; Register HID input to obtain info from devices _WinAPI_RegisterRawInputDevices($tRID) EndFunc ;==>Register_RawInput Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) ;Callback from RawInput #forceref $iMsg, $wParam ;'struct;dword Type;dword Size;handle hDevice;wparam wParam;endstruct' Local $tRIH = DllStructCreate($tagRAWINPUTHEADER) If _WinAPI_GetRawInputData($lParam, $tRIH, DllStructGetSize($tRIH), $RID_HEADER) And DllStructGetData($tRIH, "Type") = $RIM_TYPEKEYBOARD Then ConsoleWrite("0x" & Hex(DllStructGetData($tRIH, "hDevice")) & @CRLF) If $ghSelectedDevice = DllStructGetData($tRIH, "hDevice") Then Device_Pressed() Else ;Different Device ConsoleWrite("Different Device Pressed" & @CRLF) EndIf EndIf Return $GUI_RUNDEFMSG ;Pass on to default winproc EndFunc ;==>WM_INPUT Func EnumRawKeyboards($sDeviceNameMatch = "") ;Returns array of keyboard device IDs Local $tInfo, $aData = _WinAPI_EnumRawInputDevices() If IsArray($aData) Then Local $aKeyboards[$aData[0][0] + 1][4] ;'dword Size;dword Type;';'struct;dword KbType;dword KbSubType;dword KeyboardMode;dword NumberOfFunctionKeys;dword NumberOfIndicators;dword NumberOfKeysTotal;endstruc' Local $_tagRID_INFO_KEYBOARD = $tagRID_INFO_KEYBOARD If StringRight($_tagRID_INFO_KEYBOARD, 1) <> "t" Then $_tagRID_INFO_KEYBOARD &= "t" ; t is missing from endstruct Local $iCt = 0, $iSz Local $tInfo, $tDeviceName, $sDeviceName For $i = 1 To $aData[0][0] $tInfo = DllStructCreate($_tagRID_INFO_KEYBOARD) If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tInfo, DllStructGetSize($tInfo), $RIDI_DEVICEINFO) And $aData[$i][1] = $RIM_TYPEKEYBOARD Then $iSz = _WinAPI_GetRawInputDeviceInfo($aData[$i][0], 0, 0, $RIDI_DEVICENAME) ;Get bytes needed $tDeviceName = DllStructCreate('wchar[' & $iSz + 1 & ']') ;Holds device name string If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tDeviceName, DllStructGetSize($tDeviceName), $RIDI_DEVICENAME) Then $sDeviceName = DllStructGetData($tDeviceName, 1) If $sDeviceNameMatch <> "" And Not StringInStr($sDeviceName, $sDeviceNameMatch) Then ContinueLoop $iCt += 1 $aKeyboards[$iCt][0] = $aData[$i][0] ;Handle $aKeyboards[$iCt][1] = $aData[$i][1] ;Type $aKeyboards[$iCt][2] = $sDeviceName $aKeyboards[$iCt][3] = DllStructGetData($tInfo, "NumberOfKeysTotal") EndIf EndIf Next $aKeyboards[0][0] = $iCt ; Write count of keyboard devices to array ReDim $aKeyboards[$iCt + 1][4] ;Resize array EndIf Return $aKeyboards EndFunc ;==>EnumRawKeyboards The code is written in the console for the PS2-keyboard: 0х00010049 Different Device Pressed The code is written to the console via a USB keyboard: 0х280112C7 Device Pressed But this code does not determine which key is pressed. How to make autoit script to define different keys "Q" ? If I press Q - on the PS2 keyboard - then Msgbox (or console) shows the message - "Key Q, PS2 Keyboard" If I press Q - on the USB keyboard - then Msgbox shows the message - "Key Q, USB Keyboard"
  18. Melba23, This information is of interest. Thanks you.
  19. Nine, I want to have a lot of hotkeys on the second keyboard. Therefore, I ask this question.
  20. careca, I did not find examples of the keyboard on the link.
  21. Hello. I have two keyboards on my computer. One is connected via the PS2 port, the second is connected via the USB port. I press the "Q" key first - on one keyboard, then a similar key - on the second keyboard. How can the autoit script recognize - from which keyboard - were these presses made? If I press Q - on the PS2 keyboard - then Msgbox shows the message - "PS2 Keyboard" If I press Q - on the USB keyboard - then Msgbox shows the message - "USB Keyboard"
×
×
  • Create New...