Microsoft statement about Windows-key usage in the future? - windows

Assigning keyboard shortcuts is very popular for automating tasks. AutoHotKey even makes it a one-liner.
When choosing hotkey combinations, we always need to be careful not to destroy shortcuts of any existing applications, especially if they can be assigned using the mechanisms of Winforms or WPF.
So the most safe key is probably the Windows key. However, Microsoft writes in the documentation of RegisterHotKey():
MOD_WIN 0x0008
Either WINDOWS key was held down. These keys are labeled with the
Windows logo. Keyboard shortcuts that involve the WINDOWS key are
reserved for use by the operating system.
And it's true that Microsoft adds more and more Windows-key-combinations to the operating system itself, as we have
E - Explorer
L - Lock screen
P - Presentation
M - Minimize
D - Desktop
R - Run
Tab - Switch
and probably others which I don't even use. Until now I haven't seen a Windows shortcut which uses additional modifiers such as Shift, Ctrl or Alt.
As I don't want to override existing shortcuts which users might already be familiar with, I have the following questions:
a) Is there a way to programmatically find out which Windows-shortcuts are defined by the OS?
And I mean Windows only here. Not shortcuts which are in use e.g. by OneNote (I especially don't like those) or AutoHotKey.
b) Is there any official Microsoft statement that they will try not to use modifier-Windows-shortcuts in the future?

Some modifier+Win shortcuts already exist, for example Win+Shift+Tab, Win+Shift+Arrow, and Win+Shift+digit.

Related

Impossible to differentiate CTRL from ALT Gr when key down with the IE browser

I am coding in a vbs page and I need to know when AltGr is pressed. I must use the IE browser only (I am using version 1909).
Here is a sample of code reproducing the issue:
sub document_onkeydown()
MsgBox "key=" & window.event.keyCode
MsgBox "ctrl=" & window.event.ctrlKey
MsgBox "alt=" & window.event.altKey
MsgBox "altLeft=" & window.event.altLeft
end sub
The document_onkeydown sub is called each time I press a key.
My problem is that it is impossible to differentiate AltGr key from Ctrl key.
If I press Ctrl:
window.event.keyCode = 17
window.event.ctrlKey = true
window.event.altKey = false
window.event.altLeft = false
If I press AltGr:
window.event.keyCode = 17
window.event.ctrlKey = true
window.event.altKey = false
window.event.altLeft = false
As you can see, the values are the same. How to differentiate between the two keys pressed?
I could see that window.event.altRight is not recognized so I can't use that.
I am using a FRA CAFR (french Canada) keyboard.
TL;DR
This issue is caused by a combination of your Operating System (OS) and the Application you are using. IE is simply treating AltGr as Ctrl (or Ctrl + Alt) and there is nothing you can do to change that. IE and many other applications are developed that way.
Full Answer
The key your computer detects as being pressed is a combination of your OS and Application. It sounds like your using some version of Windows as your OS?
Windows will properly detect AltGr as long as its a supported keyboard and configured correctly. Its a small possibility, but you might want to check your settings to make sure your not treating your FRA CAFR (french Canada) keyboard as an English keyboard or something else.
Most likely your running into one or more of the following issues:
Windows has a quirk where it often detects AltGr only when the Right Alt (AltGr) is pressed.
Its up to the application to report keystrokes to you. Applications developers often have a bad habit of treating AltGr as Ctrl or Ctrl + Alt. Since you have to use IE, I suspect the version of IE your using (and possible all IE versions/ Edge) treat AltGr as Ctrl.
Sources
On SuperUser this is a similar question and answer: In a windows keyboard, is right ALT treated as AltGr? I copied the main point below:
But multi-platform apps (e.g. Eclipse IDE or some Firefox plugins)
ignore this difference so AltGr+E launches Ctrl+Alt+E so you have no
way to type the €. But this is rather a bug which hopefully developers
fix, although developers using only US keyboard layout typically don't
care and resist fixing this (as seen in Eclipse bug tracker).
Not treating the AltGr key correctly is actually a big issue that many application developers overlook or decide not to address. Take a look at this issue opened with VScode for example: AltGr invokes Ctrl+Alt shortcuts #50341 VSCode is one of the most popular code editors on the market and supported by Microsoft, yet they still cant fix this issue.
If you follow the issue thread AltGr is being treated as Ctrl + Alt by Electron possibly in part because of Chromium. The user is using one application, VSCode, but the key press is being passed through 2 to 3 different abstraction layers (applications to keep things simple) and any one of them can choose to ignore AltGr and treat it as Ctrl.
Workaround
If you can and are willing to use additional software SuperUser has a question and answer that can help you: Can I make Ctrl+Alt NOT act like AltGr on Windows?
The answer is to much to copy or summarize here, but in case of link rot the solution is to use AutoHotKey to (attempt to) force the correct key through to the application.

