Jump to content

Problem in my script


Recommended Posts

I've to upload different number of photos online in different assignments. There is a problem that all photos cannot be selected at once to upload. I have to choose and upload photos one by one. For this purpose I have made a script to automate whatever I have to do manually for choosing and uploading photos one by one.

Please see my script below and check the last "MouseClick" command. This command clicks the button to choose and upload next photo. The problem I'm facing is; the last "MouseClick" works 1 step extra when all photos have been selected and uploaded. I mean if 7 photos are to be uploaded, this command opens the box from where next photo is selected and uploaded then it again opens the box and next photo is choosen and so on.... when last photo is selected and uploaded, this button once again opens the box. When all photos are uploaded, it should not click the button to select next photo. Please suggest how can I resolve this issue.

#include <AutoItConstants.au3>
Sleep(200)
HotKeySet("{ESC}","Quit") ;Press ESC key to quit
Send("{ALT DOWN}")
Send("{TAB}")
Send("{ALT UP}")
Sleep(200)

Local $photos = InputBox("Question", "How many photos to upload?", "#", "", _
             - 1, -1, 0, 0)  ;  How many photos to upload
Local $selector = 0
While $photos <> $selector
   MouseClick("Left", 281, 238, 1) ; mouse click on very first photo in the box.
   if $selector = 0 Then
      Send("{ENTER}") ; for selecting very first photo from "open" window.
      Sleep(800)
   Else
      sleep(200)
      Send("{RIGHT " & $selector & "}") ; for selecting 2nd to onward photos from "open" window.
      sleep(1000)
      Send("{ENTER}")
      sleep(1000)
   EndIf
   MouseClick("Left", 495, 198, 1) ; for clicking a button to choose next photo to upload
   $selector = $selector + 1
WEnd





Beep(1500, 300) ; beep when all photos uploaded
Exit

Regards,

 

Shakeel

Link to comment
Share on other sites

27 minutes ago, Zedna said:

Maybe instead of


While $photos <> $selector

Try


While ($photos - 1) <> $selector

It didn't work with "While" as you suggested but your tip of using ($photos - 1) <> $selector helped me like this:

#include <AutoItConstants.au3>
Sleep(200)
HotKeySet("{ESC}","Quit") ;Press ESC key to quit
Send("{ALT DOWN}")
Send("{TAB}")
Send("{ALT UP}")
Sleep(200)

Local $photos = InputBox("Question", "How many photos to upload?", "#", "", _
             - 1, -1, 0, 0)  ;  How many photos to upload
Local $selector = 0
While $photos <> $selector
   MouseClick("Left", 281, 238, 1)
   if $selector = 0 Then
      Send("{ENTER}") ; for selecting very first photo from "open" window.
      Sleep(800)
   Else
      sleep(200)
      Send("{RIGHT " & $selector & "}") ; for selecting 2nd to onward photos from "open" window.
      sleep(1000)
      Send("{ENTER}")
      sleep(1000)
   EndIf
   If ($photos - 1) <> $selector Then
   MouseClick("Left", 495, 210, 1) ; for clicking a button to choose next photo to upload
   EndIf
   $selector = $selector + 1
WEnd
Exit

Thank you!

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

×
×
  • Create New...