How do I press 2 non modifier keys to do something in AHK with minimal side effects? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pharmokan
Posts: 4
Joined: 24 May 2018, 15:10

How do I press 2 non modifier keys to do something in AHK with minimal side effects?

24 May 2018, 15:22

I want to press F + J to do MsgBox for example,
how do I do it minimizing key delay and unintended behavior when I type regularly while still maintaining this functionality in AHK?
pharmokan
Posts: 4
Joined: 24 May 2018, 15:10

Re: How do I press 2 non modifier keys to do something in AHK with minimal side effects?

24 May 2018, 15:37

swagfag wrote:

Code: Select all

f & j::MsgBox % "something"
f key doesn't work now. :facepalm:
OCP
Posts: 98
Joined: 28 Mar 2018, 19:28

Re: How do I press 2 non modifier keys to do something in AHK with minimal side effects?  Topic is solved

24 May 2018, 15:48

try to add ~ before your f and j

Code: Select all

; as a hotkey it triggers a msgbox
~f & ~j:: MsgBox, hi 
return
pharmokan
Posts: 4
Joined: 24 May 2018, 15:10

Re: How do I press 2 non modifier keys to do something in AHK with minimal side effects?

24 May 2018, 16:16

OCP wrote:try to add ~ before your f and j

Code: Select all

; as a hotkey it triggers a msgbox
~f & ~j:: MsgBox, hi 
return
COOL! and lets say i push those keys while a text cursor is active in notepad for example, f and j are typed out and then msgbox comes up
so if i want to make sure the f and j keys dont get typed out, would this be the logical solution:

Code: Select all

; as a hotkey it triggers a msgbox
~f & ~j::
send {Backspace}{Backspace}
MsgBox, hi 
return
Thanks for your help.
OCP
Posts: 98
Joined: 28 Mar 2018, 19:28

Re: How do I press 2 non modifier keys to do something in AHK with minimal side effects?

24 May 2018, 16:23

not sure if i understand you but here is a few examples

Code: Select all

; as a hotkey it triggers a msgbox
~f & ~j:: MsgBox, hi 
return 

;as a string it replaces text fj for MsgBox
:R:fj::MsgBox 

; as a hotkey that only works if a window is active
#IfWinActive ahk_class yourwindowname
~f & ~j:: MsgBox, hi 
return 
pharmokan
Posts: 4
Joined: 24 May 2018, 15:10

Re: How do I press 2 non modifier keys to do something in AHK with minimal side effects?

24 May 2018, 16:42

OCP wrote:not sure if i understand you but here is a few examples

Code: Select all

; as a hotkey it triggers a msgbox
~f & ~j:: MsgBox, hi 
return 

;as a string it replaces text fj for MsgBox
:R:fj::MsgBox 

; as a hotkey that only works if a window is active
#IfWinActive ahk_class yourwindowname
~f & ~j:: MsgBox, hi 
return
sorry for not being clear. i found this final snippet to be satisfactory. thanks for your help, I wasn't expecting to be helped this fast. I really appreciate it.

Code: Select all

~f & ~j::
send {LCtrl Down}z{LCtrl Up}
sleep 50
MsgBox, hi
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, vikasgandhi and 332 guests