Cntl+Alt+Key

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
POSAM-Ron
Posts: 12
Joined: 02 Sep 2016, 11:35

Cntl+Alt+Key

14 Jan 2017, 12:18

How do I trigger a keycode > Cntl+Alt+Key < where "key" is any alphabetic character?
User avatar
boiler
Posts: 17390
Joined: 21 Dec 2014, 02:44

Re: Cntl+Alt+Key

14 Jan 2017, 12:35

If by "any", you want all sets of those modifier keys and letters to trigger the same label:

Code: Select all

Loop, 26
{
	Name := chr(96 + A_Index)
	Hotkey ^!%Name%, MyLabel
}
return

MyLabel:
Soundbeep
return
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Cntl+Alt+Key

14 Jan 2017, 17:13

e.g. hotkeys:

Code: Select all

^!a::
^!b::
^!c::
^!d::
^!e::
^!f::
^!g::
^!h::
^!i::
^!j::
^!k::
^!l::
^!m::
^!n::
^!o::
^!p::
^!q::
^!r::
^!s::
^!t::
^!u::
^!v::
^!w::
^!x::
^!y::
^!z::
vLetter := SubStr(A_ThisHotkey, 1-1)
MsgBox % A_ThisHotkey " " vLetter
Return
e.g. generate the hotkey labels:

Code: Select all

q::
vOutput := ""
Loop, 26
vOutput .= "^!" Chr(96+A_Index) "::`r`n"
Clipboard := vOutput
MsgBox % "done"
Return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
POSAM--Ron

Re: Cntl+Alt+Key

16 Jan 2017, 08:36

POSAM-Ron wrote:How do I trigger a keycode > Cntl+Alt+Key < where "key" is any alphabetic character?
----------------------------------------

To > just me , boiler , jeeswg - Monday, 2017 January 16 - 21:19:47 (day#016)

* Thank you > just me , boiler , jeeswg < for your suggestions * Having done some programming in the 70's - 90's , I appreciate how powerful this scripted language can be * It's certainly more versitile than a tab-bar/menu driven program * For the novice (to AHK) like me , though ; it takes some time to do even the basics *

* I actually tried > ^!a:: send, word < but it didn't work ; probably because I may have fiddled with the "New AutoHotkey Script.ahk" file and thought the "send" line was the problem * Thanks for getting me through the obvious * I do have one request though > Please include an obvious example or two for using " ^! " and " +^! " in the > AutoHotkey Beginner Tutorial by tidbit < section of the manual * This may help the novice get started with a particular usage of the program *

* Please help me get started with the following specific usage * I want to use the keyboard to "send" Greek characters such as ( α ) to a text editor * However , > ^!a:: send, α < doesn't work * Inserting unicode " 03B1 " works and inserts (α) directly into the text * However , using > ^!a:: send, α < in the script converts " 03B1 " to UTF-8 " CEB1 " in the (.AHK) file which inserts jibberish into the text when you press > Cntl+Alt+a * How can I get the "^!a" key to insert UNICODE 03B1 (U+03B1) into the target text ?*

* It seems that this unicode stuff , though intellectually quite simple , is quite complex with its code pages , and unicode code points , and UTF-8 encoding *

* Thanks for any help you can give * A simple example will do *

POSAM-Ron
User avatar
boiler
Posts: 17390
Joined: 21 Dec 2014, 02:44

Re: Cntl+Alt+Key

16 Jan 2017, 09:35

Make sure you have installed the Unicode (not ANSI) version of AHK. Also see this thread.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Cntl+Alt+Key

16 Jan 2017, 13:20

I believe that the ahk file must be saved in the UTF-8 or UTF-16 LE ('Unicode' in Notepad) encoding.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
POSAM--Ron

Re: Cntl+Alt+Key

17 Jan 2017, 13:38

* Thanks , boiler , for the hint > https://autohotkey.com/board/topic/1132 ... e-letters/
* Sending unicode characters is now working * I have one more request >

* Is it possible to do this > cntl+alt+Numpad1 & cntl+alt+Numpad4:: send {U+00BC} ?* This would send (¼) *

POSAM-Ron
User avatar
boiler
Posts: 17390
Joined: 21 Dec 2014, 02:44

Re: Cntl+Alt+Key

17 Jan 2017, 16:01

I would think you should be able to do that. Use ^! Numpad1 & ^!Numpad4
POSAM-Ron
Posts: 12
Joined: 02 Sep 2016, 11:35

Re: Cntl+Alt+Key

18 Jan 2017, 12:06

Hi boiler - 2017-01-19
boiler wrote:I would think you should be able to do that. Use ^! Numpad1 & ^!Numpad4
* Thanks for your immediate reply * The above code fails to work (even without the extra space) * I have included an image that I get * Here is the script's context >

################

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

msgbox This AutoHotkey file sends some common math symbols

^!Numpad1 & ^!Numpad4:: send {U+00BC}

#################

* Here is the image >

<img src="file:///D:/Temp/Math%20Symbols%20-%20Msgbox.gif"></img>

#################

* Can you please try it *

P.S. - Am I misusing "msgbox"

Thanks

POSAM-Ron
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Cntl+Alt+Key

18 Jan 2017, 12:27

Code: Select all

^!Numpad1:: send {U+00BC}
^!Numpad4:: send {U+00BC}
^!NumpadEnd:: send {U+00BC}
^!NumpadLeft:: send {U+00BC}

;be careful because it's easy to trigger ctrl+alt+numpad(arrow) which flips the screen,
;you might want to add in:
^!NumpadUp:: Return
^!NumpadDown:: Return
^!NumpadRight:: Return
Return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
POSAM-Ron
Posts: 12
Joined: 02 Sep 2016, 11:35

Re: Cntl+Alt+Key

19 Jan 2017, 11:16

jeeswg wrote:

Code: Select all

^!Numpad1:: send {U+00BC}
^!Numpad4:: send {U+00BC}
^!NumpadEnd:: send {U+00BC}
^!NumpadLeft:: send {U+00BC}

;be careful because it's easy to trigger ctrl+alt+numpad(arrow) which flips the screen,
;you might want to add in:
^!NumpadUp:: Return
^!NumpadDown:: Return
^!NumpadRight:: Return
Return
###############

Hi jeeswg - 2017-01-19

* Thanks for your immediate reply * I have tried the code above that you recommended * Unfortunately , it locks-in both > ^!Numpad1 < and > ^!Numpad4 * As expected , > ^!Numpad1 < gives a (¼) and > ^!Numpad4 < gives a second (¼) * Thus , there is no-way to send (½) and (⅓) and then (⅔) without using another > ^!Numpad# < that's unrelated * Since unicode specifies several fractions , the most reasonable way to send the desired fraction is to specify a combination of two keys * To remain isolated from normal keypad operations , the > ctrl+alt+numpad(#1) & ctrl+alt+numpad(#2) < would be the way to go * That way ALL unicode fractions (simple) could be sent without overlap *

* Is there any (temporary) workaround to this dilemma ?* It would be best if a "combination of two keys" could be implemented in the > shift-ctrl-alt < domain * Is this a possibility ?*

* Again , thanks for your reply * I don't mean to be a bother *

POSAM-Ron
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Cntl+Alt+Key

19 Jan 2017, 12:43

I like this idea, and the code could be useful to me.
This is working really nicely now.

Code: Select all

^!NumpadUp:: Return
;^!NumpadLeft:: Return
;^!NumpadDown:: Return
^!NumpadRight:: Return

^!Numpad1::
^!Numpad2::
^!Numpad3::
^!Numpad4::
^!NumpadEnd:: ;1
^!NumpadDown:: ;2
^!NumpadPgDn:: ;3
^!NumpadLeft:: ;4

vIsDown1 := vIsDown2 := vIsDown3 := vIsDown4 := 0
vList := "End,Down,PgDn,Left"
Loop, Parse, vList, `,
if InStr(A_ThisHotkey, A_Index) OR InStr(A_ThisHotkey, A_LoopField) OR (GetKeyState("Numpad" A_Index, "p") OR GetKeyState("Numpad" A_LoopField, "p"))
vIsDown%A_Index% := 1

vOutput := ""
(vIsDown1 AND vIsDown2) ? (vOutput := "U+00BD") ;1/2
(vIsDown1 AND vIsDown3) ? (vOutput := "U+2153") ;1/3
(vIsDown1 AND vIsDown4) ? (vOutput := "U+00BC") ;1/4
(vIsDown2 AND vIsDown3) ? (vOutput := "U+2154") ;2/3
if !(vOutput = "")
Send {%vOutput%}
JEE_RetX()
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
POSAM-Ron
Posts: 12
Joined: 02 Sep 2016, 11:35

Re: Cntl+Alt+Key

20 Jan 2017, 08:10

jeeswg wrote:I like this idea, and the code could be useful to me.
This is working really nicely now.

Code: Select all

^!NumpadUp:: Return
;^!NumpadLeft:: Return
;^!NumpadDown:: Return
^!NumpadRight:: Return

^!Numpad1::
^!Numpad2::
^!Numpad3::
^!Numpad4::
^!NumpadEnd:: ;1
^!NumpadDown:: ;2
^!NumpadPgDn:: ;3
^!NumpadLeft:: ;4

vIsDown1 := vIsDown2 := vIsDown3 := vIsDown4 := 0
vList := "End,Down,PgDn,Left"
Loop, Parse, vList, `,
if InStr(A_ThisHotkey, A_Index) OR InStr(A_ThisHotkey, A_LoopField) OR (GetKeyState("Numpad" A_Index, "p") OR GetKeyState("Numpad" A_LoopField, "p"))
vIsDown%A_Index% := 1

vOutput := ""
(vIsDown1 AND vIsDown2) ? (vOutput := "U+00BD") ;1/2
(vIsDown1 AND vIsDown3) ? (vOutput := "U+2153") ;1/3
(vIsDown1 AND vIsDown4) ? (vOutput := "U+00BC") ;1/4
(vIsDown2 AND vIsDown3) ? (vOutput := "U+2154") ;2/3
if !(vOutput = "")
Send {%vOutput%}
JEE_RetX()
##################

Thank you jeeswg - 2017-01-20

* Thank you for sending this "workaround" code * Apparently , it works for you and , therefore , it works * However , it doesn't work for me probably because I am-not depressing the correct keys * I don't quite understand much of the code but I tried some combinations on the keypad >

^!1 & ^!2 > sends nothing
^!end & ^!down(arrow) > sends nothing
1 & 2 > sends nothing
end & down(arrow) > sends nothing
others

* Of course , I should know what key combination to use just by looking at the code * However , I admit that I do-not know the AHK scripting instructions well enough to decipher the code * I should spend some time becoming proficient *

* In the meantime , could you please tell me what key combinations I should use to get the 4 unicode fractions that you list * I look forward to adding to the code to install "sends" for the total of 37 fractions published in the unicode *

Thanks again

POSAM-Ron
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Cntl+Alt+Key

20 Jan 2017, 09:17

Ctrl+Alt+Numpad1 and Ctrl+Alt+Numpad2.
4 keys pressed down at the same time, Ctrl, Alt, Numpad1, Numpad2.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
POSAM-Ron
Posts: 12
Joined: 02 Sep 2016, 11:35

Re: Cntl+Alt+Key

20 Jan 2017, 13:46

POSAM-Ron wrote:
jeeswg wrote:I like this idea, and the code could be useful to me.
This is working really nicely now.

Code: Select all

^!NumpadUp:: Return
;^!NumpadLeft:: Return
;^!NumpadDown:: Return
^!NumpadRight:: Return

^!Numpad1::
^!Numpad2::
^!Numpad3::
^!Numpad4::
^!NumpadEnd:: ;1
^!NumpadDown:: ;2
^!NumpadPgDn:: ;3
^!NumpadLeft:: ;4

vIsDown1 := vIsDown2 := vIsDown3 := vIsDown4 := 0
vList := "End,Down,PgDn,Left"
Loop, Parse, vList, `,
if InStr(A_ThisHotkey, A_Index) OR InStr(A_ThisHotkey, A_LoopField) OR (GetKeyState("Numpad" A_Index, "p") OR GetKeyState("Numpad" A_LoopField, "p"))
vIsDown%A_Index% := 1

vOutput := ""
(vIsDown1 AND vIsDown2) ? (vOutput := "U+00BD") ;1/2
(vIsDown1 AND vIsDown3) ? (vOutput := "U+2153") ;1/3
(vIsDown1 AND vIsDown4) ? (vOutput := "U+00BC") ;1/4
(vIsDown2 AND vIsDown3) ? (vOutput := "U+2154") ;2/3
if !(vOutput = "")
Send {%vOutput%}
JEE_RetX()
##################

Thank you jeeswg - 2017-01-20

* Thank you for sending this "workaround" code * Apparently , it works for you and , therefore , it works * However , it doesn't work for me probably because I am-not depressing the correct keys * I don't quite understand much of the code but I tried some combinations on the keypad >

^!1 & ^!2 > sends nothing
^!end & ^!down(arrow) > sends nothing
1 & 2 > sends nothing
end & down(arrow) > sends nothing
others

* Of course , I should know what key combination to use just by looking at the code * However , I admit that I do-not know the AHK scripting instructions well enough to decipher the code * I should spend some time becoming proficient *

* In the meantime , could you please tell me what key combinations I should use to get the 4 unicode fractions that you list * I look forward to adding to the code to install "sends" for the total of 37 fractions published in the unicode *

Thanks again

POSAM-Ron
##############

* Thanks jeeswg , it works * It's not as easy as pressing "numpad#1" then "numpad#2" seperately , but it will do * I didn't think to try all 4 keys simultaneously *

* I hope I can understand the code enough to insert several other unicode fractions *

* Please consider enabling the combination > "numpad#1 & numpad#2" in the shift-ctrl-alt domain * Thanks !* I can submit a request post if necessary *

POSAM-Ron
POSAM-Ron
Posts: 12
Joined: 02 Sep 2016, 11:35

Re: Cntl+Alt+Key

24 Jan 2017, 13:08

; CAN ANYONE EXPLAIN WHY THIS CODE FAILS (SEE BELOW)?

; ############################ AHK Fractions.ahk >

; Uses (CTRL & ALT & numpad#1 & numpad#2) to send that fraction to your text editor

^!NumpadEnd:: ;1
^!NumpadDown:: ;2
^!NumpadPgDn:: ;3
^!NumpadLeft:: ;4
; ^!NumpadCenter:: ;5 ; not needed
^!NumpadRight:: ;6
^!NumpadHome:: ;7
^!NumpadUp:: ;8
^!NumpadPgUp:: ;9
^!NumpadIns:: ;0

^!Numpad1::
^!Numpad2::
^!Numpad3::
^!Numpad4::
^!Numpad5::
^!Numpad6::
^!Numpad7::
^!Numpad8::
^!Numpad9::
^!Numpad0::

vIsDown1 := vIsDown2 := vIsDown3 := vIsDown4 := vIsDown5 := vIsDown6 := vIsDown7 := vIsDown8 := vIsDown9 := vIsDown0 := 0

; ERROR APPEARS TO BE BELOW v

vList := "End,Down,PgDn,Left,5,Right,Home,Up,Pgup,Ins"
Loop, Parse, vList, `,
if InStr(A_ThisHotkey, A_Index) OR InStr(A_ThisHotkey, A_LoopField) OR (GetKeyState("Numpad" A_Index, "p") OR GetKeyState("Numpad" A_LoopField, "p"))
vIsDown%A_Index% := 1
vOutput := ""

; ERROR APPEARS TO BE ABOVE ^

(vIsDown1 AND vIsDown4) ? (vOutput := "U+00BC") ; 1/4
(vIsDown1 AND vIsDown2) ? (vOutput := "U+00BD") ; 1/2
(vIsDown3 AND vIsDown4) ? (vOutput := "U+00BE") ; 3/4
(vIsDown1 AND vIsDown3) ? (vOutput := "U+2153") ; 1/3
(vIsDown2 AND vIsDown3) ? (vOutput := "U+2154") ; 2/3
(vIsDown1 AND vIsDown8) ? (vOutput := "U+215B") ; 1/8
(vIsDown3 AND vIsDown8) ? (vOutput := "U+215C") ; 3/8
(vIsDown5 AND vIsDown8) ? (vOutput := "U+215D") ; 5/8
(vIsDown7 AND vIsDown8) ? (vOutput := "U+215E") ; 7/8

(vIsDown1 AND vIsDown7) ? (vOutput := "U+2150") ; 1/7
(vIsDown1 AND vIsDown9) ? (vOutput := "U+2151") ; 1/9
(vIsDown1 AND vIsDown0) ? (vOutput := "U+2152") ; 1/10
(vIsDown1 AND vIsDown5) ? (vOutput := "U+2155") ; 1/5
(vIsDown2 AND vIsDown5) ? (vOutput := "U+2156") ; 2/5
(vIsDown3 AND vIsDown5) ? (vOutput := "U+2157") ; 3/5
(vIsDown4 AND vIsDown5) ? (vOutput := "U+2158") ; 4/5
(vIsDown1 AND vIsDown6) ? (vOutput := "U+2159") ; 1/6
(vIsDown5 AND vIsDown6) ? (vOutput := "U+215A") ; 5/6

if !(vOutput = "")
Send {%vOutput%}

; ############################ AHK Greek Letters.ahk > ABOVE CODE WORKS INCORRECTLY WHEN SCRIPT BELOW IS PRESENT

; Uses (CTRL & ALT & alphabetic keyboard keys) to send lowercase Greek letters to your text editor

^!a::Send {U+03B1} ; a - alpha
^!b::Send {U+03B2} ; ß - beta

; IT APPEARS THAT THE FRACTION-CODE IS CAPTURING THE GREEK-LETTER-CODE (KEYS ON THE NUMPAD)
; I HAVE BEEN UNABLE TO ISOLATE THE SCRIPT CODE THAT DOES THIS
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Cntl+Alt+Key

24 Jan 2017, 14:54

I couldn't figure it out for a while, then after testing I realised that
Return is needed underneath Send {%vOutput%}.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
POSAM--Ron

Re: Cntl+Alt+Key

28 Jan 2017, 12:59

Thank you - jeeswg - Sunday, 2017 January 29 - 00:37:37 (day#029)

* That was the solution to the problem , all right * The fraction segment of the combined script just kept going and found the first instance/keystroke in the total list that satisfied the key condition and outputed that * That's why it worked without the RETURN in the single FRACTION script but not in the combined script *

* I can't thank you enough for the help you have given me to create these most useful scripts * They are >

FRACTIONS
GREEK LETTERS
MATH SYMBOLS
& all 3 combined

* I would still like to see the AHK program be able to process > ^!NUMERATOR & ^!DENOMINATOR < generally > ^!HOTKEY#1 & ^!HOTKEY#2 < *

* The > ^! < and > +^! < prefixes would enable isolation from other interferring keystrokes (often assigned within another program) *

* Enabling , say , > +^!HOTKEY#1 & ^HOTKEY#2 < and other combinations would even expand the possible combinations *

################ Requests >

* Is there a repository/gallery of spiffy scripts where my 4 scripts can be listed ?* If not , It might be a good idea to have one *

* Is there a means to submit a formal request for a new feature in the AHK program ?*

* I have tried finding these (above) but have-not been able to find them *

################ Acknowledgement >

* Thanks to Teeter for his script "Send Unicode Letters?" at > https://autohotkey.com/board/topic/1132 ... e-letters/ < for his guidance which helped me get going with unicode inserting *

* Thanks to boiler for directing me to Teeter's script code *

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], peter_ahk and 170 guests