So I'm currently using SendInput as a way of doing keyboard emulation. My problem is that to switch on the emulation the user has to hold down the CTRL button (client's specification :-( ).
I used GetAsyncKeyState(VK_CONTROL) to get the state of the CTRL key, so I can work out the switch part. My problem now is that since the physical CTRL button is pressed, it is not ignored when the SendInput function is used. So instead of emulating say the c button it emulates CTRL + c.
I'd like to know if there is a way for SendInput to ignore physical keyboard presses.
Related
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.
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?
I've made simple remapping of CapsLock to Control with autohotkey:
Capslock::Control ; make Caps Lock the control button
This works OK, but in Emacs if I need to do a key sequence like Ctrl-x Ctrl-f while holding the CapsLock key continuously the whole time what gets registered is Ctrl-x f. In order to get the correct sequence I now have to release CapsLock between the keystrokes like Ctrl-x <release> Ctrl-f which is very inconvenient.
Is there a way to do the rebinding so that holding CapsLock down will work exactly as holding down the Control button?
I've also tried the following snippet without success:
#IfWinActive ahk_class Emacs
{
CapsLock::
Sendinput {Ctrl Down}
KeyWait, CapsLock
Sendinput {Ctrl Up}
return
}
Using Send or Sendplay in the above instead of Sendinput also doesn't solve my problem.
My system:
Windows 7 32bit
AHK v1.1.13.01
Emacs 24.3
Thank you!
I'm not sure why it's not working correctly for you. I added your remapping into my existing script and it seems to work fine. Can you post more of what you have? I have the following commands at the top of mine but I wouldn't think they should affect your problem.
#Persistent
#SingleInstance, Force
The commands GetKeystate
and SetKeyDelay might be helpful.
This is what I use and it works:
*Capslock::LCtrl
The asterisk is documented in the help under Keyboard Control > Hotkeys and Hotstrings:
Wildcard: Fire the hotkey even if extra modifiers are being held down. This is often used in conjunction with remapping keys or buttons. For example:
*#c::Run Calc.exe ; Win+C, Shift+Win+C, Ctrl+Win+C, etc. will all trigger this hotkey.
*ScrollLock::Run Notepad ; Pressing Scrolllock will trigger this hotkey even when modifer key(s) are down.
This symbol is ignored on Windows 95/98/ME.
I actually have this one too, +Caps Lock, if I really want caps lock:
<#Capslock::Capslock
Try this;
SetCapsLockState, AlwaysOff
CapsLock:: SendInput, {LCtrl Down}
Capslock Up:: SendInput, {LCtrl Up}
Our MFC-based Windows application has functionality that depends on the state of the shift key. Shift exposes power-user menu commands and shift-dragging has different behavior than normal dragging. I am exploring our options in supporting Windows 8 tablets, and it seems that there is no straightforward way to detect the state of the Windows 8 soft keypad shift key.
Using GetAsyncKeyState(VK_SHIFT) (our current method) doesn't detect this key.
Experimenting with examining all incoming keyboard messages, I find:
A single isolated tap of the shift key produces no keyboard event
A double tap of the shift key produces a caps lock key event, indistinguishable from a normal caps lock key event
A single tap of the shift key followed by another keystroke (eg. the 'q' key) produces a shift key event, the keystroke, and a shift key (up?) event.
Are there any other ways I could try to detect the state of the soft keyboard shift key? Has anyone else had success detecting the state of this keypad on Windows 8 tablet soft keyboards.
The external keyboards that you plug into these devices all have normal behaving shift keys. The problem is specific to the soft keypad.
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