Match both shift keys being pressed in AutoHotKey - autohotkey

One of my keyboards has a larger Shift key where my pipe/backslash key normally is. Is there a way to match Shift-Shift in AutoHotKey (i.e. both Shift keys pressed) so that I can still type pipes (|) in the way I would with my other keyboards? I have tried simply ++ but that seems to equate to Shift-+.

Thanks to #0x464e's comment, I was able to find the Virtual Key codes (VKs) for left shift and right shift by:
Adding ++::Send {U+007C} to my ahk script (right of the :: is irrelevant here, this is just so that Shift shows up in the key history)
Right click the script in the system tray, click Open, select Key History in the View tab.
Type Shift-+ a few times with each Shift key into a text editor.
Hit F5 in the Key History window and read off the values for Virtual Key for Left Shift and Right Shift (VKA0 and VKA1 respectively in my case).
Then I added the following rules to my ahk script to send a pipe whenever I held the Right Shift key and pressed the Left Shift key:
VKA1 & VKA0::Send {U+007C}

Related

Having problem with using Virtual keyboard code in Autohot Key

From the error I explained in my previous question It turns out I should use Virtual Keyboard code for the keys that I face error.
I want to use virtual code for hotkey +' (Which is pressing Shift and ' at the same time) and for the key ; (semi-column) (more specifically I want to use hotkey +' to click on a coordinate and the key ; to click on other coordinate) but I have problem writing the code. I found list of Virtual Keys here but unfortunately I don't know how to use them to write code.
Edit:
For pressing semi-column (;) I tried this key:
[vkBA27]::
Click,885,234
return
But It says it is invalid hotkey.
From the AutoHotkey documentation:
If your keyboard or mouse has a key not listed above, you might still be able to make it a hotkey by using the following steps:
Ensure that at least one script is running that is using the keyboard hook. You can tell if a script has the keyboard hook by opening its main window and selecting "View->Key history" from the menu bar.
Double-click that script's tray icon to open its main window.
Press one of the "mystery keys" on your keyboard.
Select the menu item "View->Key history"
Scroll down to the bottom of the page. Somewhere near the bottom are the key-down and key-up events for your key. NOTE: Some keys do not generate events and thus will not be visible here. If this is the case, you cannot directly make that particular key a hotkey because your keyboard driver or hardware handles it at a level too low for AutoHotkey to access. For possible solutions, see further below.
If your key is detectable, make a note of the 3-digit hexadecimal value in the second column of the list (e.g. 159).
To define this key as a hotkey, follow this example:
SC159:: ; Replace 159 with your key's value.
MsgBox, %A_ThisHotkey% was pressed.
return
Interpreting the example above, we know that the format for a hotkey declaration using a virtual key is:
SC<Hex code>::
<Your code here>
Return
I can only assume "SC" stands for "Scan Code". Using the steps above, I can see that the scan code (the documentation refers to it as the "3-digit hexadecimal value") for ; is 027, and the scan code for ' is 028. This allows me to construct your hotkey definitions like so:
SC027::
<Your code for ; here>
+SC028::
<Your code for SHIFT+' here>

Re-enable right-Ctrl when using Canadian Multilingual Standard keyboard for my AutoHotkey function?

I have an Autohotkey function that lets me switch between tabs with "Control + left/right" as well as closing tabs (Ctrl-down) and going into the search bar (Ctrl-up). It helps me save clicks and use the mouse less.
However, I use the Canadian Multilingual Standard keyboard to type accents (éèçà) in French for some of my classes and this keyboard DISABLES the right control key (the one right beside my keyboard buttons) which is the most convenient to use with my right hand only.
Here is a source documenting this: http://archives.miloush.net/michkap/archive/2013/04/08/10409187.html
Is there any way I can override this? I very rarely use the letter œ for because I can just use ALT + 0156 instead.
Here is the very simple code for my hotkey!
^Left::SendInput, ^{PGUP}
^Right::SendInput, ^{PGDN}
^Up::SendInput, !d
^Down::SendInput, ^w
Using SciTE4AutoHotkey tool, on my UK hardware keyboard right ctrl is detected as expected (RControl)
When I switch to French (Canada) Canadian Multilingual keyboard,
the right ctrl key is not found, also Virtual Key is different: DF
(SC means scan code and VK means virtual key)
so if you remap, it should solve the problem
~SC11D::RControl
After remapping: not found is replaced by RControl with each keypress.
Even if above remapping does not work for your case, it is a matter of finding which key corresponds to relevant scan code and then you can remap it.
Double click on your ahk script on the taskbar, and then
View > Key history and script info (Ctrl + K) by pressing key and refresh(F5) you can see respective keyboard scan codes.

Trying to recognize Fn + V on my keyboard

I hate that when I'm using my laptop on its own I often type FN+v when I mean to paste. So I decided to solve my problem with AHK. I installed a keyboard hook in my main script,and used that to extract the fn keys value, 163. My initial test worked, but adding the & to make it a modifier does not. What am I overlooking?
So this doesn't work
SC163 & v::
MsgBox, %A_ThisHotkey% was pressed.
return
but this did work
SC163::
MsgBox, %A_ThisHotkey% was pressed.
return
When you hit the FN key, it might be remapping the "v" to something else (like "Media_Play_Pause" button) in the keyboard driver. Therefore the key code wouldn't be SC163 & v but something like SC159.
The Special Keys section for mentions a method to get the Scan code:
Ensure that at least one script is running that is using the keyboard hook. You can tell if a script has the keyboard hook by opening its main window and selecting "View->Key history" from the menu bar.
Double-click that script's tray icon to open its main window.
Press one of the "mystery keys" on your keyboard.
Select the menu item "View->Key history"
Scroll down to the bottom of the page. Somewhere near the bottom are the key-down and key-up events for your key. NOTE: Some keys do not generate events and thus will not be visible here. If this is the case, you cannot directly make that particular key a hotkey because your keyboard driver or hardware handles it at a level too low for AutoHotkey to access. For possible solutions, see Special Keys.
If your key is detectable, make a note of the 3-digit hexadecimal value in the second column of the list (e.g. 159).

How to remap C-x prefix in emacs to a dedicated key?

Many emacs commands start with C-x or C-c. I found that I never use the right shift key. So I was thinking if it's possible to remap C-x to Shift. To open a file, I can do Shift-Ctrl-f instead of C-x C-f. Here I would prefer Shift-Ctrl-f than Shift Ctrl-f.
The link created by SSH between machines does not transmit the pressing and releasing of the shift key; only when another key is pressed in conjunction with Shift is a character transmitted, and the character — upper case H when Shift and “h” have been pressed, for example — looks the same to the remote machine whether left or right shift was used.
Therefore, to make right Shift visible, you will have to tell the terminal program to consider it to be a different key — or maybe even have to tell the Mac system settings that it is no longer Shift?
Is it possible to explain to your Mac that pressing Shift sends the character Control-X? That would kill both birds with one stone!

How to make both Alt keys work same way

I have some mappings that uses Alt key on Windows XP. While they work fine with
the left Alt, they doesn't with the right Alt key.
For example, the following mapping does nothing when I press right_Alt+b,
while it display a message box when left_Alt+b is pressed.
!b::MsgBox You pressed Alt+b.
I'd like to have both Alt keys to work the same way and trigger the mapping
above.
The mapping below does works with right Alt key, but doesn't works with left
Alt key:
<^>!b::MsgBox You pressed right Alt+b.
One workaround would be duplicate all mappings that contains the alt key, but
that would significantly increase the size of some scripts. Besides, I found
that in some cases it doesn't works. Further investigation showed that the
right alt key has a strange behavior. In a script containing only the
following mapping,
^!b::MsgBox You pressed Ctrl+Alt+b.
, the message box is displayed when right_Alt+b is pressed.
I've tried to map right Alt to left Alt,
<^>!::!
or
<^>!::Send {ALT}
, but it didn't solve the problem.
You mention that you tried to map the Right-Alt to Left-Alt, but not HOW you did this. Anyway, when I use this:
RAlt::LAlt
MsgBox You pressed Alt+b. is executed when I press Right-Alt+b AND Left-Alt+b.
Can you tell how you tried to map the two Alt keys?
I write this comment as an answer because of the better formatting options.
Here is the script I used in AutoHotKey_L (1.1.09.01), should work the same in regular AutoHotKey.:
RAlt::LAlt
<^>!b::MsgBox, A You pressed right Alt+b.
^!b::MsgBox, B You pressed Ctrl+Alt+b.
Test 1: pressed Ctrl+LAlt+b. Result: MsgBox B, normal behaviour
Test 2: pressed Ctrl+RAlt+b. Result: MsgBox B, expected due to the re-mapping
Commented the ;^!b::MsgBox, B... out and tested again.
Test 3: pressed Ctrl+RAlt+b. Result: Nothing, as expected
Commented ;RAlt::LAlt out and tested again:
Test 4: pressed Ctrl+RAlt+b. Result: MsgBox A, expected since no more re-mapping.
Last but not least. There is NO difference in behaviour if I press Ctrl+RAlt+b or RAlt+Ctrl+b. One more note: I always used the LEFT Ctrl key, not the RIGHT Ctrl key.
Are you NOT getting these results?
Or are you expecting different results when you make RAlt equal to LAlt?