Jump to content
ShakeelAhmad

Problem in my script

Recommended Posts

ShakeelAhmad

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

Share this post


Link to post
Share on other sites
ShakeelAhmad
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!

Share this post


Link to post
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

  • Similar Content

    • CarlD
      By CarlD
      Is there a reliable way to ensure that data assigned to variables in a script is overwritten or deleted when the script exits? I have scripts that encrypt/decrypt data and would like to ensure, if possible, that the encryption keys and decrypted data do not stay in memory after the script exits. Thanks.
    • Skeletor
      By Skeletor
      Hi Guys,
      Is it possible to get a variable on your For..Next loop? 
       
      Local $Lines1 = _FileCountLines(C:\temp\test.txt) Local $linesToCount2 = $Lines1 + 2 $var = Number($linesToCount2) For $count = 1 To _FileCountLines($FileRead2) Step 1 For $i = $var To $count Next ;Code does stuff here Next Somehow my code doesn't work even though I thought I could convert the variable to a Integer / Number.
      This code I posted above does not move to the next value.
      But the code below does... why is that?
      For $count = 1 To _FileCountLines($FileRead2) Step 1 For $i = 2 To $count Next ;Code does stuff here Next  
      Why is the For loop resetting itself?
      Is it because the program does not cache the variable and needs to keep on acquiring this variable each time?
      If so , how would you make this variable static?

       
    • Dzenan03
      By Dzenan03
      I want to make a while loop, that creates variables based on a array. For thist I created the array $iDsO with the number and the name of folders in an other folder. Every folder has a different name an I want to create variables(arrays) for each folder that show me all the files in that folder. For example: I have the Folder \Folder1. In it there are the Folders \1, \2, \3. In 1, 2 and 3 there are some files(.png). The array for Folder1 is $iDsO and now I want to crate the arrays $iDsO1, $iDsO2 and $iDsO3 with the files in them can I make something like this:
      While $iDs > 0 ;$iDs is the number of files in Folder1>> $iDsO[0] $iDs#here should come the Foldername for example '1'# = _FileListtoArray(@ProgramFilesDir&"\Folder1\"&$iDsO[$iDs]) $iDs = $iDs - 1 Wend So that in the End I have three variabels ($iDs1, $iDs2 and $iDs3)
       
      Is this posible or if not what could I do instead ( I don´t know the number of folders in Folder1 in the begining).
    • WoodGrain
      By WoodGrain
      Hi guys,
      I'm learning about GUI's, I'm trying the below code, the idea being if I press the letter "e" while I have the GUI open I want the label color to change to green (I'm using a UDF for label colors). But every time I press "e" on my keyboard I just get a "ding" sound from my speakers and nothing changes with the label.
      I've looked at using something like "While GUIGetMsg() <> $GUI_EVENT_CLOSE" as I've seen it in other code instead of "While 1", but I don't think it's relevant.
      #include <GUIConstantsEx.au3>; for GUI... #include <GUIRichLabel.au3>; UDF for rich text label fonts #include <Misc.au3>; for _IsPressed $myLetter = "e" $hGUI = GUICreate("test", 700, 60) $lbl2 = _GUICtrlRichLabel_Create($hGUI, '<font color="purple">' & $myLetter & '</font>', 10, 10); , 260, 25 GUISetState(@SW_SHOW) Local $hDLL = DllOpen("user32.dll") While 1 if _IsPressed(Hex($myLetter), $hDLL) Then While _IsPressed(Hex($myLetter), $hDLL) Sleep(250) WEnd _GUICtrlRichLabel_SetData($lbl2, '<font color="green">' & $myLetter & '</font>') Sleep(2000) DllClose($hDLL) Exit EndIf Sleep(50) WEnd DllClose($hDLL) I am using an array of letters that I'm wanting to do this for, but as I can't get it to work I've stripped it down to the simplest code I can think of to try and get this working first. Appreciate any help.
      Thanks!
    • Gringo
      By Gringo
      Hi,
      I'm trying to create a shortcut playing with variables but I can't figure out what's wrong
      I got 2 variables joined in one with for instance
      Local $path = FileOpenDialog($message, "C:" & "", "Select your executable (*.exe)", 1 + 4)
      Local $elev = 'c:\windows\System32\cmd.exe /c start "runhigh" /high '
      $target = $elev & $path
      FileCreateShortcut($target, @DesktopCommonDir & "\linked.lnk", StringLeft($target,StringInStr($target,"\",0,-1)) , "" , "" , "c:\i.ico")
      The problem is that a shortcut is created but instead of the target area I got the start in filled with my variable
      My second problem is that when I do a shell execute of the result of $target = $elev & $path, Note that if I do a batch with the variable written manually, it's working.
×