How can I keep modifier of hotkey active in AutoHotkey? - autohotkey

A media keyboard I'm using doesn't have a full set of keys, so I'm trying to map alternatives using AutoHotkey. Basically, I want to use the Alt Gr key together with some other keys to simulate the missing keys. This is what I've done:
<^>!,::send {Home}
<^>!.::send {End}
<^>![::send {PrintScreen}
<^>!]::send {Insert}
However, if I want to do the equivalent of Shift + Home (to select all text to the beginning of a line), this doesn't work as I'd hoped. I know I can put a * at the beginning of the line so that Home is still sent even when I'm holding Shift, but the problem is that I'd like the Shift key to still be active so that I get the equivalent of Shift + Home.
Likewise, if I want to do Alt + Print Screen then holding Alt while pressing Alt Gr + [ doesn't have the desired effect.
I assume I could set up extra rules to catch those combinations, but surely there must be a way to just have AutoHotkey not discard whatever modifier I'm holding at the time I hit the hotkey so that whatever combination I use it'll work?
EDIT (2014-07-16):
Here is the latest version of my script, which includes comments that make it clear what I'm wanting to achieve. Everything in this script works except for the last line. For some reason, even though I'm trying to send Alt + PrtScn it gets treated as just PrtScn.
; Home ( by pressing AltGr + , )
<^>!,::send {Home}
; Shift + Home ( by pressing Shift + AltGr + , )
+<^>!,::send +{Home}
; End ( by pressing AltGr + . )
<^>!.::send {End}
; Shift + End ( by pressing Shift + AltGr + . )
+<^>!.::send +{End}
; Insert ( by pressing AltGr + [ )
<^>![::send {Insert}
; Shift + Insert ( by pressing Shift + AltGr + [ )
+<^>![::send +{Insert}
; PrtScn ( by pressing AltGr + ] )
<^>!]::send {PrintScreen}
; Alt + PrtScn ( by pressing LeftAlt + AltGr + ] )
<!<^>!]::send !{PrintScreen}

Using the {Blind} attribute will pass on the modifier keys.
e.g.
<^>!,::send {Blind}{Home}
See: Send existing modifiers with a key in autohotkey?

It turns out that some of the combinations I wanted to do with Autohotkey, involving the AltGr key, are not possible due to AltGr itself actually being a combination of Control and Right Alt. Therefore, not all modifiers are available for use together with that key, and some of the AutoHotkey commands give unwanted/unexpected results when trying to use them together with AltGr.
The final version of the script I'm using with my new keyboard (the UK version of the Microsoft All-in-One Media Keyboard) is as follows:
; Set an initial state for the lock keys
SetCapsLockState, off
SetNumLockState, on
SetScrollLockState, off
; Home ( by pressing AltGr + , )
<^>!,::send {Home}
; Shift + Home ( by pressing Shift + AltGr + , )
+<^>!,::send +{Home}
; End ( by pressing AltGr + . )
<^>!.::send {End}
; Shift + End ( by pressing Shift + AltGr + . )
+<^>!.::send +{End}
; Insert ( by pressing AltGr + [ )
<^>![::send {Insert}
; Shift + Insert ( by pressing Shift + AltGr + [ )
+<^>![::send +{Insert}
; PrtScn ( by pressing AltGr + ] )
<^>!]::send {PrintScreen}
; Alt + PrtScn ( by pressing Alt + ] )
!]::send !{PrintScreen}
; Scroll Lock ( by pressing AltGr + \ )
<^>!\::send {ScrollLock}
; Pause/Break ( by pressing AltGr + p )
<^>!p::send {Pause}
; Win + Pause/Break ( by pressing Shift + Alt + p )
+!p::send #{Pause}
; Control + Pause/Break ( by pressing Shift + Ctrl + p )
+^p::send ^{CtrlBreak}
; Run Calculator ( by pressing AltGr + c )
<^>!c::Run Calc

Related

Avoid overlapping modifiers for hotkey

Use case: my laptop keyboard (a Qwerty one with Azerty stickers on it) is missing the « < and > » key, which I absolutely need. Therefore I'm writing an AutoHotKey script to be able to type these characters.
Expected behavior: inputting « Left Ctrl + W » should programmatically type "<", and inputting « Left Ctrl + Left Shift + W » should programmatically type "<".
Issue: with the following script, inputting « Left Ctrl + W » programmatically type "<>", so the hotkeys seem to be overlapping… but I thought AutoHotKey was expected to not trigger a hotkey when extra modifiers are inputted.
; Left Ctrl + W
<^w::
SendInput <
; Left Ctrl + Left Shift + W
<^<+w::
SendInput >
However, the following script works as expected. I just added a "Return":
; Left Ctrl + W
<^w::
SendInput <
Return
; Left Ctrl + Left Shift + W
<^<+w::
SendInput >
Question: is it normal that AutoHotKey inputs "<>" with my first script? Is adding such "Return" the required syntax indeed, even though the script consists of just these 2 hotkeys?
Yes, this is normal.
Either write the hotkeys on a single line, otherwise use return.
Valid syntaxes:
; Left Ctrl + W
<^w::SendInput <
; Left Ctrl + Left Shift + W
<^<+w::SendInput >
or
; Left Ctrl + W
<^w::
SendInput <
return
; Left Ctrl + Left Shift + W
<^<+w::
SendInput >
return

Simulate QWERTY on QWERTZ with script

At my school, the Windows control panel is locked and I am only allow to use the standard German QWERTZ layout there, which I cannot touch-type on. With the agreement of my teacher, I am allowed to use a program or script to simulate the QWERTY layout, which I am used to. This is what I got so far:
y::z
z::y
-::Sendraw /
+-::Sendraw ?
+::Sendraw ]
*::SendRaw }
+2::SendRaw #
+3::SendRaw #
+6::Send {^}{Space}
+7::SendRaw &
+8::SendRaw *
+9::SendRaw (
+0::SendRaw )
ß::SendRaw -
+ß::SendRaw _
´::Send {U+003D}
+´::SendRaw +
ö::Send {U+003B}
+ö::SendRaw :
ä::SendRaw '
+ä::SendRaw "
ü::SendRaw [
+ü::SendRaw {
Most things work nicely except Shift + 7, 8, 9, 0 and ´
Shift + 8, 9 or 0 all produce }
Shift + 7 produces an ^
Shift + ´ produces an ]
Minus produces an ^
Shift + - produces an overflow error.
Fetch pressed keys by unicode is not possible from what I understand.
What am I doing wrong?
Do you maybe know a program which does exactly this, so I can just leave all this?
y::z
z::y
-::Send {U+002F} ; /
+-::Send {U+003F} ; ?
+::Send {U+005D} ; ]
*::Send {U+007D} ; }
+2::Send {U+0040} ; (
+3::Send {U+0023} ; #
+6::Send {U+005E}{Space}; ^
+7::Send {U+0026} ; &
+8::Send {U+002A} ; *
+9::Send {U+0028} ; (
+0::Send {U+0029} ; )
ß::Send {U+002D} ; -
+ß::Send {U+005F} ; _
´::Send {U+003D} ; =
+´::Send {U+002B} ; +
ö::Send {U+003B} ; ;
+ö::Send {U+003A} ; :
ä::Send {U+0027} ; '
+ä::Send {U+0022} ; "
ü::Send {U+005B} ; [
+ü::Send {U+007B} ; {
^::Send {U+0060} ; ~
+°::Send {U+007E} ; `
#::Send {U+005C} ; \
+'::Send {U+007C} ; |
You just have to use unicode characters as output.

How to go to a particular line in Zend Studio 12 with a keyboard shortcut

What is the shortcut to go to a particular line in Zend Studio 12, in the same way that CTRL + G works in NetBeans IDE and Notepad++?
Also, how can I get all the shortcuts of Zend Studio 12?
CTRL + L is the short cut to go to line directly.
If you want to see a full list of shortcuts, in Zend Studio go to :
Window--> Preferences--> General--> Keys.
To bring up a list of commonly used commands, press Ctrl+ Shift+ L in the Editor.
Source : commonly used keyboard shortcuts
Manage
Ctrl + N Add New Document
Ctrl + O Open Document
Ctrl + F4 Close Document/Window
Ctrl + Shft + F4 Close All
Ctrl + Shft + O Open Project
Ctrl + Shft + N New Project
Ctrl + S Save File
Ctrl + Shft + S Save As
Ctrl + Alt + S Save All
Editor
Ctrl + Space Show Code Completion
Ctrl + Space + Shft Show Function Arguments
Ctrl + Shft + F Reformat Code
Ctrl + / Add Remove Comment
Ctrl + / + Shft Add Remove PHP Block Comment
Ctrl + W Toggle Line Wrap
Ctrl + Z Undo
Ctrl + Y Redo
Ctrl + E Erase Line
Ctrl + D Duplicate Selection
Ctrl + L Change Selection to Lower Case
Ctrl + U Change Selection to Upper Case
Ctrl + B Bold Tag
Alt + I Italic Tag
Ctrl + - [1-3] Heading 1-3 Tag
Ctrl + Enter Break Tag
Ctrl + Back + Quote NBSP Tag
F1 Open Function Help
Code Folding
Ctrl + Shft + 1 Collapse All Non-PHP
Ctrl + Shft + 2 Collapse All Classes
Ctrl + Shft + 3 Collapse All Functions
Ctrl + Shft + 4 Collapse All DocBlocks
Ctrl + Shft + 9 Fold in Scope
Ctrl + Shft + E Expand All Folds
Ctrl + Shft + C Collapse All Folds
Debugging & Profiling
F8 Debug URL
F12 Profile URL
Ctrl + F5 Run
F5 Go
F10 Step Over
F11 Step Into
Shft + F1 1 Step Out
Shft + F5 Stop Debug
Shft + F10 Go to Cursor
F9 Toggle Breakpoint
Shft + F8 Add Watch
Ctrl + Alt + B Show In Browser
Navigation
Ctrl + Alt + G Goto File
Ctrl + Shft + G Goto PHP Resource
Ctrl + G Goto Line
Ctrl + F2 Goto Next Bookmark
Alt + F2 Goto Next Project Bookmark
Ctrl + M Goto Matching Bracket
Alt + Left/Right Go Back/Forward
F2 Toggle Bookmark
Ctrl + Shft + F2 Remove All Bookmarks
Ctrl + Shft + M Open Bookmarks Dialog
Ctrl + Shft + R Show Recent Files
F4 Open Next Entry
Find/Replace
Ctrl + F Find
F3 Find Next
Shft + F3 Find Prev
Ctrl + H Replace
Ctrl + Alt + F Find In Files
CVS/Subversion
Alt + U Update
Alt + C Commit
Tools
Alt + Ctrl + A Analyze Code
Ctrl + Shft + I Check Include Files

BetterDesktopTool and Autohotkey

I have setup a keyboard shortcut in BetterDesktopTool that has a sort of mission control view for Windows.
The shortcut is Alt + Tab and I want to map my F3 key to that. But it won't work in Autohotkey
#InstallKeybdHook
#SingleInstance force
SetTitleMatchMode 2
#Include Apple Wired Keyboard.ahk
SendMode Input
; --------------------------------------------------------------
; NOTES
; --------------------------------------------------------------
; ! = ALT
; ^ = CTRL
; + = SHIFT
; # = WIN
; media/function keys all mapped to the right option key
F7::SendInput {Media_Prev}
F8::SendInput {Media_Play_Pause}
F9::SendInput {Media_Next}F3F3
; F10::SendInput {Volume_Mute}
; F11::SendInput {Volume_Down}
; F12::SendInput {Volume_Up}
; swap left command/windows key with left alt
LWin::LAlt
LAlt::LWin
; Misc.
F20::WinMinimize A
*F3::SendInput {Alt}{Tab}
; F13-15, Volume
F13::SendInput {Volume_Mute}
F14::SendInput {Volume_Down}F3F3
F15::SendInput {Volume_Up}
;F16-19 Standerd
F16::SendInput {PrintScreen}
F17::SendInput {ScrollLock}
F18::SendInput {Pause}
F19::Run wmplayer
I know that my Alt + Tab shortcut works, but it doesn't activate the hotkey for BetterDesktop
Have a look at this documentation:
http://www.autohotkey.com/docs/Hotkeys.htm
Search for "Substitutes for Alt-Tab"

Alt + Space + key in autohotkey

How can I create an Alt + Space + C shortcut in autohotkey? Alt + Space is !space but I don't see how I can add a third key without getting an error.
You can use the #If directive (requires AHK_L) in combination with the GetKeyState() function:
#If GetKeyState("Alt", "p")
Space & c::Traytip,, % a_thishotkey
#If
or you can use the Keywait command:
!space::
keywait, c, d, t0.6
If ErrorLevel
Traytip,, Alt and space
Else
Traytip,, Alt space and c
Return
This will also trigger an Alt+space outcome after 0.6 seconds if you don't press C.
If that is undesirable you can write it like this:
!space::
keywait, c, d, t0.6
If (!ErrorLevel) {
Traytip,, Alt space and c
Sleep, 2000
Traytip,, % a_thishotkey
} Return
!ErrorLevel means "not ErrorLevel"