Jump to content

[help] restarting script after a number of clicks


depddo
 Share

Recommended Posts

Hello,

I only started learning autoit yesterday, and I have been stuck on this issue for while.

I want this script to do the following:
1) open an image gallery website (through clicks)
2) search for an image on screen, if the image is not on screen then click the next button (always in the same spot)
3) keep clicking next until finds the image.
4) once finds the image click and close window 
5) repeat

Now if the image detection is 100% I wouldn't have an issue, but sometimes it misses the picture, and I want the script to start all over if this happens... I'm not sure what the best way is, I was thinking after a certain # of clicks (which represent the pages it needs to scroll through).

Any help would be appreciated!

 

#include <image_search.au3>
HotKeySet("{ESC}", "Terminate")
While 1
_WinWaitActivate("New Tab - Google Chrome","")
MouseClick("left",1909,55,1)
MouseClick("left",1823,122,1)
MouseClick("left",1788,77,1)
MouseClick("left",1622,241,1)
_WinWaitActivate("shareimage - Google Chrome","")
MouseClick("left",590,599,1)
Sleep(1000)
search_code()
WEnd
Func Terminate()
    Exit 0
EndFunc
Func get_sample_target_sign()
    Local $sign[9]
    $sign[0] = 10128249
    $sign[1] = 1446936
    $sign[2] = 6121812
    $sign[3] = 2038550
    $sign[4] = 1769472
    $sign[5] = 986896
    $sign[6] = 3544082
    $sign[7] = 328207
    $sign[8] = 854795
    return $sign
EndFunc
func search_code()
    Sleep(2000)
    $img_pos = image_search(get_sample_target_sign(),55,42)
    if $img_pos[0] <> -1 then
        MouseClick("left",$img_pos[0]+10,$img_pos[1]+50)
        sleep(1000)
        MouseClick("left",1891,6)
    else
        MouseClick("left",1115,908)
        search_code()
    endif
EndFunc

 

Link to comment
Share on other sites

You want the script to start over or the Function?

Both answers involve setting up an error handler.

Exiting and restarting the script I would steer clear of.

Set up your script so that the function that would fail and need to be restarted can be controlled by the error handler.

For instance:

If _imgSearch = 0 Then

Exitloop

Restart Function

etc.

Edited by l3ill
Link to comment
Share on other sites

I would add a tolerance value to img search, and test.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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