Posts: 726
Threads: 99
Joined: Mar 2018
08-16-2018, 01:34 AM
(This post was last modified: 08-16-2018, 03:59 AM by win.)
How to achieve the following aotuhotkey code effect in QM
I tried to set multiple triggers to achieve, but it is more cumbersome, is there a better way?
Thanks in advance
————————————————————————————————
#IfWinActive , ahk_exe notepad.exe
F1::
Send, http://quickmacros.com
Return
F2::
Send, http://bing.com
Return
F3::
send, http://google.com
Return
#IfWinActive
Posts: 1,337
Threads: 61
Joined: Jul 2006
08-16-2018, 03:16 AM
(This post was last modified: 08-16-2018, 03:19 AM by Kevin.)
F1 and F3 are already in use in notepad so will need to use other keys
F2 works F4 F6 F7 F8 are not in use .
Posts: 726
Threads: 99
Joined: Mar 2018
08-16-2018, 03:56 AM
(This post was last modified: 08-16-2018, 04:00 AM by win.)
Thanks for your reply, the above is an example, I want to know how to implement multiple hotkey functions in a QM file.
Ahk is simpler in some aspects, I hope to run the ahk code in QM and complement each other.
Posts: 1,337
Threads: 61
Joined: Jul 2006
the only reliable way i can think of is using a filter function and separate trigger function
Function FF_Notepad
;/
;Each macro or function (key or mouse triggered) that has this filter
;function, will run only if Notepad window is active.
function# iid FILTER&f
if(wintest(f.hwnd "" "Notepad")) ret iid
ret -2
Function F6_Notepad
Trigger F6 //FF_Notepad
out "F6"
_s="http://quickmacros.com"
paste _s
Function F7_Notepad
Trigger F7 //FF_Notepad
out "F7"
_s="http://bing.com"
paste _s
Function F8_Notepad
Trigger F8 //FF_Notepad
out "F8"
_s="http://google.com"
paste _s
Posts: 1,337
Threads: 61
Joined: Jul 2006
08-16-2018, 07:01 AM
(This post was last modified: 08-16-2018, 08:04 AM by Kevin.)
try this .This is a little different has one function that runs in a loop and does actions if F6,F7, or F8 keys are pressed. ends either when the notepad window closes or pause key is pressed.
Macro Notepad Multi Key
Trigger !a"" "Notepad"
int vk w
rep
,w=win("" "Notepad"); if !w;ret
,rep
,,vk=wait(0.3 K)
,,err
,,,w=win("" "Notepad"); if !w; ret
,,,continue
,,break
,if win()!=w
,,act w
,sel vk
,,case VK_F6
,,_s="http://quickmacros.com"
,,paste+ _s
,,case VK_F7
,,_s="http://bing.com"
,,paste+ _s
,,case VK_F8
,,_s="http://google.com"
,,paste+ _s
I cleaned up the code some changed reflected above. Like i said in previous post don't use F1 F3 or F5 as they are already assigned hotkeys in notepad
Posts: 726
Threads: 99
Joined: Mar 2018
08-17-2018, 12:17 AM
(This post was last modified: 08-17-2018, 12:22 AM by win.)
thank you very much,
The code runs a bit wrong. When I open the word and notepad at the same time, I can't input characters in the word, it will automatically switch the window to the word.
Also, I want to know how to set a combination hotkey? For example: ctrl+F6, ctrl+F7, ctrl+F8
Unable to generate exe format?
Posts: 1,337
Threads: 61
Joined: Jul 2006
08-17-2018, 12:25 AM
(This post was last modified: 08-17-2018, 12:48 AM by Kevin.)
cannot duplicate your issue i just ran it with notepad word and wordpad all open only fired and worked on notepad.
found the bug try this
Macro NotepadMultiKey
Trigger !a"" "Notepad"
int vk w
rep
,w=win("" "Notepad"); if !w;ret
,rep
,,vk=wait(0.3 K)
,,err
,,,w=win("" "Notepad"); if !w; ret
,,,continue
,,break
,sel vk
,,case VK_F6
,,if win()!=w; act w
,,_s="http://quickmacros.com"
,,paste+ _s
,,case VK_F7
,,if win()!=w; act w
,,_s="http://bing.com"
,,paste+ _s
,,case VK_F8
,,if win()!=w; act w
,,_s="http://google.com"
,,paste+ _s
sorry posted wrong code corrected now.
and to answer your last question no this cannot be made into an exe in the current format because it uses a qm trigger.
anything with triggers cannot be made into an exe.
Posts: 726
Threads: 99
Joined: Mar 2018
In the code above, how to set a combination hotkey? For example: ctrl+F6, ctrl+F7, ctrl+F8
|