AHK - simulating Fn key shortcut - autohotkey

I would like to build an AHK script that will press Fn + D and Fn + G for me when executed.
Unfortunately, after checking the "key history" from an an AHK script where I enabled "KeybdHook", it appears that my keyboard's Fn key doesn't trigger any key action when pressed.
Should I give up all hope?
Unnecessary context :
On my 65% keyboard, Fn + [Key] shortcuts are pivotal for replacement of various missing keys, as well as for changing various keyboard settings.
In particular, RGB settings are changed using Fn + D and Fn + G — and, annoyingly, they reset to a default, ugly rainbow every time I restart my computer, instead of a more subdued RGB setting which I prefer. The script I am trying to build would change these settings automatically on startup (until my brain grows large enough to comprehend QMK, my keyboard's RGB software)
Thanks in advance. I fully expect bad news.

QMK has a good diagram of how keyboards work:
+------+ +-----+ +----------+ +----------+ +----+
| User |-------->| Key |------>| Firmware |----->| USB wire |---->| OS |
+------+ +-----+ +----------+ +----------+ +----+
When you press a key on your keyboard the QMK Firmware inside the keyboard interprets the key presses and creates a set of keycodes of what exactly to send down the USB wire to the OS.
If you configure QMK Firmware to say that Key(1,1) is the letter "a", whenever you hit Key(1,1), it will send the letter "a" (scancode 0x04) down the USB wire.
There are some keys and that combinations which don't get sent down the USB wire at all. For example, Fn keys are typically used to switch between virtual "layers". This means that if you configured it, Fn + Key(1,1) could now send the letter "z" (scancode 0x1D). Now, when you hit Fn + Key(1,1), it will send the letter "z" (scancode 0x1D) down the USB wire. It will not send the Fn key, because the Fn key only matters to QMK firmware, and not the OS.
When you press the Fn + D keys, the QMK Firmware interprets this as change RGB Setting. Even though you may be a part of pcmasterrace, the OS does not know anything about RGB keyboards and lighting. Also, there is no RGB scancode in the USB HID protocol defining "change RGB". Therefore pressing the Fn + D keys sends nothing down USB to the OS.
Since Change RGB isn't happening on the OS, and it only exists inside your keyboard, Autohotkey cannot send the right set of keystrokes to replicate the functionality. The only way to make changes to the default settings in the keyboard is to make and flash your own custom QMK firmware.

As the others stated, the Fn+D and Fn+G functions are totally handled inside the keyboard package, with no information passing to or from the PC side, making it impossible to readily insert a PC script routine in between.
However, keyboard mechanical switches are perhaps the simplest circuit in the world; with a couple of jump wires and a microcontroller (MCU), you can simply override any finger movement. Now, if that MCU is handled correctly, it may be controlled by PC-side software such as AHK, allowing you to accomplish your aim.

Related

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.

Redefining Uart Alt Modes For Pinmuxing

I am working on to enable Wandboard Quad(IMX6Q) Uart 2 features for to get data from GPIO3_26 and GPIO3_27 I enabled Uart2 from dts and recompiled imx6q-wandboard.dtb file ,it seems its working but
when I send the "hello" to ttymxc1 I m seeing the senseless charachters , even if I adjust same baudrate ttymxc1 and my machıne ttyUSB0 (I m using usb to rs232 converter ). I think I need to close some features but I dont know what is it or I need to make some configuration pinmuxing and ALT modes .
Is there any way to change the ALT modes of the features or when we choose the UART or another features it is enabling the dependent ALT Mode ?
Can you give me a suggestion or what Am I doing wrong ?
Must_ba

Setting up Tmux prefix to be a key sequence instead of the default key combination

By default the prefix with which one switches focus to Tmux for command entry is C-b (ctrl + b). This is a key combination. I would like to, instead, use a key sequence. I would like to doublepress the control key (C C (ctrl ctrl)).
How can this be achieved?
Generally speaking, you cannot do this: terminals use Control as a modifier (something done in combination with other key(s). Repeating a modifier has no effect.
There are several aspects to this:
tmux (like screen) runs in a conventional terminal. The fact that tmux is a curses application while screen is a termcap application makes no difference, since both are for the same type of terminal.
the terminals are conventional in the sense that they are either hardware terminals such as a DEC VT100, or emulate (act like) a hardware terminal.
all of these ("real" terminals and terminal emulators) are designed to send characters, such as US-ASCII (essentially the POSIX character set, along with control characters).
to be able to send these characters, some keys were assigned the role of modifiers. That is, they are used only in combination with other keys to modify the value sent.
examples of modifier keys include: Shift, Control, NumLock, Alt.
while there are graphical applications (such as the xev X Window application) that can read separate key-press and key-release events for almost any key on a keyboard, terminal emulators use a keyboard configuration which combines these, along with modifier keys. Applications running in the terminal emulator see only the effects of key-presses, modified to reflect which shift-, control-, etc., modifier key you are using.
a few special cases exist, such as the Linux console for which an application can make system calls to get some of the event information. However, applications (back to tmux and screen) which are written for conventional terminals do not use these special cases. That is because the specialized information would be only available on certain terminals, while the applications are designed to be able to attach (and run seamlessly) on any (conventional) terminal).
Regarding the special function calls, that has been asked before, e.g.,
Access Keystrokes in C
How to fetch data in a background process in Ubuntu

What is the key scan code of the Fn key for use in AutoHotkey (AHK)?

I want to use Fn+S to emulate Ctrl+S, and so far this is my code:
#InstallKeybdHook
#Persistent
SC126 & s::
Send ^{s}
return
My problem is that I don't know the Fn key's scan code.
How can I find it?
The Fn key does not have a scan code.
The keyboard driver does not expose the Fn key to the operating system, so basically your operating system (and therefore AutoHotkey) does not know that it exists.
When you press the Fn key in combination with a supported key, the keyboard driver reports a single key press to the operating system with a different scan code. Basically, it tells the operating system that a different key was pressed.
When you press the Fn key in combination with a supported key, the keyboard driver reports the presses to the operating system (Windows in this case).
You can find the Fn key scan code by:
Go to the tray icon
Right-click Script
Click Open
Click View and then Key History and Script Info (alternatively Ctrl + K)
Once you press the key, you can refresh (F5) and scroll to the bottom to see the codes
If you're trying to use a Mac keyboard and would like to map the Fn key to Insert (and also get other standard Windows keys, like PrintScreen), then you might want to try the 'hidfalum' driver. It's available here: http://www.bimoid.com/download/utils/hidfalum.zip

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.