Page 1 of 1

[Touchpad] Issue with blocking keys temporarily

Posted: 23 Apr 2019, 09:08
by Scr1pter
Hi guys,

I bought a USB Touchpad which sends specific keycombinations when doing 3 and 4 finger gestures.
For the left and right 3 finger swipe it sends Alt+Tab/Alt+Shift+Tab.

The problem is that when I swipe too long/wide, it starts sending Left/Right additionally.
(Probably to allow a user to browse through all opene applications more easily.)

Anyway, for me it's disturbing, so I'm trying to block Left/Right temporarily right after I perform a 3 finger left/right swipe.
That's the code, but I'm having two problems.

Code: Select all

!+Tab:: ; 3 fingers left-swipe
Send left
blockKeys := 1 ; Block ON
Sleep, 1000 ; After 1 second:
blockKeys := 0 ; Block OFF
;Block_Keys_Temporarily() ; Blocks a list of specified keys for 1 second - FUNKTION DOES NOT WORK
return

!Tab:: ; 3 fingers right-swipe
Send right
blockKeys := 1 ; Block ON
Sleep, 1000 ; After 1 second:
blockKeys := 0 ; Block OFF
;Block_Keys_Temporarily() ; Sperrt eine Liste von definierten Tasten für 1 Sekunde - FUNKTION DOES NOT WORK
return

Block_Keys_Temporarily() ; Blocks a list of specified keys for 1 second - #FUNKTION#
{
  blockKeys := 1 ; Block ON
  Sleep, 1000 ; After 1 second:
  blockKeys := 0 ; Block OFF
}

#if blockKeys ; Block all those keys:
Left::
Right::
return
#if
Problem 1: It's not working, Left/Right get sent anyway
Problem 2: If I try it with the blocking function, it does not even work when I press Alt+Tab on my keyboard

When I swipe too widely, this will be the result:
lfte
letf
letf
lfte

Instead of left

I don't want that it sends left/right, because it could disturb.

P.S. I also tried it this way, but that was even worse:

Code: Select all

!+Tab:: ; 3 fingers left-swipe
blockKeys := 1 ; Block ON
Send left
Sleep, 1000 ; After 1 second:
blockKeys := 0 ; Block OFF
;Block_Keys_Temporarily() ; Blocks a list of specified keys for 1 second - FUNKTION DOES NOT WORK
return
Thanks for any help and best regards!

Re: [Touchpad] Issue with blocking keys temporarily  Topic is solved

Posted: 23 Apr 2019, 17:11
by Scr1pter
I have upgraded my script and now it seems to be working almost perfectly.
Basically, I just specified that modifies can be allowed too.

Cheers!

Re: [Touchpad] Issue with blocking keys temporarily

Posted: 12 May 2020, 06:04
by pers3us
Hey, I recently bought a similar enough touchpad which works just like a keyboard and emits the same set of key presses from it. I could easily remap all this in my linux box using `udev`. Ever since moving to Windows, I have had this issue of not being able to use the trackpad because I mostly use it to swipe across workspaces.

After looking for a solution for ages, I came across this post which gives me some hope, but I am absolutely a huge noob when it comes to Autohotkey, or Win APIs that AHK uses. If you could be so kind and share the script you are using for intercepting the keypress events from the trackpad and remapping it, it would be super helpful, otherwise it will take lots and lots of effort to even reach to the point where I can use this trackpad.

Re: [Touchpad] Issue with blocking keys temporarily

Posted: 13 May 2020, 06:25
by Scr1pter
Hi and welcome,

I tried to make the code as easy as possible.
You can change the functions to your desired ones:

Code: Select all

;Cortana bzw. 3-fach Touch unterbinden
^+#F22:: ; Interner Windows-Befehl
return

!+Tab:: ; Alt+Shift+Tab bzw. Drei/3 Finger nach links
Send ^{PgUp} ; Strg+Bild nach oben
return

!Tab:: ; Alt+Tab bzw. 3 Finger nach rechts
Send ^{PgDn} ; Strg+Bild nach unten
return

#Tab:: ; Alt+Tab bzw. 3 Finger nach oben
Send {xbutton2} ; Touchpad
return

#d:: ; Win+Tab bzw. 3 Finger nach unten
Send {xbutton1} ; Touchpad
return

^+#F24:: ; Vierfach/4-fach Touch::
Send !{F4} ; Fenster schließen
return

!Capslock::Tab ; Neue Form von Alt+Tab
Consider that the classical Alt+Tab will probably not work, because the touchpad uses it (at least mine).
So I changed it to Alt+Capslock.

If the keybindings of your touchpad are not the same as for mine:
- run the ahk script
- double click on it (taskbar)
- press Ctrl+K (or click on View -> Key history)

Now you can perform touchpad actions like 3 fingers left, 3 fingers up etc and press F5 to see the actual key output.
However, since you already changed them in Linux, I guess you know them already.

Good luck and best regards!

Re: [Touchpad] Issue with blocking keys temporarily

Posted: 14 May 2020, 20:23
by pers3us
Thanks a ton, this is a huge help. :bravo:

I will port your AHK script over the weekend and update how it went :D .