I need to make a standalone service for detecting and executing custom Windows hotkeys

I am attempting to make a macro keyboard that will automatically open some webpages and programs for me. In order to accomplish this, I have made a custom keyboard that is able to input keystrokes for me.
I would like to use a key combination like ctrl + a + b + c to activate my macros so that it does not interfere with the macros I already have on my keyboard. I have attempted to use Auto Hotkey for this purpose, but it does not accept multiple keys like I want.
I, therefore, believe that I will be forced to code my own hotkey manager. Here are the features That I want to be included in my hotkey manager:
Multiple key activation. example: ctrl + a + b + c
Ability to open webpages.
Ability to run programs.
preferably a single program, so that it can be used on multiple computers easily.
Is a project like this possible for an intermediate programmer?
I am currently experimenting with C# and Windows services, but I am unable to figure out how to listen for keystrokes. I am not married to C#. I can change languages as needed.
Any advice you would give is greatly appreciated.
You can try using hotstrings instead of a multi-key hotkey.
A hotstring is a sequence of keystrokes.
You can define hotstrings like this
::btw::by the way
Typing "btw" and then a Space or Enter or any word terminator, will expand "btw" to "by the way"
AutoHotKey can also be used to open webpages, run programs etc.

Remap keys in OS X

Specifically I'm attempting to map my MacBook's fn key to left mouse click.
Back in the old days when I was using Windows, I came across a wonderful little utility that let me map anything to anything: http://www.autohotkey.com/
You create a little text file, e.g.
^!s:: ; CTRL + ALT + s
Send Sincerely,{enter}John Smith ; sends keystrokes to active window
return
Creating a simple text file was infinitely better than any GUI based remapper.
I can look through it and see everything that is going on at a glance
I can customise every last detail
I can save / retrieve / post / share my scripts
Really, it's the one thing I really miss about Windows.
So my question is: How do I go about doing this in OS X? Every Google search leads to https://pqrs.org/macosx/keyremap4macbook/ and I dislike this package: it has an insanely cluttered GUI.
I would be very happy if I could do it in a shell script, or even compile code.
HotKeys on OS X
Even though AHK is seemingly absent on Mac, the functionality that AHK provides on Windows can likely be achieved in OS X. It could be a matter of coding your own solution, modifying something that's open-source, or using a combination of applications that will work together. I haven't tried all of the following, but might as well mention them as they might be worth checking out:
Open Source
IronAHK - .NET rewrite of AHK ported to OS X
AHK Forum Thread
Github Project
*the original project might be dead
CliClick - command-line application that will emulate mouse clicks
Github Project
Commercial
TextExpander - scriptable text completion / hotkey / macro app (supports AppleScript, Shell scripts)
Typinator - similar to TextExpander, although some features vary.
KeyMo - mostly for mapping keys exclusively to your mouse.
FastScripts - maps hotkeys/user-definable keyboard shortcuts to AppleScripts
*I use Text Expander and FastScripts together and can't live without them.
Rolling Your Own
It's fairly easy to create something with an AppleScript, or a shell script for just about anything imaginable in OS X. For example, I've seen CliClick used along with a custom AppleScript to achieve a certain functionality that it might not provide otherwise. To find an AHK replacement on Mac it'll probably be through trial and error, patience, and ultimately what ends up working best for you.
It is possible with a program called ControllerMate, instructions here. It is, however, a commercial software. I'm also interested in finding a free alternative.
Sikuli project looks promising. Not sure about your particular problem (e.g. Fn key remapping), but it's definitely a crossplatform alternative to AHK.
Another Open Source solution to this problem not mentioned in l'L'l's answer is Karabiner; I have been looking for a way to remap the key to the left of 1 to Esc for a while, and this worked perfectly. It even resolved an issue I was having where swapping Cmd and Alt using the built in OSX key remapping was breaking terminal Alt shortcuts! Highly recommend it.

