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

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.

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>

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 can I remove the Numpad Slash keyboard shortcut from MS Word 2013 Outline View

I work a lot in Microsoft Word's Outline view, because I like being able to expand/collapse subtrees of a tree of bulleted lists, and quickly move bullets around with Ctrl-Alt-arrow keys.
I'm generally impressed with the customisability of MS Office's keyboard shortcuts. However, there are some keyboard shortcuts that apply to Outlining mode that don't appear to be modifiable in the usual way. In particular, the Numeric Keypad Slash key ( / ) is bound to the rather useless function "toggle formatting", which hides colouration of my text. MS ref, specific ref
I'd like to be able to enter numeric sequences on the numeric keypad that include slashes. In other words, I'd like to be able to remove this keybinding which is no use to me, and instead bind Numeric Keypad Slash to just enter a literal slash character.
But I can't find a way to do this. The normal Customise Keyboard Shortcuts view doesn't help: I can assign new keyboard shortcuts to the OutlineShowFormat effect, but it doesn't list Numeric Keypad Slash as an already-existing keyboard shortcut so I can't remove it.
Is there any way to remove this keyboard shortcut, or override it so that pressing the slash key on my keypad will just enter a slash?
Well, in the absence of any other answers (this question earned me the Tumbleweed badge!), I found a workaround: Hold Shift while typing Numpad Slash to get a literal slash in Outline View rather than toggling formatting. Not great, but it will probably be easier than moving my hand over to the main keyboard slash key.

autohotkey does not exist in current keyboard layout - solution examples

