How to hold Alphanumeric keys from keyboard using TestStack.White Framework - ui-automation

I'm familiar with the command Keyboard.Instance.HoldKey(KeyboardInput.SpecialKeys.CONTROL); as well as Keyboard.Instance.Enter("Z");, but I don't seem to be able to find a way to hold down alphanumeric keys using this. Am I missing something? HoldKey seems to only take SpecialKeys.
I'm wanting to hold down both CTRL and Z at the same time. I don't want to merely press the Z key.

This so far as I can see is not possible with White.
Instead, you could use Input Simulator to do this, which has a SimulateKeyDown and SimulateKeyUp method available for every key.

Related

How to remap Tab key to two dots/period key presses

I want to map two dot/period key presses to Tab key in AutoHotkey script. I tried to map similarly as its shown for remapping semicolon key - on AutoHotkey forums, but it doesn't work. I tried following:
1. `..`::Tab
2. ..::Tab
AutoHotkey gives an error
.
I tried searching on AutoHotkey Remap docs, but couldn't figure it out. The period key is the one with the greater than mark and not the number keypad period key. See this: Dot/period key
Addition info/context in response to reply by user 0x464e:
Basically, I am trying to expand Emmet style abbreviations in devtools style sub-panel since the chrome devtools team wont implement it.
I am not a fast typist, so it's a pain to type complete property names. For example, if I want to type margin-top, (see the image), Chrome autocomplete brings up margin, margin-block margin-block-end etc.
Now, for margin-top, you need to at least type margin-t to get the autocomplete to show that property.
This is the case for many very common CSS properties like margins, paddings, etc., so autocomplete isn't great.
On the other hand, if I just type mt and have Autohotkey expand to margin-top, it's much much faster, saves me much time and keeps me sane.
Basically, I have setup some hotstring in .ahk script and they work too.
However, if I press mt followed by a Tab key press, Chrome's autocomplete takes over and hotstring fails, (try once to see the problem). Instead, currently I press spacebar, or . (period) to trigger the hotstring. It works, but the problem is it leaves a space or a dot with the expanded text. [see this].
So, that's the actual reason I wanted a double period key trigger to replace Tab.
It would be great if the hotstring trigger would work with a double period key, but doesn't leave the trigger character itself and then have send Tab so as to jump to the value input of the just expanded property.
You're not really looking for a traditional remap, which is why you didn't find it from the documentation.
Remapping is just simply remapping one key to another, but you're not trying to do that. You're trying to make some action do another action.
Anyway, what you're asking is doable, but there's loads of different ways it can be achieved with difficulties varying from simple to extremely advanced & complicated.
You'll need to specify things more clearly before this can be answered properly.
Biggest questions that pop into my head right away are at least:
Should this work everywhere, or just in text input fields?
How should the original functionality of . be preserved, if at all.
(What should happen after the initial . keypress?)
Should there be some timeout between the keypresses?
Etc, this is just what I could think of right away, but surely there's more.
Anyway, for now I can give a simple implementation with a hotstring:
:*?:..::{Tab}
So this is a hotstring with the * and ? options.
I'm guessing these would probably be pretty good options for this.
So what this does, is it presses backspace twice and sends a Tab if you type ...
This should be fine for text editors, but it leaves much to be desired (the points I listed above aren't considered since I can't know what you're looking for. This is just what a default simple hotstring can offer).
Looks to me like you don't actually want the additional mapping of .. to Tab, but instead just want to update your existing hotstrings to activate immediately (without waiting for an EndChar) when the hotstring is followed by ..
Normally, you might look to the Ending Characters option to create this functionality, but since you want multiple characters to trigger this, we need to look to other options.
I will be using the example of ::mt::margin-top for my sample implementation. Extend any changes I make to these to the rest of your hotstrings in the script you screenshotted.
Here are the changes I am making to this example:
Add your .. to the end of each of your hotstrings triggers. For example ::mt::margin-top becomes ::mt..::margin-top. However, at this present, this still requires some sort of ending character to be pressed in order to proc. Let's fix that in the next step
Add the Asterisk Modifier to the hotstring. From the docs:
* (asterisk): An ending character (e.g. Space, ., or Enter) is not required to trigger the hotstring.
Final code for ::mt::margin-top example:
:*:mt..::margin-top
And extend this * insertion and .. appendation to each of your hotstrings.
Hope this helped! Lmk if you need any more help or changes.

Show multiple keys inside one <kbd> tag

I have a key sequence I want to display in github. Let's just say it's the Konami code.
So, I want the result to be ↑↑↓↓←→←→BA.
The way I've done this is by using some extremely long code:
<kbd>↑</kbd><kbd>↑</kbd><kbd>↓</kbd><kbd>↓</kbd><kbd>←</kbd><kbd>→</kbd><kbd>←</kbd><kbd>→</kbd><kbd>B</kbd><kbd>A</kbd>
Is there another way to do this without tons of <kbd>'s and </kbd>'s?
Not really: as shown here, using only one kbd would only include everything, without any separation:
Ctrl + Shift + L
So unless you can add separators inside one kbd sequence, you would need all those kbds you mentioned in your question.

AutoHotKey replace dollar sign with percent

I'm trying to use Auto Hot Key to replace $ with %. I also am replacing & with $.
My problem is that when I press the & key (now remapped to $), it thinks I'm actually pressing $, so it triggers the code and types %.
This is the code:
~::#
#::?
%::^
^::~
$::Sendraw `%
&::$
?::+
/::_
+::&
=::/
_::=
My keyboard layout doesn't have these keys as actual keys, so I can't really test this for you, but I can still tell you what will likely fix the problem, and then an other version which will definitely fix the problem.
So the thing that will likely fix the problem is using the $ modifier (docs). You should only need it for the $::Sendraw `% hotkey, because the other hotkeys use the remapping syntax and will automatically do what adding the $ does.
So your script would look like this:
~::#
#::?
%::^
^::~
$$::SendInput, `%
&::$
?::+
/::_
+::&
=::/
_::=
(and I also switched to using SendInput because SendRaw really made no sense there)
That should work if all the hotkeys are as actual keys on your keyboard layout (as opposed to being accessible with modifier key combos (e.g. CTRL + ALT + 2), like they are on my keyboard layout).
Why it wouldn't work when having to mess with modifiers keys is a bit more complicated. I can explain it in detail if you're actually interested, but for now I'll just say it's because of the blind send mode the remapping syntax uses.
So, not using the remapping syntax like this should ensure it'll work on any keyboard layout no matter what:
*~::SendInput, #
*#::SendInput, ?
*%::SendInput, {^}
*^::SendInput, ~
*$::SendInput, `%
*&::SendInput, $
*?::SendInput, {+}
*/::SendInput, _
*+::SendInput, &
*=::SendInput, /
*_::SendInput, =
Here we're using the * (docs) modifier to deal with having to hold modifier keys to access hotkeys. And we're not using $ modifier, because using * already does what $ does. So having them both would be redundant.
+4::SendInput, `%
This should work fine.

Two keys pressed simultaneously in autohotkey

I'm wiring innards of a keyboard to make a board of buttons to use as macros for photoshop among other applications. The insert key and a letter key is wired to a single tactile switch. This is done with each letter switch.
I can use Ins & a:: but because I can't predict which will be "read" first, I have to have the reverse as well. The problem is that when I use a & Ins:: the 'a' key doesn't work properly.
Is there a way to use the 'up' and 'down' function with a letter key? Maybe that will work? Otherwise if there is a way to determine if two keys were pressed within a certain time between each other, I believe that would work.
Try these sentences:
Ins & a::SendRaw The Ins&a thing...
a & Ins::Send, The a&Ins thing...
a::SendRaw, a
This fixes your problem with the a key (although now the normal a appears with some delay).

xmonad and Emacs : problem with 'mod' key

I started using xmonad as my window manager a couple of weeks ago. I love it. Its great. But since then I have had to use 'ESC' key a lot when I am in emacs and want to press the 'ALT' key. This is because 'ALT' key is used by xmonad as the 'mod' key.
Is there a way to assign the emacs mod key to anything other than the 'ALT' key like assigning it to the 'windows' key.
Any help would be higly appreciated.
Thanks,
Vimal
P.S. this is the keyboard I am using
http://tinyurl.com/c4955o
Actually, it would be much easier to assign Xmonad's mod key to be the "Windows" (super) key. It's what I do!
Here's how:
Xmonad FAQ
Bindings starting with Alt modifier often conflict with applications, so the first modification I always make to XMonad configuration is to change the modifier to the Super (Windows) key.
modMask = mod4Mask
I like the idea that everything associated with window management is assigned to a modifier used just for this purpose, this makes it conceptually isolated and easier to remember.
More details can be found in a great tutorial on configuring XMonad.
You can configure xmonad to use Emacsey key sequences instead of the default Mod-X or Mod-Shift-X. Details are here.
emacs commands are often show M-/ which means hold the Meta key, and press forward slash. You need to use xkeycaps to figure out which key on your keyboard is assigned the META modifier, and that's the key you want to use for META key chords.
Also, xkeycaps lets you assign the META modifier to whatever key you like, so if you don't like the way it's setup, you can fix it.
You will probably want to read the xkeycaps man page thoroughly, or post more questions here, if you set META to some places, GNOME won't pick up the META key correctly, but I've forgotten exactly what problems I had.