Make AutoHotKey ignore Alt as menu key - autohotkey

I'm trying to use autohotkey to simulate elements of Mac keyboard on a PC (Windows) keyboard. My muscle memory reaches for the Command key for simple tasks like copying and pasting, so I'd like to remap the left alt+letter key combinations to appropriate ctrl+letter.
<!c::Send ^c
Most of the time it works fine, except for part of the time in IE and Office applications. When pressing the left Alt, it screws with the office ribbon/menus (i.e. the menu bar shows in IE, or ribbon letters start appearing in Office 2010), and the ctrl+letter combination fired does not reach destination.
I've read the AHK FAQ + forums, tried a couple of options with UP and $ modifiers to the hotkey, but it did not fix the problem. Any ideas?

This prevents the left-hand side Alt key from activating the menu bar for most applications (under Windows 7 and AutoHotkey 1.1.11.01):
~LAlt Up:: return
It doesn't work with Internet Explorer but I don't use IE often anyway. :)
BTW, I also killed the annoying start menu popup via:
~LWin Up:: return
~RWin Up:: return

Use
LAlt::LCtrl
put it into a ahk file compile it and run .exe with administrator rights
right click -> Run as administrator
I tested it on Windows 7 and it works, LAlt no longer fires anywhere and it is completely replaced with LCtrl.

Just checked this on Win-7 and it works, even with IE.
00 00 00 00 00 00 00 00 03 00 00 00 1d 00 38 00 38 00 1d 00 00 00 00 00 00
Here is the SwapCtrlAlt.reg text.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,1d,00,38,00,38,00,1d,00,\
00,00,00,00,00

It sounds like you need the wildcard modifier. This will make it so if your hotkey is pressed in conjunction with another key. The mapping still works. Give the following a try:
*LAlt::LCtrl
This will make Alt fire Ctrl for any Alt+Key combination.

Use
LAlt::LCtrl
this will replace LAlt with LCtrl

you could also swap the two buttons.
Something like:
LAlt::LCtrl
LCtrl::LAlt
In the limited testing I did, it works, but you might need to relearn some of your window key shortcuts. It basically just swaps the two buttons.

I am afraid that IE behaves differently from most other applications.
You could try the instructions below. This is NOT autoHotKey but regedit changes.
B.t.w. I had checked to see if ScanCodes would work (SC38 for LAlt), but IE still ignores that.
Not sure if this works in Vista/Win7/8, but worth a look.
http://www.designcodeexecute.com/2006/11/04/swap-alt-and-ctrl-keys-in-windows-xp/

Related

How to return to previous popup?

I am opening a Popup(1) - Screen_0300
CASE sy-ucomm.
WHEN 'POPUP1'.
CALL SCREEN 0300 STARTING AT 10 08 ENDING AT 70 15.
ENDCASE.
From within this Popup I am calling another screen Popup(2) - Screen_0400.
MODULE user_command_0300 INPUT.
CASE sy-ucomm.
WHEN 'POPUP2'.
CALL SCREEN 0400 STARTING AT 10 08 ENDING AT 70 15.
ENDCASE.
ENDMODULE.
Now when I close Popup(2) I want to return to Popup(1). Currently both Popups get closed simultaneously. I already tried to call Popup(1) in the PAI of Popup(2) with Leave to Screen or Set Screen. Is there any way to achieve this?
To leave a screen displayed using CALL SCREEN, use SET SCREEN 0 during the execution of the PAI (MODULE ... INPUT), and the program will continue after the statement CALL SCREEN.
0 is a special value to leave the current "Screen Call Sequence".
I found the answer myself, posting it so others might find the answer faster. It seems to be the same issues as this.
Fixed it with the following:
data next_screen type sy-dynnr.
CASE sy-ucomm.
WHEN 'POPUP1'.
next_screen = '0300'.
while next_screen is not INITIAL.
CALL SCREEN next_screen STARTING AT 10 08 ENDING AT 70 15.
endwhile.
ENDCASE.
And in the second popup:
MODULE user_command_0300 INPUT.
CASE sy-ucomm.
WHEN 'CANCEL' OR 'ENTER'
CLEAR next_screen.
WHEN 'POPUP2'.
CALL SCREEN 0400 STARTING AT 10 08 ENDING AT 70 15.
ENDCASE.
ENDMODULE.
This way whenever the first Popup is closed with the sy-ucomm CANCEL or EXIT next_screen is cleared and the main program is in focus again. Otherwise next_screen keeps being 300 and will be called all the time.

