AutoIt 3 Inputing keyboard keys by GUI - user-interface

How can I create a GUI element like the one of type "Input" that would register current keyboard keystroke, but I'm not talking about any letter or number, but rather special buttons like CTRL, TAB or Enter?

As far as i know there is no special GUI element handling that.
There are some "workarounds" like
When something gets written check if CTRL (or anything else) is pressed
_IsPressed()
Catch if you press CTRL with Hotkey and then make a Funktion to insert it into the Input
HotKeySet({CTRL},_insertCTRL);
Does one of these work for you?

Related

Hotkey wont work if its modifier is also being used as part of the trigger

This issue seems to only occur in this one program.
I have the hotkey Shift+a set in this programs hotkey editor dialog, I want to trigger it in AHK using Rshift and w;
RShift & w::
SendInput, +{a}
Return
For the life of me, it will not work. I press Rshift and w and nothing happens at all. Triggering the hotkey manually by pressing shift and a works just fine.
The strange thing is the following works:
LCtrl & w::
SendInput, +{a}
Return
So does this:
w::
SendInput, +{a}
Return
I also tried to send Rshift back up before triggering the hotkey, no luck:
RShift & w::
SendInput, {RShift up}
SendInput, +{a}
Return
Is there a rule that says you cant use the same modifier as the target hotkey in the trigger that I missed?
please dont suggest that I use other modifier keys, shift +[key] is all that I have left.
Any help would be greatly appreciated!
Firstly, you shouldn't use a custom hotkey combination when a modifier exists (unless you have a good reason to):
For standard modifier keys, normal hotkeys typically work as well or better than "custom" combinations. For example, <+s:: is recommended over LShift & s::.
And secondly you shouldn't escape keys in a Send(docs) command that don't need escaping:
Enclosing a plain ASCII letter (a-z or A-Z) in braces forces it to be sent as the corresponding virtual keycode, even if the character does not exist on the current keyboard layout. In other words, Send a produces the letter "a" while Send {a} may or may not produce "a", depending on the keyboard layout. For details, see the remarks below.
And then about the problem itself:
I of course can't know if this will work, but I'd simply try the following:
>+w::a
This would work because because the remapping syntax actually uses the blind sendmode.
Alternatively, you could, of course, just manually use the blind sendmode:
>+w::SendInput, {Blind}a

Replace any keyboard character(s) with keyboard shortcut or different keystroke

For a project using a barcode scanner I need to know if it is possible to replace a special character like
!
"
ยง
$
%
=
with different keyboard strokes like
arrow down or arrow up or even shortcuts like
ctrl+a or ctrl+v?
Would be also possible if a specific series of characters resulted in a keystroke/keyboardshortcut,
for instance this text InsertArrowLeftHere would result in this keypress arrow left
Is there any way to make something like this work?
A bar-code scanner (unless is used with special hardware in-between) just reads the data, and sends keystrokes to the computer as keyboard interrupts. How the bar-code "string" is interpreted depends on software that, at that moment, has the focus. If you open a Notepad and read something with the barcode scanner, the number will be printed in notepad. In many cases no software comes with the scanner because there is no need for that.
But your software (the program that receives the data from the scanner) can catch anything typed in the textbox (or other control that has the focus, for example the whole form can catch the keystrokes). Maybe you can also identify where the keystrokes come from, (means: from which keyboard-input device: keyboard1, keyboard2, barcodescanner etc.) and act accordingly (if from keyboard1 or keyboard2 do nothing, if from barcodescanner then do this).

How does TranslateAccelerator know about CTRL or SHIFT modifier?

I'm working in a program that uses Accelerator keys for user-defined hot keys, and every thing works fine. The user can set hotkeys using SHIFT, CTRL, or ALT. I know that using ALT generates a WM_SYSKEYDOWN rather than WM_KEYDOWN, so it's pretty obvious when ALT is held down.
TranslateAccelerator only takes a window handle, the accel table handle and a single KEYDOWN message. So, my question is, if the user presses CTRL+T, how does TranslateAccelerator know the CTRL key was also pressed?
I know that the CTRL generates a separate KEYDOWN command, and I specifically filtered those out (do not pass to TranslateAccelerator) to test a theory, but TranslateAccelerator is still working.

Press keys then type message in Textbox?

I was wondering if Visual Basic could emulate the pressing of keys.
I was thinking of a program that did this:
When I press a button (Button1) it would start a timer (Timer1), then press the V key on the keyboard and then type what was entered in a textbox (Textbox1), then press the Enter key. After doing that, repeating that action a second or two later, but saying what is in (Textbox2).
Could this be possible? If yes, please respond.
This will tell you how:
http://msdn.microsoft.com/en-us/library/ms171548(v=vs.80).aspx?cs-save-lang=1&cs-lang=vb
And use:
http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx?cs-save-lang=1&cs-lang=vb
For special keys.

Binding to Ctrl-Shift in AutoHotKey

I want to use AutoHotKey to bind a command to Ctrl+Shift, in the same way that Windows detects it in order to change text direction from right-to-left to left-to-right. That is: I want it to be invoked when Ctrl+Shift is let go, and only if no keys were pressed between pressing Ctrl+Shift and letting them go.
I bound a hotkey on ^~ Shift Up and I expected it to behave the same way as when Windows binds to it for changing the text direction. But, I found that it gets invoked even in cases where I don't want it to be invoked.
For example, I could be selecting a few words by pressing Ctrl and Shift, and then using the arrow keys. Then I let go of Ctrl and Shift and the hotkey gets invoked. I don't want this. I want a hotkey that gets invoked only if I held nothing else then Ctrl and Shift. If I use any other keys, I want the hotkey not to be invoked.
Is there a way to do this with AHK?
#InstallKeybdHook
Hotkey, ^LShift Up, ControlShiftUp
Return
ControlShiftUp:
if (A_PriorKey != "LShift") ; [v1.1.01+]
return
; do something
msgbox hi
Return

Resources