Produce typing lag on purpose - winapi

I have to use USB barcode scanner in application running on remote desktop. This scanner is being recognised by Windows as keyboard. When I try to scan barcode however, every 3th or 4th character is being changed to another one. When I type numbers by hand, they are being correctly written. The question is: is there any way to programmatically produce "lag" on keyboard globally? I would like to create for example a half second gap between keyboard input events and a result on the screen. Some time ago I worked with Windows hooks, and I was able to change keyboard input globally, but I remember I had problems with delaying it. Is there any other way?

you can make an autohotkey script to listen to a keyboard input, wait and then press the same keyboard button.
once you have intalled AHK(autohotkey) , you can do a AHK script whit the intructions that are in the ahk documentation.
Right-Click on your desktop.
Find "New" in the menu.
Click "AutoHotkey Script" inside the "New" menu.
Give the script a new name. Note: It must end with a .ahk extension. Ex. MyScript.ahk
Find the newly created file on your desktop and Right-Click it.
Click "Edit Script".
A window should have popped up, probably Notepad. If so, SUCCESS!
i::
sleep, 500 ;
Send, i
Return
(you can change the "i" for other keyboard keys).
a function would reduce the amount of code that you use, but i don't know how to do it in a AHK script

Related

ahk send alternative in bash script

I want to achieve in a bash script, that when I press any key (e.g. F5) and then type any word (e.g. "hello world"), regardless of whether I positioned in the terminal, or text-editor or browser...
While I was using Windows, then I used Autohotkey for that.
How could I achieve that with bash script in Linux?
While as #Socowi mentioned, you will likely not be able to do this with bash alone, you can use AutoHotkey Linux alternatives like AutoKey for this.
For your specific question, see this guide for setting up and configuring AutoKey on Linux.
More specifically, scroll down to the section labeled "Inserting repetitive text using a hotkey" for how to configure a text-typing hotkey:
Inserting repetitive text using a hotkey
Abbreviations is only one way of inserting text using AutoKey. If you
prefer, you can also insert text using a keyboard shortcut, which
doesn't require typing an abbreviation.
To insert some text that you need to type frequently using a keyboard
shortcut, click the Set button next to Hotkey, then click Press to Set
in the newly opened window, and press the key combination you want to
use for this phrase:
Make sure you use a hotkey that's not already in use or else it may
not work / it will interfere with the already set hotkey. To try this
out, set it to something like Ctrl + F1 (which shouldn't be set by the
system at least).
Remember to click the Save button in the AutoKey toolbar after setting
the phrase hotkey, or else the changes won't have any effect. Now try
it out: focus a text editor, some text field in a web form, etc., and
press the hotkey you've set in AutoKey - the Testing AutoKey text
expansion on Linux phrase should be automatically inserted as soon as
you press the keyboard shortcut.

Hotkey for this application?

I'm putting together an AutoIt script to automate notepad and this software called Ecsow Dialer. I'm stuck on one thing, that's trying to find the hot key to select the text box so it's ready to type text in. Manually you'd just press enter and it will open, but sometimes pressing enter will open up the menu along the top of the window, i think it all depends on where the cursor is in the window. I took a couple of screen shots, here they are below:
The red part is where i need it to select, when you press enter, it opens it up ready for text input:
and here is what happens when you press enter sometimes, sometimes it opens the menu above, this is why i need a hot-key instead of just having autoit press enter.
If anyone can help me out, i'd really appreciate it. Thanks.
Have you taken a look at the _GUICtrlListView* functions (they are user defined functions, meaning they can interact with outside programs as well in many cases)?
I'm not sure that's a standard window, if the AutoItInfo.exe tool doesn't provide a classid/classnamenn you are probably dealing with a non-windows-standard GUI.
If that's the case, try out IUIAutomation, they've done a good job with their tool helping others automate past AutoIt's standard functions.

a basic keystroke map

