Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Execute multiple hotkeys under a specific program
#1
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? Huh 

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

#2
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 .
#3
Thanks for your reply, the above is an example, I want to know how to implement multiple hotkey functions in a QM file.  Exclamation

Ahk is simpler in some aspects, I hope to run the ahk code in QM and complement each other.
#4
the only reliable way i can think of is using a filter function and separate trigger function

Function FF_Notepad
Code:
Copy      Help
;/
;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     Help - how to add the trigger to the macro
Code:
Copy      Help
out "F6"
_s="http://quickmacros.com"
paste _s

Function F7_Notepad
Trigger F7 //FF_Notepad     Help - how to add the trigger to the macro
Code:
Copy      Help
out "F7"
_s="http://bing.com"
paste _s

Function F8_Notepad
Trigger F8 //FF_Notepad     Help - how to add the trigger to the macro
Code:
Copy      Help
out "F8"
_s="http://google.com"
paste _s
#5
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"     Help - how to add the trigger to the macro
Code:
Copy      Help
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
#6
thank you very much, Heart

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  Smile

Unable to generate exe format?   Huh
#7
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"     Help - how to add the trigger to the macro
Code:
Copy      Help
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.
#8
In the code above, how to set a combination hotkey? For example: ctrl+F6, ctrl+F7, ctrl+F8   Huh


Forum Jump:


Users browsing this thread: 4 Guest(s)