Posts: 1,336
Threads: 61
Joined: Jul 2006
i have a few questions concerning toolbars and functions that run from a toolbar that are window specific.
#1
Is there a way 2 only allow 1 function 2 to run on a window.Meaning i have a toolbar that works with mutiple windows of the same name and class,or simuliar names.what i am trying 2 do is once a function is running on a specific window not allow another function 2 run on that specific window until the currently running function has stopped.
#2 with using get prop and set prop the function stops but if there is a wait command in the code it may take some time 2 stop.Is there a way 2 use get prop and set prop and have the function stop as soon as the command is given?meaning i have the set prop stopping the function from a button on the toolbar,but i need it 2 stop as soon as the button is clicked.
#3
i have used the status bar in samples 2 and attached it 2 the same window but sometimes when i send a message 2 the control if another window is active it places the message on that window instead of the intended window.Is there a way 2 fix it so it will send the message 2 the intended staus bar?
Posts: 12,071
Threads: 140
Joined: Dec 2002
#1. Difficult. Maybe some ideas will come if you show all the code.
#2. If it is a simple wait command (not "wait for"), instead use wait for variable.
#3. You can change toolbar window name with setwintext.
Posts: 116
Threads: 19
Joined: Nov 2006
This is for your toolbar (Dont run more then one Macro)
Create this function
Function: IsFunctionRunning
function# $functionname
;Returns 1 if function is running, 0 if not.
;EXAMPLE
;if(IsFunctionRunning("MyFunc"))
,;out "MyFunc is running"
int i n=EnumQmThreads(0 0 0 0)
ARRAY(QMTHREAD) a.create(n)
for i 0 EnumQmThreads(&a[0] n 0 0)
,_s.getmacro(a[i].qmitemid 1)
,if(_s=functionname) ret 1
Macro or Function in Toolbar:
rep 10
,if(IsFunctionRunning("type in function here"))
,,out "Function is Running" ;;use this to test
,;;Add what you would like the function to do if this function is already running
You can either do this OR Ctrl+P and set function to single instance.
8)
Posts: 1,336
Threads: 61
Joined: Jul 2006
toolbar
Menu1 :int+ g_tbwindow=GetWindow(val(_command) GW_OWNER); mac "Menu1
Menu2 :int+ g_tbwindow=GetWindow(val(_command) GW_OWNER); mac "Menu2"
Stop Macro :mac "stop" "" SetProp(GetWindow(val(_command) GW_OWNER) "running" 0) * close.ico
menu
Function1 :mac "Function1" "" g_tbwindow
Function2 :mac "Function2" "" g_tbwindow
Function3 :mac "Function3" "" g_tbwindow
ect.
function
int w1;err
w1=g_tbwindow
SetProp(w1 "running" 1)
spe
rep
,if(!GetProp(w1 "running")) end
wait command is 0 WV
Posts: 1,336
Threads: 61
Joined: Jul 2006
MR b ty 4 your response i tried that but that won't work for what i am trying 2 do. i don't want 2 stop that function from running on another window.What i want 2 do is stop any other function from running on the specific window that a function is already running on.
Posts: 116
Threads: 19
Joined: Nov 2006
I think i got what you need.
Toolbar
STOP ALL MACROS RUNNING ON THIS TOOLBAR :SetProp(GetWindow(TriggerWindow GW_OWNER) "x" 0) * close.ico
;;;This is toolbar that will stop all macros ran from the toolbar it was started from.
Function:
int w1
w1=win("Notepad");err
act w1
hid w1
hid- w1
SetProp(w1 "x" 1)
rep
,;;YOUR CODE
,if(!GetProp(w1 "x"))end;; if the stop function in your toolbar is pressed then it will stop all
,;functions funning on the window.
Try that Bro.
8)
Posts: 1,336
Threads: 61
Joined: Jul 2006
again ty for your response.I have no problem stopping the function with the code i used.I have also tried your way also both work.But the problem is if i have a wait command of any type mainly using 0 WV command the function won't stop until the the window it is waiting 4 appears.So i was trying 2 figure out a way to stop it as soon as i click the x on the toolbar no matter what using get prop and set prop
Posts: 12,071
Threads: 140
Joined: Dec 2002
Divide single long wait into many small wait:
rep
,wait 0.2 WV "window"
,err
,,if(!GetProp(w1 "x"))end
,,continue
,break
Posts: 116
Threads: 19
Joined: Nov 2006
try this
wait 10 WA "Notepad";if(!GetProp(w1 "x"))end
8)
Posts: 1,336
Threads: 61
Joined: Jul 2006
is this a seperate repeat apart from the main repeat?
Posts: 1,336
Threads: 61
Joined: Jul 2006
ok that work perfectly G!!! ty vm
Any thoughts about my oyher 2 questions?
Posts: 1,336
Threads: 61
Joined: Jul 2006
here's a thought could this be done
the toolbar that is a status bar if i changed the name of each 1 on each window and then when a function tried on a specific window it would look at the status bar and if it said running on that status bar the function would not run.Is i on the right track?
Posts: 1,336
Threads: 61
Joined: Jul 2006
hey Gintaras
not sure if this can be but is it possible 2 do this?
int hwnd=win("TB STATUSBAR" "QM_toolbar")<---- on a specific window like (w1)
see most of the time i don't need 2 do it but if another window that also has this status bar becomes active it will get that handle instead.
Posts: 12,071
Threads: 140
Joined: Dec 2002
When you call
int hwnd=win("TB STATUSBAR" "QM_toolbar")
, do you know the handle of the owner window? If yes, try this
int hwnd=win("TB STATUSBAR" "QM_toolbar" "" 64 w1 0)
It finds toolbar whose owner window handle is w1.
Posts: 1,336
Threads: 61
Joined: Jul 2006
Thank very much Gintaras that was it, works perfectly!!!!.Now i have accomplished all my questions.
Posts: 56
Threads: 14
Joined: Jul 2008
BenJamin Wrote:I think i got what you need.
Toolbar
STOP ALL MACROS RUNNING ON THIS TOOLBAR :SetProp(GetWindow(TriggerWindow GW_OWNER) "x" 0) * close.ico
;;;This is toolbar that will stop all macros ran from the toolbar it was started from.
Function:
int w1
w1=win("Notepad");err
act w1
hid w1
hid- w1
SetProp(w1 "x" 1)
rep
,;;YOUR CODE
,if(!GetProp(w1 "x"))end;; if the stop function in your toolbar is pressed then it will stop all
,;functions funning on the window.
Try that Bro.
DOES THIS CODE WORK FOR THE NEWEST VERSION OF QUICKMACROS? CAUSE IT DONT WORK FOR ME.
Posts: 12,071
Threads: 140
Joined: Dec 2002
If here GetWindow is used for a toolbar, it does not work in new QM versions. Use GetToolbarOwner. Some examples are somewhere in forum.
|