Jump to content

Script Help - While/For


Recommended Posts

I am working on a PHP web app.

Basically what I want is a script that will run in the background always, and when a certain page is loaded, it will execute keystrokes and load an application.

This seems like an easy way as i've stuffed around with PHP execution to no avail. It's only for one PC anyway.

This works:

If WinWaitActive("Google - Mozilla Firefox") Then

Send('#r')

Send('cmd{ENTER}')

EndIf

But after CMD launches, the script terminates.

I want it to be running in the background ready to do the same thing each time the page is loaded, is that possible?

I've tried but I end up havign the cmd popup like 20 times at once.

Thanks

Link to comment
Share on other sites

Depends if you need to do the action only once after the window exists, or each time it's the active window. Only you know exactly what you are doing. But I would suggest once you perform your action then using something like WinWaitNotActive, or if you don't want to do the action again until a new window with that title pops up, then wait as long as the window exists.. as in While WinExists sleep(250)

until the window is closed.. then you wait for it to pop up again.

2 nested loops should do it.

Link to comment
Share on other sites

hey,

I think this should do the trick

Global Const $sWinTitle = "Google - Mozilla Firefox"
Global $bDone = 0

While 1 
    If Not $bDone And WinActive($sWinTitle) Then
        Send('#r')
        Send('cmd{ENTER}')
        $bDone = 1
    ElseIf $bDone And Not WinExists($sWinTitle) Then
        $bDone = 0
    EndIf
    Sleep(25)
WEnd
Link to comment
Share on other sites

hey,

I think this should do the trick

Global Const $sWinTitle = "Google - Mozilla Firefox"
Global $bDone = 0

While 1 
    If Not $bDone And WinActive($sWinTitle) Then
        Send('#r')
        Send('cmd{ENTER}')
        $bDone = 1
    ElseIf $bDone And Not WinExists($sWinTitle) Then
        $bDone = 0
    EndIf
    Sleep(25)
WEnd

Thanks to you both.

This one works perfectly!

Link to comment
Share on other sites

Thanks to you both.

This one works perfectly!

Actually just one more thing,

Is there a faster/more efficent way to launch applications within an AutoIt script?

Start -> Run CMD is fine,

but when the file paths start to get longer there's that lil' bit of lag/delay while it enters the keystrokes in and i'd rather not have it

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...