Jump to content

program sometimes won't open


Recommended Posts

I write script that run in loop

The problem that the program won't open all the times just sometimes
Somethimes after 2 times of the loop it won't open

here the script (bay the way before i start new loop i close it in MouseClick fun)

Thanks in advance
yaniv


$i = 1
While 1
Local $iPID = Run("Snipping Tool.exe", "")             //// <<<<< THIS LINE IS THE PROBLEM ////
Sleep(2000)
MouseClick("left",328,327,2)
Sleep(1000)

MouseClick("left",1018,1040,1)
_WinWaitActivate("Windows XP Professional - VMware Player (Non-commercial use only)","")
MouseClick("left",80,94,1)
MouseClick("left",111,220,1)
MouseClick("left",1907,265,1)
_WinWaitActivate("Snipping Tool","")
MouseClick("left",45,42,1)
MouseMove(140,120)
MouseDown("left")
MouseMove(1200,390)
MouseUp("left")
MouseClick("left",52,44,1)
MouseClick("left",52,96,1)
_WinWaitActivate("Save As","")
Send($i)
MouseClick("left",796,498,1)
_WinWaitActivate("Snipping Tool","")
MouseClick("left",1400,4,1)
MouseClick("left",1500,265,1)
Send("{DOWN}")
WinMinimizeAll()
Sleep(2000)
$i += 1
WEnd

Link to comment
Share on other sites

  • Moderators

You have absolutely no error checking in your script. After your run command and the sleep, check for the existence of the executable:

Quote

If WinExists("Snipping Tool", "") Then
    ;Do one thing
Else
    ;Try to launch again, throw error code, etc.
EndIf

Additionally, you need to get away from the Mouseclicks; they are inherently unreliable. You will save yourself a lot of headaches if you find another way to accomplish what you're after (which there usually is).

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I dont know why but now for some reson it wont open at all

 

$i = 1
While 1

   Local $iPID = Run("Snipping Tool.exe", "")
   Sleep(2000)

   If WinExists("Snipping Tool", "") Then

      MouseClick("left",328,327,2)
      Sleep(1000)

      MouseClick("left",1018,1040,1)
      _WinWaitActivate("Windows XP Professional - VMware Player (Non-commercial use only)","")
      MouseClick("left",80,94,1)
      MouseClick("left",111,220,1)
      MouseClick("left",1907,265,1)
      _WinWaitActivate("Snipping Tool","")
      MouseClick("left",45,42,1)
      MouseMove(140,120)
      MouseDown("left")
      MouseMove(1400,390)
      MouseUp("left")
      MouseClick("left",52,44,1)
      MouseClick("left",52,96,1)
      _WinWaitActivate("Save As","")
      Send($i)
      MouseClick("left",796,498,1)
      _WinWaitActivate("Snipping Tool","")
      MouseClick("left",1400,4,1)
      MouseClick("left",1500,265,1)
      Send("{DOWN}")
      WinMinimizeAll()
      Sleep(2000)
      $i += 1
   EndIf
WEnd

Link to comment
Share on other sites

  • Moderators

It has a space when checking for the existence of the Window.

1.png.43745df960c43b09e72d316f79b8b5a8.png

The executable itself has no space. Count on MS to be consistent :)

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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