Posts: 197
Threads: 60
Joined: Dec 2013
Hi,
Allow me to explain the cryptic title.
I have a lot of functions that each will activate the same window (I may take this out) and/or find accessible object.
I noticed that activating a 2nd window will change the w count from w to w1,w2,w3...etc. The same happens with accessible objects. This will break my code.
Is there a way to reset the w and a variables so I can always get my code to work on w and a...not w1,w2,w3 and a1,a2,a3...?
Thanks
Posts: 1,335
Threads: 61
Joined: Jul 2006
do you mean window or browser tab?only time i have seen qm do w1 w2 w3 ect is if you already have the w variable declared already if you are using the same window you dont have to use the int w1 instead after you capture the second object in the acc dialog window remove what is says for window and type in w.
acc will use the window handle it has already has instead of getting the window handle again.
example
Function
Function3
int w=win("Mozilla Firefox" "Mozilla*WindowClass" "" 0x4)
Acc a.Find(w "PAGETAB" "Quick Macros Forum • Edit post" "a:class=tabbrowser-tab" 0x1005)
a.DoDefaultAction
Acc a1.FindFF(w "A" "" "onclick=subPanels('attach-panel'); return false;" 0x1004 3)
a1.DoDefaultAction
Posts: 197
Threads: 60
Joined: Dec 2013
I meant the window.
Ya, that's exactly my situation. I have a w declared already. I could skip the duplicate w declaration to avoid w1,w2, but I don't know if that will always work because each function (there are many) does different things and it'll be hard to keep track of all the w,w1,w2, and a,a1,a2...etc
I do know that if I could "reset" the w variable then I can avoid the hassle of w1,w2...for sure. I'm thinking the same thing for accessible object to avoid a1, a2..etc.
Posts: 1,335
Threads: 61
Joined: Jul 2006
do your function perform at the same time or 1 after the other?
you can make the w variable into a global variable
Then that same w variable(window handle) would be available to use in all your functions without declaring it again
it really depends
your could also pass it to the function as an argument when you run the function
read more about functions in qm help
your could pass the handle using mac as well
as well as other ways
there are many things you can do to if your are using the same window and have many functions that are working on that 1 window
Posts: 1,335
Threads: 61
Joined: Jul 2006
somehow i get the feeling you might need to read more in qm help
do you understand what this line does?
int w=win("Mozilla Firefox" "Mozilla*WindowClass" "" 0x4)
this stores the unique window handle of that window(not the name!) in variable w
each window has it's own unique id number .No two windows can have the same id(window handle) .once you have gotten that window handle u can use the w variable in as many statements as you want in that same function
Posts: 197
Threads: 60
Joined: Dec 2013
do your function perform at the same time or 1 after the other?
>>Yes
you can make the w variable into a global variable
Then that same w variable(window handle) would be available to use in all your functions without declaring it again
>>Will try this.
your could also pass it to the function as an argument when you run the function
>>Will learn more.
somehow i get the feeling you might need to read more in qm help
>> I do try, but it's hard for me to find answers there. I often find I can only get solutions by coming to the forum. Just recently, Gintaras gave me an answer that I would never discover on my own. EVER. lol. I had to use a reverse for loop to make array.remove(element) work.
I have coding experience in pascal from highschool from I'm not a coder by trade.
Do you understand what this line does?
int w=win("Mozilla Firefox" "Mozilla*WindowClass" "" 0x4)
>> yes
Is there a way to "reset" the w or a so that teach time I activate a window, it can be referred to as just "w" and each time I find an acc.object, it's just "a"?
I'll try illustrate the problem better.
I need to find an accessible object to select a section of the screen. After that, I MAY or MAY NOT need to grab another accessible object (2nd object), followed again by I MAY or MAY NOT need to grab another accessible object (3rd object).
Depending on what I do, I may need to address that 3rd object as a1 or a2. That's where the code potentially breaks. If I were able to "reset" the a so the reference is always to a - not a1, a2, etc then I will have stability.
Does that make more sense?
Posts: 1,335
Threads: 61
Joined: Jul 2006
even in acc you can reuse that variable. Use Accessible object actions menu instead of find Accessible object,wait
then u can type in the variable you want to use
but i still don't see how using another variable is breaking your code
you can use a1 a2 a3 etc no problem without fail
my guess is you using some other command to check something and forgot to match up the variables
you could do like this
Function
Function3
int w=win("Mozilla Firefox" "Mozilla*WindowClass" "" 0x4)
Acc a.FindFF(w "tab" "" "class=tabbrowser-tab[]label=Quick Macros Forum • View topic - reset int w and a.findff to avoid w1 and a1...etc" 0x3004)
a.DoDefaultAction
a.FindFF(w "A" "" "title=Post a reply[]href=''./posting.php?mode=reply&f=1&t=5786''" 0x1004 3)
a.DoDefaultAction
but i don't recommend it
if code is breaking from using a1 a2 a3 ,then it's not qm its how your programming.Hard to say why you code is failing without seeing it.
Posts: 197
Threads: 60
Joined: Dec 2013
Thanks for the code. It does exactly what I need.
Why do you not recommend this?
re:my code
I COULD keep track of all the a1,2,3,4...etc but there's so many functions (30 and growing) and each one searches for multiple objects on different websites, that I'll have a long list of a's to keep track of.
Even more worrisome for me is code maintenance. If I add another function or delete a function, then the numbering of those "a"s changes and I'll have to renumber a bunch of them. The headache would be huge from what I can see.