Jump to content

Detect on AutoIt a key combination ( ctrl + left arrow ) not from the keyboard but by using a touchpad action


Go to solution Solved by Nine,

Recommended Posts

Posted

Hi everybody, is there a way to listen from this kind of events ? i already tried with _IsPressed but it does not work at all.

Posted

The code is working when i do the combination on my keyboard, but not by sending it from the driver of my touchpad. So, i don't think so the problem is from my code.

Posted
Opt("MustDeclareVars", True)

If @OSVersion <> "WIN_11" Then Exit MsgBox($MB_SYSTEMMODAL, "", "This script only runs on Win 11")

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_HiDpi=Y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

If Not (@Compiled ) Then DllCall("User32.dll","bool","SetProcessDPIAware")
Local $Dll = DllOpen("user32.dll")

While 1

    Sleep ( 50 )
    If _IsPressed("11", $Dll) Then
        If _IsPressed("25", $Dll) Then
            ExitLoop
        EndIf
    EndIf

WEnd

DllClose($Dll)

 

  • Developers
Posted

Ok... thanks for that part, but this part is still unclear:

18 minutes ago, Syla said:

but not by sending it from the driver of my touchpad.

So how exactly are you simulating this key combination from your touchpad?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted (edited)

Try to hook WH_KEYBOARD_LL with _WinAPI_SetWindowsHookEx (see help file, there is a nice example of it)

ps.  you can also take a look at my Debug Messages Monitor UDF (see my signature for a link to it)

Edited by Nine
Posted

https://learn.microsoft.com/en-us/windows/win32/winmsg/about-messages-and-message-queues

The whole windows system is based on messaging. Your swipedevice has a driver that if it nicely behaves transforms your guesture to a sendinput or sendmessage for a keyboardmessage ctrl and left. So you must know which messages the driver is sending and then you have to catche.hook them. An advanced topic where you probably have to read a lot.

  • Solution
Posted

@junkew  Sorry to disagree with you, but some messaging passes thru OutputDebugString API messages, not thru standard messages.  I tested a lot with those uncacheable messages and this is the only way.  Asking to GUIRegisterMsg is absolutely not the solution in his case.  Probably the best solution for OP is to hook to  WH_KEYBOARD_LL like I already suggested...

Posted

https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/wintouch/architectural-overview.md is having WM_TOUCH messages.

Then it depends afterwards what the driver is doing if its a nice driver it uses sendinput for driving the keyboard and/or mouse. (which you then can hook with a keyboard hook)

And not sure where MS is going with WinUI: https://learn.microsoft.com/en-us/uwp/api/windows.ui.input.preview.injection?view=winrt-26100

Posted (edited)

Thanks junkew and Nine, i will try all your solutions today and tell you back here.

Edited by Syla
Posted
#include <WinAPI.au3>
#include <WindowsConstants.au3>
HotKeySet('{F3}', '_EXIT')

Dim $hHook, $hFunc, $pFunc

$hFunc = DllCallbackRegister('_KeyboardHook', 'long', 'int;wparam;lparam')
$pFunc = DllCallbackGetPtr($hFunc)

$hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, $pFunc, _WinAPI_GetModuleHandle(0))

While 1
    Sleep(15)
WEnd

Func _EXIT()
    Exit
EndFunc

Func OnAutoItExit()
    _WinAPI_UnhookWindowsHookEx($hHook)
    DllCallbackFree($hFunc)
EndFunc

Func _KeyboardHook($iCode, $iwParam, $ilParam)
    Local $tKHS = DllStructCreate($tagKBDLLHOOKSTRUCT, $ilParam)
    Local $vkCode, $iScanCode

    If $iCode > -1 Then

        $vkCode = DllStructGetData($tKHS, 'vkCode')

        Switch $vkCode
            blah blah blah
        EndSwitch

    EndIf

    Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
EndFunc

Func _keybd_event($bvkCode, $Flag)
    DllCall('user32.dll', 'int', 'keybd_event', 'byte', $bvkCode, 'byte', 0, 'uint', $Flag, 'ptr', 0)
EndFunc;

Thanks To you both ! It works like a charm 🙂

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...