I have written a python script for my co-workers, and then created an autohotkey script to run it every time someone presses Ctrl+LShift+Y. Looks something like this:
^+y::Run helper.py
The python script is fine, but the ahk script doesn't work on all the computers. Sometimes it works fine, and sometimes you get this error:
^+y does not exist in current keyboard layout
Now, searching the web this seems to be a problem with multi-language keyboards (we're using both Hebrew and English), because different languages means a different layouts (I guess?). I also found someone explaining that to solve this you need to use scan codes instead of the usual ^ and + and so on (I'd link to it but I cannot seem to find it now).
This all vaguely makes sense to me on a theoretical level, but when I want to realize it with actual code, I don't really know what to do. To me it seems as if this topic is hardly discussed (with the few exceptions being lacking in examples or hard to understand), so I'd love an answer that would include the following:
some simple way of determining the scan code for a key. This should preferably be a pythonic solution (and just out of curiosity, I'd love to know how to do this with linux as well). This is probably the easier part (but I think is an inherent part of a complete answer).
This is the important part: examples of how you implement that scan code in an autohotkey script, including edge-cases (if there are any).
Question 1
As you want to use the key with autohotkey, it makes sense to use autohotkey detect the key in the first place. Obviously this method works only on windows where autohotkey is running.
Write a Autohotkey script with this line and run it.
#InstallKeybdHook
Press the key you want to examine.
Open the script menu by right clicking the icon of the script in the right lower corner of your screen.
Select OPEN, then from the Menu "View / Key history and script info"
There is a line for each keypress.
First column is the VK (Virtual key) code, next is the scancode.
For example for CAPSLOCK the VK is 14 and the Scancode 03a
Question 2:
#InstallKeybdHook
VK14::
msgbox, you pressed capslock!
return
OR
#InstallKeybdHook
SC03a::
msgbox, you pressed capslock!
return
both work.
Note that you can combine two keys into a hotkey by combining them with & (but not 3)
#InstallKeybdHook
RShift & SC03a::
msgbox, you pressed Rshift capslock!
return
You can modify a Scancode with + and ^
#InstallKeybdHook
^+SC02C::
msgbox, you pressed Ctrl Shift and Y(maybe)!
return
Further info about this is on the page "List of Keys, Mouse Buttons, and Joystick Controls" of the autohotkey help file that comes with the default installation.

Best keyboards for emacs? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
For emacs users out there, what are your recommended keyboards?
Bonus points for keyboards that:
Have no capslock key. Instead, a control key in that position.
Alt keys that are closer to the centre, and easier to use with meta key combos. I find alt keys too far to the left to be a bit awkward to hit with my thumb in some key combos.
Help ergonomically with emacs in other ways.
I'm not a huge fan of model M style high and clacky keys. I instead prefer laptop style flat keys; however, I'm not disqualifying either category.
A couple of interesting keyboards I'm curious if people have tried with emacs - Kinesis
Semi-conclusion:
I ended up getting an MS natural 4k, which I like a lot overall as the alt keys on both sides are easy to hit with your thumbs. This is useful for ergoemacs-mode.
However, one flaw I see with this keyboard is that the number keys are shifted to the left, so that 6 is on the wrong side of the keyboard. Aside from that 0 is left shifted enough that I accidentally hit - when I meant to hit 0 with my pinky.
Due to this flaw, I'm leaving this question open in case someone can come up with the perfect emacs keyboard.
Richard Stallman (which I'm sure you all know is the author of Emacs, and probably the biggest Emacs user) was seen using a HHKB (Happy Hacking Keyboard) (source)
Here's the layout of the HHKB Pro:
No Caps Lock.
Control key conveniently placed for Emacs users.
They're quite pricey though...
I used the Kinesis keyboard with Emacs for many years and loved it. Having Alt, Ctrl, Del, and Backspace all easily reachable with the thumbs is very, very nice. The location of the arrow keys is also quite convenient.
I have a model M "Das Keyboard" Ultimate - no letters on it, highly ergonomical and very beneficial to my productivity. I used to share your taste for low profile laptop style keyboards, but ever since I got the Das Keyboard I cannot imagine using another keyboard. It's as noisy and heavy as they get, but it's benefits cannot be described by mere words - one has to type on it for himself... Since you can easily remap CAPS to control(which I've done) I don't think that you should consider something like this in a keyboard a particular advantage. Also - if you get attached to using a keyboard with a highly customized key layout you'll be very impaired when you have to do some work from time to time on a regular keyboard...
I use MS Natural 4K, with some keybindings altered to cope with the different geometry.
In particular, I swapped c-p/n with a-p/n.
My hand and keyboard geometry are such that Alt lies directly under my thumb and I can trivially scroll up and down with thumb of left and and first/third finger of the right hand.
I do not have pinky pain.
Also, I use emacs & MS 4K both at work and at home, and I am pretty much 100% happy with it and plan to continue it.
I recently got a ThinkPad USB TrackPoint Keyboard at work, and is very pleased with it.
I always remap the Caps Lock to act as an extrac Ctrl. When I do need the mouse, the trackpoint is right there, no need to move your hand away from the keyboard.
The keyboard is very flat and I like the feel of the keys. I have a couple of thinkpad laptops as well, and as this is essentially the same keyboard, the feel is the same whether I at my desk or working directly on the laptop - that's a big plus.
Here's some photos: http://www.thinkpads.com/2009/08/31/finally-photos-of-new-thinkpad-usb-trackpoint-keyboard/
There is another keyboard on the way designed for use within emacs, its name is the key64 and is a keyboard i am designing from about two years ago, right now i am finishing building the firmware while all the instructions to make the pcb and the parts needed to make the keyboard are available at its website www.key64.org
It's 100% programmable within Linux with gcc-avr as it use a teensy board.
Hope to finish the firmware by the end of January 2013 and publish it at the website for anyone interested in making his own keyboard :)
as an avid emacs user and long time rsi sufferer, the best solution i found was kinesis combined with footpedals. i program the pedals for Ctrl, Alt, Meta, and thus can use the notorious emacs combos with only a single finger. especially repeated Ctrl sequences work very well in this configuration. obviously you'll need to reprogram the keyboard a little bit, but those changes will be obvious.
I have been using Emacs since 1976, and have had a Kinesis classic for about 8 years now. I used to use it with foot switches for Control and Alt, but have found that it is equally effective to simply swap Backspace with Control, and Delete with Alt. I also swap the left side arrow keys with [ and ] to make it easier to type "[", "{", "}", and "]".
To further ease typing, I have created bindings for common programming language sequences that require shifted symbols. For example, in C++ I map "." to a function that replaces ".." with "->". I have also experimented with word abbrevs that are effective only when preceded by a semicolon, e.g. replacing ";pp" with "++".
I use the Kinesis keyboard most of the time; I've had mine for 10 years and recently retrofitted it with the new Linear Feel "Cherry Reds" and it should be good to go for another 10. But the keyboard is perhaps less important than the keymapping. The basic rule is: don't move your wrists when you're typing, at least not more than you have to.
In order to accommodate this on the Kinesis, I have the bottom row mapped to Hyper, Super, Control, Meta. I have Mode_switch on the thumb keys. So I absolutely never have to move my wrists to type key combos. (I use Mode_switch to connect to an "embedded arrow key" layer.)
You can do something similar on any keyboard, for example, your laptop keyboard -- remap the number row to modifiers, using xmodmap. You can still type Shift+num to get the standard symbols. Here is a minimal xmodmap starter kit. Use xev to customize further.
clear Shift
clear Lock
clear Control
clear Mod1
clear Mod2
clear Mod3
clear Mod4
clear Mod5
keycode 9 = s S Left
keycode 10 = d D Down
keycode 11 = f F Right
keycode 21 = w W BackSpace
keycode 22 = e E Up
keycode 23 = r R Delete
keycode 26 = Super_L exclam
keycode 27 = Hyper_L at
keycode 28 = Control_L numbersign sterling
keycode 29 = Meta_L dollar
keycode 30 = F6 asciicircum
keycode 31 = Mode_switch percent
keycode 32 = bracketright braceright
keycode 33 = Control_L parenleft
keycode 34 = Mode_switch ampersand
keycode 35 = bracketleft braceleft
keycode 36 = Meta_L asterisk
keycode 37 = Hyper_L parenright
add Shift = Shift_L Shift_R
add Control = Control_L Control_R
add Mod1 = Meta_L Meta_R
add Mod2 = Hyper_L Hyper_R
add Mod3 = Super_L Super_R
add Mod4 = Mode_switch
add Mod5 = Alt_L
I use a GoldTouch keyboard at work and home, and it works great to keep my arthritis at bay. I've remapped the Caps Lock to the Ctrl-key which helps quite a bit w/emacs-pinky. The Alt-key is a bit problematic, but I've solved some of this with a simple mapping in my .emacs file:
; Replace M-x with C-x C-m or C-x C-c
(global-set-key "\C-x\C-m" 'execute-extended-command)
(global-set-key "\C-xm" 'execute-extended-command)
Any OS allows you, one way or another, to remap all your keys.
This will improve greatly your speed, as long as you are not one of those who actually have to look at the keyboard while they type.
If you do that, you can then choose the keyboard focusing exclusively on the one which has the best physical keys (just try them).
I use Apple's wide keyboard and it's - for me - the best one I've ever used by far.
I like the Sun Type 6 Keyboard for Emacs - http://www.aquaphoenix.com/graphics/SunKeyboardType6/SunKeyboardType6_front_top-large.jpg
Upvoting MS Natural Pro 4000. It is the only Microsoft product I use on a regular basis and can strongly vouch for it.
I use a traditional keyboard, except that I change Caps Lock key to Ctrl and Document key to Caps Lock.
The Comfort Keyboard Original allows remapping of any keys, including Caps Lock -> Control, and is generally very ergonomic.
Is there anyone using these two keyboards?
http://www.trulyergonomic.com/store/products (trulyergonomic; about 250usd)
http://www.personal-media.co.jp/utronkb/ (utron; over 500usd)
Tooooooooo avoid RSI.