I downloaded AutoHotKey today and read the tutorial. What I want to do is have an F2 key do a shift-ctrl-S in one application. I cannot figure out how to do that by reading the tutorial. How can I do it?
Firstly, install autohotkey on your system.
Once installed, create a text file and save it as .ahk (rather than .txt).
Within the file, at the end, type the following code:
F2::Send +^s
Save the file then double click it to run the program.
This will change F2 to your shift-control-s in ALL applications.
To make it application-specific, when running, right click on the icon in the taskbar and choose "Windows Spy". Click into the application you want to use the F2 shortcut in and make a note of the line just below >>>>>>>>>>( Window Title & Class )<<<<<<<<<<<
Now, change your script to this:
#IfWinActive INSERTWindowsSpyWindowTitleHERE
F2::Send +^s
#IfWinActive
Obviously making sure to change INSERTWindowsSpyWindowTitleHERE to what you got from windows spy.
Save and run your script. Autohotkey will now only make F2 do that shortcut when the window (found via Windows spy) is active. (The last #IfWinActive is used to "reset" checking for that window in code below where this is typed - useful if you're going to type more autohotkey code in the future)

Can you remap keys of a specific keyboard?

I've got two keyboards attached to my computer. A normal full-size keyboard and a numeric keypad. I want to "remap" the keys on the numeric keypad, but leave the full keyboard alone. So, when the user presses "5" on the keypad it would get remapped to the "Media Play" key, but if the same "5" was pressed on the keypad of the full keyboard, I'd get a "5". In essence, I want to turn that seperate numeric keypad into a media control device.
Unfortunately I'm not sure how to make this work. There is a "Raw Input" feature of Windows which allows to distinguish between keyboards, but that only allows to read the keys - not remap them. There are keyboard hooks (low level and high level) which can remap the keystrokes, but they don't distinguish between keyboards.
Can I make a combination of the two methods work? For that I'd have to be sure that the raw input message is processed before the keyboard hook kicks in. Is that so?
Also, I've read that Windows for some reason does not allow to use Raw Input and Keyboard Hooks in the same process. I could work around that by making 2 different processes, but that becomes more fragile because of communication latency (keyboard hooks have very limited time in which they must complete their work).
Is this doable at all?
In the end it turned out I needed a custom keyboard driver to accomplish this. Fortunately I found one ready for taking - Interception. The app is ready and works perfectly. :)
I wanted to expand on the answer by Vilx as I've revisited this post several times, and I've only just managed to remap my second keyboard so the keys act uniquely. This is done using Interception and Intercept together, and it's the only working solution that I've managed to get working so far.
I'm also looking into using a raspberry pi to remap a second keyboard. Although early days, I think it it's achievable: Plug keyboard into Pi, plug Pi into PC and write script to turn input keycodes into customized output commands / keycodes. Will update when I have tested.
My working Intercept solution is completely based on a Github tutorial by TaranVH which details the process the best so far. I've copied his solution below with some amends of my own.
DOWNLOADING INTERCEPTION:
Navigate to this page: https://github.com/oblitum/Interception
Click on "download the latest release."
Click on Interception.zip to download it.
Unzip the file to a folder on your computer - I recommend using a folder location that won't ever move. I put my Interception folder into C:\Program Files\ and I'll be using this location in my examples.
INSTALLING INTERCEPTION:
Open a terminal as administrator and type cd "C:\Program Files\Interception\command line installer"
Hit Enter
Now, type in the following line of text exactly as shown:
install-interception.exe /install
Hit Enter
Once the program installs sucessfully, you still must restart your computer in order to complete the installation.
(If you ever want to UNinstall interception, watch this): https://www.youtube.com/watch?v=Hn18vv--sFY
INSTALLING INTERCEPT - (This is different from intercepTION!)
Download Kamaz's intercept.exe zip from one of these locations:
http://octopup.org/img/code/interception/intercept.zip
https://github.com/TaranVH/2nd-keyboard/blob/master/Intercept/intercept.exe
Unzip it if it's a .zip file and locate intercept.exe
To keep these files all in one place, I moved intercept.exe into C:\Program Files\Interception\
Reboot your system.
SETTING UP INTERCEPT
Plug in your second keyboard and ensure that it is working normally.
Go to where you saved intercept.exe and double click to open.
Intercept will open as a terminal, and from there you should have basic instructions to start remapping your keyboard.
Type a to add a key.
On the SECONDARY keyboard, press the Q key once. (this is the key that you are remapping)
You will be prompted with Enter combo for this trigger, end with ESC.
Carefully execute the following keystrokes (it doesn't matter which keyboard): Win + E (That is: hold down the windows key while pressing the letter E. I've found you need to do this quickly and accurately, if you hold down too long, extra keypresses are added)
When I did it, this was shown in the terminal: [Left Windows]↓ [E]↓ [E]↑ [Left Windows]↑
Press Esc and you will be prompted to label the script
I labelled mine Q->WinE so I knew what it was doing.
Press Enter to accept the label
Press S to save the filter, or C to cancel if you made a mistake.
Add more filters or close the terminal.
USING INTERCEPT
Now you've set up a custom key command, you need to apply the filter to use it.
Open up intercept.exe
Press Y to apply the filters, you will get confirmation that the filters have been activated.
Now, when you press Q on your second keyboard, Intercept will change the command to Win+E which will open File Explorer.
Caveat:
Please read TaranVH githubs page on this https://github.com/TaranVH/2nd-keyboard/tree/master/Intercept as it provides some further details and troubleshooting.
Please take care to follow the instructions very exactly as there's very little error handling in this process
In this article http://vlaurie.com/computers2/Articles/remap-keyboard.htm is explained how to remap keys of a keyboard. Hope that helps.

emacs control D key binding overridden

Any solutions out there for dealing with google script code-editor turning "forward delete" into a "kill line" binding? I'm used to the hidden cocoa/emacs derived navigation keys. Google decided to mess with control-d.
Clarifications:
This occurs when using the code editor. (edit-view?)
I would rather stop the google behavior than cope with it.
To understand more how fluid the control-key navigation can be
(and therefore how annoying when missing), try this...
set caps-lock to be the control key
open a cocoa browser like Safari and
start a script at https://script.google.com/
switch briefly to address bar
hit ctrl+a (goes to start of line)
hit ctrl+d (characters get deleted 1 at a time)
hit escape
switch to script area and try same thing (whole lines get munched!)
If you mean while you're working on your program in that editor, press the forward-delete key. On Apple's laptops and wireless keyboard, it's fn-delete (where by “delete”, I mean the backward delete, the key that is a.k.a. “backspace”).
You could try KeyRemap4Macbook.
Today I noticed that this problem no longer exists. So when editing a script file in the macro editor, emacs shortcuts WORK as expected. I cannot tell if they simply removed a bug or override, or actually patched it to work.

Resources