Continuously pressing a hotkey is not working with a KVM (keyboard sharing software).

Put simple Tips and Tricks that are not entire Tutorials in this forum

Have you encounter this issue with a KVM before?

Yes.
0
No votes
Yes, but not this issue in particular.
0
No votes
No.
0
No votes
I don't use AHK with a KVM.
0
No votes
Others.
0
No votes
 
Total votes: 0
NorInd
Posts: 21
Joined: 03 May 2020, 04:23

Continuously pressing a hotkey is not working with a KVM (keyboard sharing software).

30 Dec 2020, 00:58

Continuously pressing a hotkey is not working with a KVM (keyboard sharing software, that share your keyboard and mouse among many computers).

Lets say you download "Mouse without Borders" in 2 computers, and you have AHK script running in computer B. same AHK script running in both computers (this is Not necessary)
The hotkey you are using, lets say ^t. Now you want to add an an $ to it, so $^t. (Or if you add #IfWinActive)
When you are editing a file in computer B, using keyboard A that connects to computer A.
You press down the hotkey, ^t, and not releasing it, the script will be executed only once, and then it ignores the ctrl, just keeps typing tttttttt
In order to make it work, you have to release ctrl, and press down ^t again.

detail::

When you have the following code

Code: Select all

#SingleInstance Force 
^t::
  SendInput, ABC
return
you press down ctrl, and then press down t. You will get ABCABCABCABCABC
Nothing is wrong.

---
When you add a $ to ^t

Code: Select all

#SingleInstance Force 
$^t::
  SendInput, ABC
return
When you are editing a file computer B, using keyboard B
you press down ctrl, and then press down t. You will get ABCABCABCABCABC
Nothing is wrong.


When you are editing a file computer B, using keyboard A
you press down ctrl, and then press down t. You will get ABCtttttttttttttt
This is the problem.


Just found, even if you add $ to another hotkey, it will cause problem too (Edit 20201230_0140)

Code: Select all

^t::
  SendInput, ABC
return

$^q::
return
To fix that, you may use following, instead of $^t whenever you need to call the ^t.

Code: Select all

    HotKey, ^t, Off
    SendInput, ^t
    HotKey, ^t, On
---
The same thing happens if you add an #IfWinActive instead

Code: Select all

#SingleInstance Force 
#IfWinActive, ahk_exe notepad++.exe
^t::
  SendInput, ABC
return
#IfWinActive

Code: Select all

#SingleInstance Force 
#If WinActive("ahk_exe notepad++.exe")
^t::
  SendInput, ABC
return
#If
To fix that you can use

Code: Select all

#SingleInstance Force 
^t::
  if WinActive("ahk_exe notepad++.exe") {
    SendInput, ABC
  }
return
---
The similar thing happens if you press down ctrl, then press t, without releasing crtl then press a (try to select) (, or any other key)
---
Also, if you have any $ hotkeys in any of the include files (either this script includes that file, or this script and that file are both included in a master file), the problem will occur. (Edit 20201230_021643 EST)
However, if you have #If in any of the include files, it seems fine.
AHK version: 1.1.33.02 (mainly tested in 1.1.31.01, just upgraded to 1.1.33.02, simply tested it and have same issue. (Edit 20201230_023353 EST))
Mouse without Borders version: 2.1.8.0105
computer A: Win10
computer B: Win7
keyboard A is connected to Computer A
keyboard B is connected to Computer B
I have tried "Input Director" instead of "Mouse without Borders", same issue happened as I remember.
I don't think this is an AHK bug or "Mouse without Borders" 's bug. The just don't work with each other sometimes (I think).
I have seen some posts about sometimes AHK is not working with a KVM. So I am aware that this may not be able to be fixed.
I am putting this here just to help out those people who encounter this issue, and I think this is a good place to post this.
In short, try not to use $ or #IfWinActive, if you want to avoid this problem.
If you have a master .ahk file with lot of include files (including this one you are using), and you don't want to change all the files to avoid this(I don't recommend you do that, cuz it might get fixed one day),
then only change this script that you are using and run it separately. (It does mess up a lot of things, but this is the only way works I know so far.) (Edit 20201230_021643 EST)
---
Having Win Key eg: #d will cause problem too (20210119_161036 EST)

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 3 guests