Recalling window incorrectly

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
BlackCat
Newbie
Posts: 13
Joined: Mon Dec 20, 2010 12:32 am

Recalling window incorrectly

Post by BlackCat » Wed Dec 22, 2010 8:00 pm

This maybe one of those weird ways an application interacts with Macro Scheduler, but I wanted to see if I'm doing something wrong. I am starting a program, entering my data and then minimizing it so that I can do other things while it runs. Once the program is done running a child window will pop up to say the operation has completed. I have the macro set up so that once the main program is minimized, it waits until the child window opens and then presses Enter to dismiss the window. The way I have it written I cannot get the macro to wait for this child window if the Main window isn't minimized. The child window has the same window name as the main window.

Code: Select all

//Minimize CloneDVD2
    WindowAction>2,CloneDVD2
   
    //Wait for child window of CloneDVD2
    Let>WF_TYPE=3
    WaitWindowOpen>CloneDVD2
    
    //Press OK to recognize that movie copy completed
    Press ENTER
    Release ENTER
My problem is recalling the main window that is minimized. When I attempt to close the window while it's minimized, after dismissing the child window, a new blank application window opens. I have a link to the screen shot below, since I can never figure out the whole picture hosting thing. Yes, I know I should be ashamed of myself since this is so basic.
http://flic.kr/p/93RZTc

This problem happens when I use the WindowAction, SetFocus, or CloseWindow commands. I was able to get around the problem, by minimizing the window a second time after I used the SetFocus command.

Code: Select all

//Reactivate CloneDVD2 dialog window so I can close it. Won't work otherwise
    SetFocus>CloneDVD2
    WindowAction>2,CloneDVD2
    
    //Closes the CloneDVD2 dialog window 
    CloseWindow>CloneDVD2
I thought using a WindowHandle might help to solve the situation a better way, but I can't seem to figure out how to use it, or else it also doesn't work. I tried looking through the site, but I didn't see anything that helped me understand how to implement it.

FYI: I also have this problem when opening the program. After using WaitWindowOpen I needed a Wait> before I used SetFocus or I would get the same screen.

Code: Select all

//Starts Clone DVD 2
    RunProgram>C:\Program Files\Elaborate Bytes\CloneDVD2\CloneDVD2.exe

    //Waits for Clone DVD 2 to open
    WaitWindowOpen>CloneDVD2

    //Manual wait incase a little lag from "WaitWindowOpen" command - Might be able to use just one or the other but sometimes doesn't always work
    Wait>2

    //Activates CloneDVD2 Window
    SetFocus>CloneDVD2
Sorry if similar has been posted before, but I couldn't seem to find it.

BlackCat
Newbie
Posts: 13
Joined: Mon Dec 20, 2010 12:32 am

Post by BlackCat » Fri Dec 24, 2010 5:20 pm

Ok I figured out part of my problem. Once the screen is minimized, the title in the task bar changes based on the percent of the operation completed. So sometimes this will end on 99% CloneDVD2 or 100% CloneDVD2 so I used the following:

Code: Select all

    IfWindowOpen>100% CloneDVD2,Close_100%,Close_99%
        Label>Close_100%
        WindowAction>3,100% CloneDVD2
    Else
        Label>Close_99%
        WindowAction>3,99% CloneDVD2
    Endif
Now my problem is activating this command. I am closing the child window that says the program operation has completed, but then it skips through the actions above. Here is what I have:

Code: Select all

    //Wait for child window of CloneDVD2
    Let>WF_TYPE=3
    WaitWindowOpen>CloneDVD2
    
    //Wait until window is open
    Wait>2
    SetFocus>CloneDVD2
    //Press OK to recognize that movie copy completed
    Press ENTER
    Release ENTER
    WaitWindowClosed>CloneDVD2
    
    //Works up to this point!!
    Wait>5
    
    //See which percent CloneDVD2 ended at, then choose the appropriate close command
    IfWindowOpen>100% CloneDVD2,Close_100%,Close_99%
        Label>Close_100%
        WindowAction>3,100% CloneDVD2
    Else
        Label>Close_99%
        WindowAction>3,99% CloneDVD2
    Endif
If I use debug with the *% CloneDVD2 window still open in the taskbar, the "IfWindowOpen" command works. This leads me to believe the command is activating before the previous window is closed or the computer is not ready to accept further commands? Although, it seems like I should be OK since I have WaitWindowClose and then Wait>5 seems like it should be more than enough.

BlackCat
Newbie
Posts: 13
Joined: Mon Dec 20, 2010 12:32 am

Post by BlackCat » Fri Dec 31, 2010 7:23 pm

BlackCat wrote:Ok I figured out part of my problem. Once the screen is minimized, the title in the task bar changes based on the percent of the operation completed. So sometimes this will end on 99% CloneDVD2 or 100% CloneDVD2 so I used the following:

Code: Select all

    IfWindowOpen>100% CloneDVD2,Close_100%,Close_99%
        Label>Close_100%
        WindowAction>3,100% CloneDVD2
    Else
        Label>Close_99%
        WindowAction>3,99% CloneDVD2
    Endif
Now my problem is activating this command. I am closing the child window that says the program operation has completed, but then it skips through the actions above. Here is what I have:

Code: Select all

    //Wait for child window of CloneDVD2
    Let>WF_TYPE=3
    WaitWindowOpen>CloneDVD2
    
    //Wait until window is open
    Wait>2
    SetFocus>CloneDVD2
    //Press OK to recognize that movie copy completed
    Press ENTER
    Release ENTER
    WaitWindowClosed>CloneDVD2
    
    //Works up to this point!!
    Wait>5
    
    //See which percent CloneDVD2 ended at, then choose the appropriate close command
    IfWindowOpen>100% CloneDVD2,Close_100%,Close_99%
        Label>Close_100%
        WindowAction>3,100% CloneDVD2
    Else
        Label>Close_99%
        WindowAction>3,99% CloneDVD2
    Endif
Anyone have any ideas? I have tried taking the IfWindowOpen statement out of the Dialog box If statement and putting it after the statement has finished, but that doesn't work. I tried making it into a subroutine with a label telling the script to goto it after it has closed the other window. I have tried putting the statement in a separate script and calling it at the end using the Include command, but doesn't work either. I'm all out of ideas. The IfWindowOpen will work if I use it after the script I included it in has finished, but it won't work if it is run in or called by that script for some reason. I need an idea of what I'm doing wrong. And if I need to include more information for help.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts