In word and other programs when you hold down the alt key and type 0189 on the number keyboard you will get the half inch symbol ½. How can I send this sequence in autohotkey using a hot key
Thanks in advance
Tim
In general: Send, {ASC 00189}
I do it this way:
; ================================== FRACTIONS ==================================
^2::
Send, ½
TrayTip, For 2 Squared,press Ctrl + Shift 2,1,1
Return
^3::
Send, ¾
TrayTip, For 3 Cubed,press Ctrl + Shift 3,1,1
Return
^4::Send, ¼
; ================================== POWERS ==================================
+^0::Send, °
+^1::Send, ¹
+^2::Send, ² ; Shift Control 2#
+^3::Send, ³ ; Shift Control 3#
Ctrl+2 = ½
Ctrl+3 = ¾
Ctrl+4 = ¼
ShiftCtrl + 0 = °
ShiftCtrl + 1 = ¹
ShiftCtrl + 2 = ²
ShiftCtrl + 3 = ³
Related
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
This is a super simple thing I am trying to get my head around
I want to use something like WINKEY + ALT + C to paste ** - words** so that I can sign-off my posts or whatever using the three-key combo
Not sure what exactly you want, maybe something like this?
Press WINKEY + ALT + C to paste the clipboard contents:
#!c::
SendInput, ^v
Return
Press WINKEY + ALT + C to paste "Some random text"
#!c::
SendInput, Some random text
Return
Instead of Sendinput which will type each characters you can use a clipboard paste approach. See for example https://github.com/tdalon/ahk/blob/59a8ab2a8fd497b4a5b5a85e73e32ff95d5d4425/Lib/Clip.ahk
Clip_Paste(sText,restore := True) {
; Syntax: Clip_Paste(sText,restore := True)
If (restore)
ClipBackup:= ClipboardAll
Clipboard := sText
WinClip.Paste()
If (restore)
Clip_Restore(ClipBackup)
} ; eofun
; ---------------------------------------------------------------------------
Clip_Restore(ClipBackup) {
Clip_Wait() ; in order not to overwrite running clipboard action like pasting
Clipboard:= ClipBackup
} ;eofun
; ---------------------------------------------------------------------------
Clip_Wait(){
Sleep, 150
while DllCall("user32\GetOpenClipboardWindow", "Ptr")
Sleep, -1
} ; eofun
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"
My full goal is to be able to hold down Capslock + s, which will convert the keys uiojklm,. to work like the 10-key number pad.
So as a first step, I am trying to map Capslock + s + m to the number 1
SetCapslockState AlwaysOff
Capslock & s::
keywait, m, d, t0.6
If (!ErrorLevel) {
SendInput {1}
} Return
I based my current code off of the answer here: Alt + Space + key in autohotkey
When I press Capslock + s + m, it prints out m1. How do I stop the m from printing?
Here is an alternative solution. You MUST have AutoHotKey_L for this to work since the traditional AutoHotKey does not support #if.
CapsLock & s::
Flag:=!Flag
If (Flag)
TrayTip, AutoHotKey, Numpad ON, 1
Else
TrayTip, AutoHotKey, Numpad OFF, 1
Return
#If (Flag)
m::Send, 0
k::Send, 1
#If
In the first block you toggle a Flag to True/False with CapsLock + s and you show the status with a traytip, then you define the behaviour of certain keys in the next block. Alternatively you could delete the first block and replace the #if (Flag) line with:
#If (GetKeyState("CapsLock", "P") and GetKeyState("s", "P"))
Update:
Tried the following with varying results. The first (commented out) code does use CapsLock + s, but apparently pressing the s key prevents AutoHotKey from seeing certain other key presses (here the letters n,m,i,o,p worked but j,k,l which are on the same hight/scanline on the keyboard were NOT detected)
SetCapsLockState, alwaysoff
/*
Capslock & s::
While, (GetKeyState("CapsLock", "P") and GetKeyState("s", "P"))
{
Input, MyKey, I L1 T0.5
TrayTip, Key:, %MyKey%
if (MyKey = "m")
Send, 1
if (MyKey = "i")
Send, 2
if (MyKey = "k")
Send, 3
if (MyKey = "j")
Send, 4
if (MyKey = "o")
Send, 5
if (MyKey = "p")
Send, 6
}
Return
*/
Just using CapsLock (also on the same like as j,k,l) worked, but that is not what you wanted.
Capslock::
While, (GetKeyState("CapsLock", "P"))
{
Input, MyKey, I L1 T0.5
TrayTip, Key:, %MyKey%
if (MyKey = "m")
Send, 1
if (MyKey = "i")
Send, 2
if (MyKey = "k")
Send, 3
if (MyKey = "j")
Send, 4
if (MyKey = "o")
Send, 5
if (MyKey = "p")
Send, 6
}
Return
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"