Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem Determing which window has opened
#1
I am trying to create a check to see which of several windows has opened. The second window check is returning strange results. Here is my code

Code:
Copy      Help
int w4=win("Import Photos" "Afx:00400000:*" "" 0x800)
int w5=win("Problem with Importing Files" "Afx:00400000:*" "" 0x800)

if (w4=1)
    Acc d=acc("Import" "PUSHBUTTON" win("Import Photos" "Afx:00400000:*" "" 0x800) "Button" "" 0x1)
    d.DoDefaultAction
else if (w5=1)
    Acc e=acc("OK" "PUSHBUTTON" win("Problem with Importing Files" "Afx:00400000:*" "" 0x800) "Button" "" 0x1001)
    e.DoDefaultAction
mes("%i,%i" "" "" w4 w5)
If the window is the "Problem with Importing Files" option, the message that is returned is "0,1052278". The second number is not always the same but always large. If the window is the "Import Photos" option, the message returned is "0,0".

In both cases the buttons are not activated.

I also tried this code with the same results

Code:
Copy      Help
int w4=win("Import Photos" "Afx:00400000:*" "" 0x800)

if (w4=1)
    Acc d=acc("Import" "PUSHBUTTON" win("Import Photos" "Afx:00400000:*" "" 0x800) "Button" "" 0x1)
    d.DoDefaultAction
else
    int w5=win("Problem with Importing Files" "Afx:00400000:*" "" 0x800)
    if (w5=1)
        Acc e=acc("OK" "PUSHBUTTON" win("Problem with Importing Files" "Afx:00400000:*" "" 0x800) "Button" "" 0x1001)
        e.DoDefaultAction
mes("%i,%i" "" "" w4 w5)
#2
I think the win function returns the window's handle, not a 1 or 0. Change your "if" statements to "if(w4)" and "if(w5)", this will test if they received a handle or not.
#3
That works. Thanks. I had read a forum and thought that the win() function returned true or false (1 or 0) but after rereading that post i realize that it returns either a number or "0". Everything seems to be running correctly.......for now.
#4
So now i am in the correct window and need to do a certain action depending on which of two buttons is present. How would i do this?
#5
If you find buttons with child or id function, everything is the same as with windows, because these functions return window handle or 0 if not found.

If you use acc function,
Acc a=acc(...) ;;in 'Find accessible object' dialog uncheck 'error if not found'
if(a.a)
,out "found"
#6
*facepalms* I saw that and thought about using it but as with most problems I have run into with QM, I overthought it. Curse your simple to understand code, Gintaras. Why did you have to make it so easy to use? :lol:

In all cincerity thanks for this program. You have no idea how much of a time saver it has been.
#7
Here is my final code in case it helps anyone

Macro
Code:
Copy      Help
int w4=win("Import Photos" "Afx:00400000:*" "" 0x800)

if (w4)
,Acc d=acc("Import" "PUSHBUTTON" win("Import Photos" "Afx:00400000:*" "" 0x800) "Button" "" 0x1)
,d.DoDefaultAction
else
,int w5=win("Problem with Importing Files" "Afx:00400000:*" "" 0x800)
,if (w5)
,,Acc e=acc("" "PUSHBUTTON" win("Problem with Importing Files" "Afx:00400000:*" "" 0x800) "Button" "" 0x1100 550 293)
,,e.DoDefaultAction
,,1
,,err-
,,Acc f=acc("Import" "PUSHBUTTON" win("Import Photos" "Afx:00400000:*" "" 0x800) "Button" "" 0x1001)
,,f.DoDefaultAction
,,err+

I realized that the two different buttons I was needing to press in the different cases were in the same location in the window so i used the function not based on name of the accessible object but based on location.


Forum Jump:


Users browsing this thread: 1 Guest(s)