yanivtawily Posted January 30, 2019 Share Posted January 30, 2019 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 More sharing options...
Moderators JLogan3o13 Posted January 30, 2019 Moderators Share Posted January 30, 2019 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 More sharing options...
yanivtawily Posted January 30, 2019 Author Share Posted January 30, 2019 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 More sharing options...
Davidowicza Posted January 30, 2019 Share Posted January 30, 2019 (edited) Get rid of the space in between "Snipping Tool.exe" It should just be: Local $iPID = Run("SnippingTool.exe", "") Edited January 30, 2019 by Davidowicza Format Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 30, 2019 Moderators Share Posted January 30, 2019 (edited) It has a space when checking for the existence of the Window. The executable itself has no space. Count on MS to be consistent Edited January 30, 2019 by JLogan3o13 Davidowicza 1 "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 More sharing options...
Earthshine Posted January 30, 2019 Share Posted January 30, 2019 Exe should never have spaces. Period. And they are consistent because it doesn’t My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now