Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controlling Looping Macro from Tray
#2
Exits the rep loop when the tray icon left-clicked. The test window here is a Notepad message box.

Macro Macro274
Code:
Copy      Help
str Icon = "$qm$\paste.ico"
int count = 0
str s = 0
int stop
Tray t.AddIcon(Icon "0" 0 &sub.Callback_Tray_AddIcon)
rep
,0.1
,if(stop) break
,int w1=win("Notepad" "#32770")
,if(w1=0) continue
,clo w1
,count + 1
,s = count
,t.AddIcon(Icon s)


#sub Callback_Tray_AddIcon v
function Tray&x message

;Callback function for Tray.AddIcon.
;Called for each received message - when tray icon clicked, or mouse moved.

;x - reference to this object.
;message - mouse message (WM_MOUSEMOVE, WM_LBUTTONDOWN, etc).


;OutWinMsg message 0 0 ;;uncomment to see received messages

sel message
,case WM_LBUTTONUP
,out "left click"
,;out x.param
,
,;exit the above rep loop
,stop=1
,
,case WM_RBUTTONUP
,out "right click"
,
,case WM_MBUTTONUP
,out "middle click"
,

Or Ctrl+click the tray icon to end the macro. Then don't need all this, just use your first posted macro without changes.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)