Jump to content

Check to see if a program is open


Recommended Posts

I am want to see if a program is open every 1 min and if it is I want it to move the window to a certain x, y cord. and then click a buton. I know how to move the window and click but I don't know the logic to look for the program being open. Can anyone help me.

Link to comment
Share on other sites

Hi,

if winexists

If processexists

in a loop

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

While 1
     If WinExists("title") Then
          ClickAndMove()
     Else
          Sleep(60000)
     EndIf
WEnd

Func ClickAndMove()
     mouselick(etc.)
     Winmove(etc.)
EndFuncoÝ÷ ØäZºÚ"µÍYX[XJ    ][ÝÐÚXÚÉ][ÝË

B[ÈÚXÚÊ
BRYÚ[^ÝÊ ][ÝÝ]I][ÝÊH[BPÛXÚÐ[[ÝJ
BQ[Y[[Â[ÈÛXÚÐ[[ÝJ
BS[ÝÙPÛXÚÊ]ËBUÚ[[ÝJ]ËB[[

Edited by dandymcgee

- Dan [Website]

Link to comment
Share on other sites

While 1
     If WinExists("title") Then
          ClickAndMove()
     Else
          Sleep(60000)
     EndIf
WEnd

Func ClickAndMove()
     mouselick(etc.)
     Winmove(etc.)
EndFun

Is there any way that I can put it in this script?

WinMinimizeAll ()

WinActivate ("Maki to Eagle")

winmove ("Maki to Eagle", "", 152, 115)

Mouseclick ("left", 500, 500)

mouseclick ("left", 220, 200)

sleep (200)

winclose ("Maki to Eagle")

run ("E:\Rammserver\Data\3apps\Catapult\3spmif.exe -start")

sleep (1500)

WinActivate ("E4W Maki Interface Error")

mouseclick ("left", 650, 500)

sleep (1500)

winmove ("Maki to Eagle", "", 152, 115)

WinActivate ("Maki to Eagle")

mouseclick ("left", 220, 200)

Here for the sleep I want the code.

sleep (900000)

WinActivate ("Maki to Eagle")

Mouseclick ("left", 500, 500)

mouseclick ("left", 220, 200)

sleep (200)

winclose ("Maki to Eagle")

Link to comment
Share on other sites

What do you want to put right there? WinActive("")?

There is a chance that the program will error out and open another program. If the program errors out I want to click the button to continue. Because the program is so buggy I need to stop and restart the program every 15 min. So I want to remove the sleep for 15min and put in its place to see if the program is opened or not every minute for 15min. Then I wan the program to close and then restart again. I do the restarting with scheduled tasks.

Link to comment
Share on other sites

WinMinimizeAll ()
WinActivate ("Maki to Eagle")
winmove ("Maki to Eagle", "", 152, 115)
Mouseclick ("left", 500, 500)
mouseclick ("left", 220, 200)
sleep (200)
winclose ("Maki to Eagle")
run ("E:\Rammserver\Data\3apps\Catapult\3spmif.exe -start")
sleep (1500)
WinActivate ("E4W Maki Interface Error")
mouseclick ("left", 650, 500)
sleep (1500)
winmove ("Maki to Eagle", "", 152, 115)
WinActivate ("Maki to Eagle")
mouseclick ("left", 220, 200)

If WinExists("title of window") Then
     ;Do nothing this is a good thing
Else
     Run("Directory of the program so that you can restart it")
EndIf

WinActivate ("Maki to Eagle")
Mouseclick ("left", 500, 500)
mouseclick ("left", 220, 200)
sleep (200)
winclose ("Maki to Eagle")

Like this?

P.S. use autoit tags it makes it much easier to read. [ autoit ] and [ /autoit ] at beginning and end (without the extra spaces I added to make them show up.

Edited by dandymcgee

- Dan [Website]

Link to comment
Share on other sites

WinMinimizeAll ()
WinActivate ("Maki to Eagle")
winmove ("Maki to Eagle", "", 152, 115)
Mouseclick ("left", 500, 500)
mouseclick ("left", 220, 200)
sleep (200)
winclose ("Maki to Eagle")
run ("E:\Rammserver\Data\3apps\Catapult\3spmif.exe -start")
sleep (1500)
WinActivate ("E4W Maki Interface Error")
mouseclick ("left", 650, 500)
sleep (1500)
winmove ("Maki to Eagle", "", 152, 115)
WinActivate ("Maki to Eagle")
mouseclick ("left", 220, 200)

If WinExists("title of window") Then
     ;Do nothing this is a good thing
Else
     Run("Directory of the program so that you can restart it")
EndIf

WinActivate ("Maki to Eagle")
Mouseclick ("left", 500, 500)
mouseclick ("left", 220, 200)
sleep (200)
winclose ("Maki to Eagle")

Like this?

P.S. use autoit tags it makes it much easier to read. [ autoit ] and [ /autoit ] at beginning and end (without the extra spaces I added to make them show up.

I need it to check every minute for 15 Minutes. Then I have the program restarting.

Thanks,

Jon

Link to comment
Share on other sites

I need it to check every minute for 15 Minutes. Then I have the program restarting.

Does the code I posted not do what you want? As far as I can see it is checking every 3.4 seconds... is that a bad thing? If so, just add a sleep in there to make up the difference (56.6 seconds or Sleep(566000) if you can't figure out what I mean). I don't see why it checking even every 3 seconds would be hurtful in any way, it shouldn't take up much CPU power to see if a title exists. If so, like I mentioned simply add a sleep where you see it necessary.

- Dan [Website]

Link to comment
Share on other sites

Does the code I posted not do what you want? As far as I can see it is checking every 3.4 seconds... is that a bad thing? If so, just add a sleep in there to make up the difference (56.6 seconds or Sleep(566000) if you can't figure out what I mean). I don't see why it checking even every 3 seconds would be hurtful in any way, it shouldn't take up much CPU power to see if a title exists. If so, like I mentioned simply add a sleep where you see it necessary.

Sorry I wasn't clear on what I needed. This program gets errors all the time and needs to be shut down every 15 Min. So what I need it to do is every Min. I need it to check to see if a program is open if is then I need it to do a couple clicks of the mouse which I can program if there is not error on the screen I need it to do nothing. And then after 15 Min. I need it to finish the script. So if I could get the check for a window to be in a loop for 15 Min then end the script that would be great.

Link to comment
Share on other sites

WinMinimizeAll ()
WinActivate ("Maki to Eagle")
winmove ("Maki to Eagle", "", 152, 115)
Mouseclick ("left", 500, 500)
mouseclick ("left", 220, 200)
sleep (200)
winclose ("Maki to Eagle")
run ("E:\Rammserver\Data\3apps\Catapult\3spmif.exe -start")
sleep (1500)
WinActivate ("E4W Maki Interface Error")
mouseclick ("left", 650, 500)
sleep (1500)
winmove ("Maki to Eagle", "", 152, 115)
WinActivate ("Maki to Eagle")
mouseclick ("left", 220, 200)

$MinutesSoFar = 0
While 1
    If $MinutesSoFar = 15 Then ;15 minutes have passed
        Exit ;Close this program
    EndIf
    If WinExists("title of window") Then
        ;Put mouse clicks and such here if the window is open
    EndIf
    Sleep(60000) ;Wait one minute
    $MinutesSoFar = $MinutesSoFar + 1 ;Add one minute to tell the script how long it's been running.
WEnd

WinActivate ("Maki to Eagle")
Mouseclick ("left", 500, 500)
mouseclick ("left", 220, 200)
sleep (200)
winclose ("Maki to Eagle")

Let me know if this still doesn't work correctly and I'll try my best to keep improving it to do what you would like it to do.

- Dan [Website]

Link to comment
Share on other sites

WinMinimizeAll ()
WinActivate ("Maki to Eagle")
winmove ("Maki to Eagle", "", 152, 115)
Mouseclick ("left", 500, 500)
mouseclick ("left", 220, 200)
sleep (200)
winclose ("Maki to Eagle")
run ("E:\Rammserver\Data\3apps\Catapult\3spmif.exe -start")
sleep (1500)
WinActivate ("E4W Maki Interface Error")
mouseclick ("left", 650, 500)
sleep (1500)
winmove ("Maki to Eagle", "", 152, 115)
WinActivate ("Maki to Eagle")
mouseclick ("left", 220, 200)

$MinutesSoFar = 0
While 1
    If $MinutesSoFar = 15 Then ;15 minutes have passed
        Exit ;Close this program
    EndIf
    If WinExists("title of window") Then
        ;Put mouse clicks and such here if the window is open
    EndIf
    Sleep(60000) ;Wait one minute
    $MinutesSoFar = $MinutesSoFar + 1 ;Add one minute to tell the script how long it's been running.
WEnd

WinActivate ("Maki to Eagle")
Mouseclick ("left", 500, 500)
mouseclick ("left", 220, 200)
sleep (200)
winclose ("Maki to Eagle")

Let me know if this still doesn't work correctly and I'll try my best to keep improving it to do what you would like it to do.

That was perfect thanks so much for the help.

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...