AutoHotKey stopped working after plugging new keyboard, even if I restart computer

I upgraded my keyboard. Problem is that now all the scripts stopped working. Even simple scripts from the tutorials don't work.
This happens in all applications, and ever if I plug in my old keyboard and restart the computer, autohotkey just does not work any more even in my previous configuration. I've tried also running in administrator mode.
What I do see however is the following, that the script works only once each time autohotkey is relaunced. For example:
^j::
Send, My First Script
Return
This works the first time ctrl-j is pressed, however afterwards it does not work again until I restart autohotkey.
Any ideas? I have Windows 10 x64, 1.1.23.05. I did not install any new drivers with the new keyboard (it's a standard usb keyboard, though a mechanical type).
Here are some more examples of simple scripts that don't work:
SetCapslockState AlwaysOff
In this case the first time I press the capslock, it's indeed ignored, but all the next times I click it works normally.
a::return
Again, same behaviour: a is ignored the first time, but next time it works normally, until I restart AHK (and again then it works only the first time).
Note that in all cases I'm running AHK only with the single line scripts you see; nothing else.
Below is the Key History and last lines when pressing Ctrl-J (of the first example)
Window: C:\Files\Tools\AutoHotKey\1.ahk - AutoHotkey v1.1.23.05
Keybd hook: yes
Mouse hook: no
Enabled Timers: 0 of 0 ()
Interrupted threads: 0
Paused threads: 0 of 0 (0 layers)
Modifiers (GetKeyState() now) =
Modifiers (Hook's Logical) =
Modifiers (Hook's Physical) =
Prefix key is down: no
NOTE: To disable the key history shown below, add the line "#KeyHistory 0" anywhere in the script. The same method can be used to change the size of the history buffer. For example: #KeyHistory 100 (Default is 40, Max is 500)
The oldest are listed first. VK=Virtual Key, SC=Scan Code, Elapsed=Seconds since the previous event. Types: h=Hook Hotkey, s=Suppressed (blocked), i=Ignored because it was generated by an AHK script, a=Artificial, #=Disabled via #IfWinActive/Exist, U=Unicode character (SendInput).
VK SC Type Up/Dn Elapsed Key Window
-------------------------------------------------------------------------------------------------------------
74 03F d 11.94 F5 C:\Files\Tools\AutoHotKey\1.ahk - AutoHotkey v1.1.23.05
A2 01D d 3.09 LControl *c:\Files\Tools\AutoHotKey\1.ahk - Notepad++
74 03F d 1.99 F5 C:\Files\Tools\AutoHotKey\1.ahk - AutoHotkey v1.1.23.05
Press [F5] to refresh.
Lines
001: Return (15.77)
003: if ( GetKeyState( "Control" , "P" ) )
007: Return (150.50)

Does the Atom Editor keymap support function keys? Like F5

I setup keymap.cson with this entry. In the palette, I can see F5 is associated with this command but pressing F5 does not trigger it
'.workspace .editor':
'F5': 'runner:run'
Yes, Atom supports function keys. The names of the keys are case-sensitive and the name of F5 is f5, note the lowercase "f". The following should work:
'atom-workspace atom-text-editor':
'f5': 'runner:run'
Also, note that you may want to replace atom-workspace atom-text-editor with just atom-workspace, unless you don't want the key to execute the command when you're on the Tree View, a Markdown Preview or any other view that isn't an editor.

Automate Windows 7 Ease of Access Setting "Turn off unnecessary animations"

I'm trying to find a away to automatically enable/disable a setting in Windows 7:
From Category view:
Control Panel\All Control Panel Items\Ease of Access Center\Make the computer easier to see
From Icon view:
Control Panel\All Control Panel Items\Ease of Access Center\Make the computer easier to see
The setting:
Turn off all unnecessary animations (when possible)
Some context:
This seems to be a way to disable the animations on Microsoft Office 2013 which are causing an Excel Add-in I wrote to behave sluggishly (the add-in itself does graph interactivity and animation, which chugs badly in Office 2013 with the new graphics hardware accelerated animations). I've tried the within Office setting to disable the animation, but it didn't have any effect after Office restart or reboot, and others have also reported this. Changing settings in the Ease of Access Center or the visual performance settings (Control Panel\All Control Panel Items\Performance Information and Tools > Adjust Visual Effects > Animate controls and elements inside windows) are the best way to remove the animations. The Ease of Access Center method I'm asking for help with doesn't require elevated privileges and works instantly, so if there is a way to automate it, it should be more seemless.
In the end I'd like to toggle the setting from VBA or VB.Net Microsoft Office Add-Ins, but I don't care what form the solution takes (batch file, Windows API, VBS script, PowerShell, etc.) since it should be easy to implement from the add-in. If it comes down to Auto-It style mouse-click automation, I'd rather just give the user instructions and pop up the explorer window for them.
Thanks for any helpful ideas!
"This stuff is also controlled via the computer properties -> advanced-> performance-> visual effect option. If you set it to best performance, all the stuff you want turned off is turned off.
Unfortunately this changes a whole bunch of registry values but if we
just narrow down on the stuff you want, there are 2 registry values
involved:
HKCU\Control Panel\Desktop\UserPreferencesMask
This is a reg_binary value. Change this value from 9E 2C 07 80 12 00
00 00 to 9E 2C 07 80 10 00 00 00 .
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\VisualFxSetting
The VisualEffects key doesn't exist by default. There are a bunch of
values that can be defined under here but the only one that really
matters is VisualFxSettings. Set this to 2 to disable a lot of the
animations and also to tick "Turn off all unnecessary animations (when
possible)" ."
Quote from -> HERE
Run the following powershell, reboot, and you'll be good to go.
PS C:\> Push-Location
PS C:\> Set-Location "HKCU:\Control Panel\Desktop\"
PS HKCU\Control Panel\Desktop> Set-ItemProperty . -Name UserPreferencesMask -Value ([byte[]](0x9E,0x2C,0x07,0x80,0x10,0x00,0x00,0x00))
PS HKCU\Control Panel\Desktop> Pop-Location
PS C:\>
PS C:\> Push-Location
PS C:\> Set-Location HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\
PS HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects> New-ItemProperty . VisualFxSetting -Value 2
PS HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects> Pop-Location

Autohotkey: Commands with Alt Key Working Properly only if not Restricted to a Specific Application

I'm trying to add custom keyboard commands to an application using Autohotkey.
In many of these hotkeys I would like to use the alt key in combination with some other key of my choice (any of the standard letters).
All works fine as long as I don't restrict their usage in such a manner that they work in the target application only (via the #IfWinActive directive ). If I do so, the hotkeys themselves still work, however their behavior is very strange.
I found that they get activated either if
a) I hold down the alt key and then press the second key (in my case the 'b' key) twice
or
b) I use this hotkey two times consecutively with a very short delay between the two triggerings
- The above two cases might actually be 1 case. I'm not sure...
I have no problems when doing the same with Shift or CTRL.
The 'b' key is not what's causing the problem - no alt + 'letter' combination works.
I have tried all SendModes, but so far with no effect.
Code sample:
#IfWinActive, MyAppTitle ahk_class MyAppClass
!b::
click 367, 86
return
Alt+letter commands in AutoHotkey such as !b work without issue. It's possible the version at the time of this post contained certain bugs or was out of date from the current version.
For your code, it could be done like so:
!b::
WinGetTitle, Title, A
if (RegExMatch(Title, "MyAppTitle"))
{
MouseClick, left, 367, 86
}
return