How to make a Custom Keyboard layout?

What's the best way to make a keyboard layout for Windows?
Specifically a layout that will appear in the 'Text Services and Input Languages' list and without buying expensive software.
I know about the Microsoft Keyboard Layout Creator but find it completely limited as you can't do simple things like remap the CapsLock key or the number keys.
You can build one yourself! A keyboard layout is basically a .DLL with a function that returns a table of assignments. The driver kit contains examples, and my Programmer Dvorak comes with source too (which is not derived from the DDK).
For remapping CapsLock or the number keys, use remapkey.exe found in the Windows 2003 Resource Kit Tools.
Keyboard layouts that show up in “Text Services and Input Languages” can’t remap CapsLock or do anything not supported by Microsoft Keyboard Layout Creator; the operating system just doesn’t support it. Anything that Microsoft can do with a keyboard layout, you can do with Microsoft Keyboard Layout Creator.
I realize that this thread is quite old and dead, but the answer provided is inaccurate.
You can do exactly what you want to do with KbdEdit. It is not free, but it is not expensive by any means, and there are several versions with varying features.
I would also like to point out that despite the claims of the highest rated answer, the operating system, in fact, most certainly DOES support a multitude of complexities and customizations which MSKLC can not understand, process or support.
There are—and always have been—MANY features and behaviors of keyboards which are possible in Windows but which are impossible with MSKLC.
In a number of cases it is possible to create as much as possible with MSKLC and then modify the source file in a text editor and then to build the DLL using the command line tools supplied with MSKLC. But it is my understanding that at a certain point—with certain features—those tools can not even be used to generate working keyboards.
At this point you could turn to the driver development kit, but that is beyond my scope.
Fortunately, there's KbdEdit! It is extremely powerful, easy to use and it can change any key on most any keyboard to any other key—except for the "Pause" key, which is a Microsoft imposed restriction, but even that can be circumvented with AutoHotKey.
Cheers!
did you check the new version of Microsoft Keyboard Layout Creator, I think you can do many things with this new version like remapping keys.
I am a fan of Auto Hotkey, a free, small, non-fuzzy windows tool to assign macros to keys. If all you want is a few special characters like proper “Quotation Marks” —or em-dashes— this is great:
#NoEnv;
SendMode Input;
!1::
{
Send „
}
return
!2::
{
Send “
}
return

Customizing Windows Right-Click menus with multiple levels

I understand the process needed to customize a right click menu going through the regedit etc. However I need to the ability to go multiple levels such as in applications like WinZip. Here's a picture for clarification of what I need
alt text http://img14.imageshack.us/img14/9658/multiplemenus.jpg
You need to write a Shell Extension; there is a guide for writing one in managed code (C#) here. It will involve doing a bunch of interop and implementing COM interfaces that the windows shell will consume, namely IShellExtInit and IContextMenu.
However, one could argue that writing a Shell Extension in managed code is not advisable; it will force windows explorer to load the CLR, (or any app that uses the standard windows 'Open File' dialog) - native code (C++) would be a better choice for this.

Resources