Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
run macro in background (activate chrome window on keypress)
#1
I am sorry, this has been asked before but I couldn't find a clear explanation.

I have the following very simple code:

Macro chrome_refresher
Trigger CSF5     Help - how to add the trigger to the macro
Code:
Copy      Help
;/exe 2
int w=win("Chrome" "Chrome_WidgetWin_1")
act w

key F5          ;; F5

act


It is set to run when CTRL+SHIFT+F5 is pressed.
The code should run in the background and no matter in which application I am, when I press the key combination the code above is executed. (activating chrome window, send F5 key and then go back to previous window).

I mainly I will be using the code above when I am in one of my code editors: Webuilder, SublimeText or Notepad++.
But I might be using the macro from other programs (office, notepad, etc...) that's why I don't want to limit it to my editors but make this a 'global' macro.

Is it possible to keep the macro running in the background within windows?
The macro is called ""chrome_refresher", I would like to see it in my windows task manager running in the background as "chrome_refresher" when looking in the tab "Processes".

At the moment the macro runs briefly, with that I mean, the name "chrome_refresher" pops up briefly in my "Windows Task Manager" in the tab "Processes" but then closes/de-activates itself after a second.
I have set the option "Run in seperate process" in "Macro Properties" and UAC as "Administrator", but it still doesn't work.

I read in another topic, that I must make a function of the macro, but I didn't understand fully what to do after I make function the code.

(To avoid misunderstanding, I want to run the compiled .exe in the background)
#2
Code:
Copy      Help
;/exe 2

__RegisterHotKey hk1.Register(0 1 MOD_CONTROL|MOD_SHIFT VK_F5)
;also can register more hotkeys, for example
;__RegisterHotKey hk2.Register(0 2 MOD_CONTROL|MOD_SHIFT VK_F6)
;...

MSG m
rep
,if(GetMessage(&m 0 0 0)<1) break
,sel m.message
,,case WM_HOTKEY
,,sel m.wParam
,,,case 1 ;;Ctrl+Shift+F5 pressed
,,,mac "Function_that_does_something_on_Ctrl_Shift_F5"
,,,
,,,;case 2
,,,;mac "Function_that_does_something_on_Ctrl_Shift_F6"
,,,
,,,;...
,,,
,DispatchMessage &m

;BEGIN PROJECT
;main_function  Macro1990
;exe_file  $my qm$\Macro1990.qmm
;flags  6
;guid  {160D7E4C-0CFC-47B2-8C3A-91C5ED7F9257}
;END PROJECT
#3
Thank you!

It works! But it refreshes to many times (as long as I keep the CTRL+SHIFT pressed it keeps refreshing resulting in flickering kind of behaviour => Activating chrome, sending F5, go back to previous window then activating chrome etc...).
Is there a way that => mac "Function_that_does_something_on_Ctrl_Shift_F5" only runs once.
I tried to add "1" next to "rep" but that didn't work.
#4
Look in Properties, Function properties.
#5
Yes that was it!!

Thank you!!!!
#6
I totally forgot about this example and this example works great.
The exe is running in the background and triggers on CTRL+F5.

But now I want to unregister and register a new hotkey while the executable is running.

So I need something like this added to the macro-code above (and then compile it to exe).

Code:
Copy      Help
sel...
  case ...
  hk1.Unregister
  hk1.Register(...)

And the code that sends the code to trigger the unregister/register 'hk1' is executed from another macro.

- What is the syntax to initiate the unregister/register 'hk1' in the other (external) macro
- What do I need in the main-code to process the unregister and register, specifically the 'sel' and 'case' part
#7
Let other macro post a message to this thread. If using message loop like in previous example, other macro must know thread id. Probably easier to use a hidden dialog instead.
Function dialog_register_hotkey_from_other_macro
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("" &dialog_register_hotkey_from_other_macro 0 0 128)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "dialog_register_hotkey_from_other_macro"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030601 "*" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,__RegisterHotKey- hk1.Register(hDlg 1 MOD_CONTROL|MOD_SHIFT VK_F5)
,
,case WM_APP+177
,out "unregister/register hotkey here"
,
,case WM_HOTKEY
,sel wParam
,,case 1
,,out "Ctrl+Shift+F5 pressed"
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Macro Macro2122
Code:
Copy      Help
int w=win("dialog_register_hotkey_from_other_macro" "#32770")
if(!w) ret
SendMessage w WM_APP+177 0 0
#8
YES!! this works beautifully!!!!
THANK YOU!!!
#9
I was trying to use this but instead of F5 I wanted to use the key "R".
I read in MSDN that the syntax is the same: http://msdn.microsoft.com/en-us/library/...s.60).aspx, but apparently quickmacros isn't liking it. I tried with other keys like "SPACE" and they worked, only letters don't.

Can you help please?
#10
Letter keys don't have VK_ constants like VK_F5. Use character code like 'A'.

http://www.quickmacros.com/help/Tables/ ... LKEYS.html
#11
Thanks!


Forum Jump:


Users browsing this thread: 1 Guest(s)