Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with window specific toolbar functions
#1
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?
#2
#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.
#3
This is for your toolbar (Dont run more then one Macro)

Create this function

Function: IsFunctionRunning

Code:
Copy      Help
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:
Code:
Copy      Help
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.
Smile 8)
#4
toolbar
Code:
Copy      Help
Menu1 :int+ g_tbwindow=GetWindow(val(_command) GW_OWNER); mac "Menu1
Code:
Copy      Help
Menu2 :int+ g_tbwindow=GetWindow(val(_command) GW_OWNER); mac "Menu2"
Code:
Copy      Help
Stop Macro :mac "stop" "" SetProp(GetWindow(val(_command) GW_OWNER) "running" 0)  * close.ico
menu
Code:
Copy      Help
Function1 :mac "Function1" "" g_tbwindow
Code:
Copy      Help
Function2 :mac "Function2" "" g_tbwindow
Code:
Copy      Help
Function3 :mac "Function3" "" g_tbwindow
ect.
function
Code:
Copy      Help
int w1;err
w1=g_tbwindow
SetProp(w1 "running" 1)
spe
rep
,if(!GetProp(w1 "running")) end
wait command is 0 WV
#5
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.
#6
I think i got what you need.

Toolbar

Code:
Copy      Help
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:
Code:
Copy      Help
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.
Smile 8)
#7
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
#8
Divide single long wait into many small wait:

Code:
Copy      Help
rep
,wait 0.2 WV "window"
,err
,,if(!GetProp(w1 "x"))end
,,continue
,break
#9
try this
Code:
Copy      Help
wait 10 WA "Notepad";if(!GetProp(w1 "x"))end
Smile 8)
#10
is this a seperate repeat apart from the main repeat?
#11
ok that work perfectly G!!! ty vm
Any thoughts about my oyher 2 questions?
#12
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?
#13
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.
#14
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.
#15
Thank very much Gintaras that was it, works perfectly!!!!.Now i have accomplished all my questions. Big Grin
#16
BenJamin Wrote:I think i got what you need.

Toolbar

Code:
Copy      Help
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:
Code:
Copy      Help
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.
#17
If here GetWindow is used for a toolbar, it does not work in new QM versions. Use GetToolbarOwner. Some examples are somewhere in forum.


Forum Jump:


Users browsing this thread: 1 Guest(s)