Jump to content

Recommended Posts

Posted

Hello, I am new. I am sure you get a lot of us. So thank you for anybody that takes their time to help me.

So I'm doing this project, trying to get into coding and I thought I would want to start with auto-it.

  • Basically, I want to try to practice with random clicks - I want to see the mouse move to wherever the random click is. I don't know how to do that, I tried.
  • Then, with the pixel-search function, I am trying to have the script press on " MouseClick("left", $x_random3, $y_random3)" button until the pixel disappears  and then continue onward with the rest, but I want to create a loop out of the whole thing
  • Spoiler
    func exitthescript()
       Exit
    EndFunc 
    HotKeySet( "{ESC}", "exitthescript" ) 
    
    $x_click = 696
    $y_click = 402
    
    $x_click2 = 570
    $y_click2 = 379
    
    $x_click3 = 600
    $y_click3 = 342
    
    $x_click4 = 644
    $y_click4 = 483
    
    $x_click5 = 644
    $y_click5 = 518
    
    
    $x_deviation = 3
    $y_deviation = $x_deviation
    
    $x_random = Random($x_click - $x_deviation, $x_click + $x_deviation, 1)
    $y_random = Random($y_click - $y_deviation, $y_click + $y_deviation, 1)
    
    $x_random2 = Random($x_click2 - $x_deviation, $x_click2 + $x_deviation, 1)
    $y_random2 = Random($y_click2 - $y_deviation, $y_click2 + $y_deviation, 1)
    
    $x_random3 = Random($x_click3 - $x_deviation, $x_click3 + $x_deviation, 1)
    $y_random3 = Random($y_click3 - $y_deviation, $y_click3 + $y_deviation, 1)
    
    $x_random4 = Random($x_click4 - $x_deviation, $x_click4 + $x_deviation, 1)
    $y_random4 = Random($y_click4 - $y_deviation, $y_click4 + $y_deviation, 1)
    
    $x_random5 = Random($x_click5 - $x_deviation, $x_click5 + $x_deviation, 1)
    $y_random5 = Random($y_click5 - $y_deviation, $y_click5 + $y_deviation, 1)
    
    
    While 1=1
    MouseMove (696, 402) 
    MouseClick("left", $x_random, $y_random)
    MouseMove (570, 379) 
    MouseClick("left", $x_random2, $y_random2)
       Until PixelSearch(0, 0, 1381, 885, 0xFF0000) = @error
          if @error Then
             MouseMove (600, 342)
             MouseClick("left", $x_random3, $y_random3)
        ;if MouseClick("left", $x_random3, $y_random3) then ExitLoop 
        ContinueLoop
    MouseMove (600, 342)
    MouseClick("left", $x_random3, $y_random3)
    WEnd

     

    Thanks again for the help. The code is in the spoiler. Wanted to make the post shorter.

 

 

 

Posted

Welcome to AutoIt and the forum!

Which program do you try to automate?
Screen positions depend on the size of your display, the resolution and user interaction.
To start I suggest to automate a simple "real life" program. You will get more replies from people who have already used the same program :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted
16 hours ago, water said:

Welcome to AutoIt and the forum!

Which program do you try to automate?
Screen positions depend on the size of your display, the resolution and user interaction.
To start I suggest to automate a simple "real life" program. You will get more replies from people who have already used the same program :)

Hello, thanks for the reply. Well its this tutorial from school its on a web-browser. Trying to clear as many as I can out as I already know the information. Its specific for me because only I can log in. But what I am trying to do is mainly with the functions and at the same time I am trying to learn how to do new things. (eg., random clicks) that shows where the mouse moves too.

However, what I am mainly trying to do is the find pixel

 Until PixelSearch(0, 0, 1381, 885, 0xFF0000) = @error
      if @error Then
         MouseMove (600, 342)
         MouseClick("left", $x_random3, $y_random3)

and keep going with the script and go onto

MouseClick("left", $x_random3, $y_random3)

but when I try to use

WEnd

to have everything repeat itself. It gives me an error when I try to run it. I know continue loop shouldn't be there. The formatting is wrong somehow and cant seem to figure it out.

  ContinueLoop
Posted
18 minutes ago, Danp2 said:

Seems your "Until" line is the source of your problems as there doesn't appear to be a matching "Do" line.

Nope still get an Error ""Wend" statement with no matching "While" statement.:
WEnd

Feel like the problem originates from the while 1=1 and the Wend lines 

New Modified Code:

Spoiler

func exitthescript()
   Exit
EndFunc
HotKeySet( "{ESC}", "exitthescript" )

$x_click = 696
$y_click = 402

$x_click2 = 570
$y_click2 = 379

$x_click3 = 600
$y_click3 = 342

$x_click4 = 644
$y_click4 = 483

$x_click5 = 644
$y_click5 = 518


$x_deviation = 3
$y_deviation = $x_deviation

$x_random = Random($x_click - $x_deviation, $x_click + $x_deviation, 1)
$y_random = Random($y_click - $y_deviation, $y_click + $y_deviation, 1)

$x_random2 = Random($x_click2 - $x_deviation, $x_click2 + $x_deviation, 1)
$y_random2 = Random($y_click2 - $y_deviation, $y_click2 + $y_deviation, 1)

$x_random3 = Random($x_click3 - $x_deviation, $x_click3 + $x_deviation, 1)
$y_random3 = Random($y_click3 - $y_deviation, $y_click3 + $y_deviation, 1)

$x_random4 = Random($x_click4 - $x_deviation, $x_click4 + $x_deviation, 1)
$y_random4 = Random($y_click4 - $y_deviation, $y_click4 + $y_deviation, 1)

$x_random5 = Random($x_click5 - $x_deviation, $x_click5 + $x_deviation, 1)
$y_random5 = Random($y_click5 - $y_deviation, $y_click5 + $y_deviation, 1)


While 1=1
MouseMove (696, 402)
MouseClick("left", $x_random, $y_random)
MouseMove (570, 379)
  Do
  MouseClick("left", $x_random2, $y_random2)
  Until PixelSearch(0, 0, 1381, 885, 0xFF0000) = @error
  if @error Then
     MouseMove (600, 342)
     MouseClick("left", $x_random3, $y_random3)
     MouseMove (600, 342)
     MouseClick("left", $x_random3, $y_random3)
WEnd

So I want the automated script to click until there is a 

Until PixelSearch(0, 0, 1381, 885, 0xFF0000) = @error

The color is not going to be there anymore. 

Then, I want it to get out of that and continue with the script normally by 

MouseMove (600, 342)
     MouseClick("left", $x_random3, $y_random3)
     MouseMove (600, 342)
     MouseClick("left", $x_random3, $y_random3)
WEnd

and continuing the whole process again. 

Posted
HotKeySet( "{ESC}", "exitthescript" )

$x_click = 696
$y_click = 402

$x_click2 = 570
$y_click2 = 379

$x_click3 = 600
$y_click3 = 342

$x_click4 = 644
$y_click4 = 483

$x_click5 = 644
$y_click5 = 518

$x_deviation = 3
$y_deviation = $x_deviation

$x_random = Random($x_click - $x_deviation, $x_click + $x_deviation, 1)
$y_random = Random($y_click - $y_deviation, $y_click + $y_deviation, 1)

$x_random2 = Random($x_click2 - $x_deviation, $x_click2 + $x_deviation, 1)
$y_random2 = Random($y_click2 - $y_deviation, $y_click2 + $y_deviation, 1)

$x_random3 = Random($x_click3 - $x_deviation, $x_click3 + $x_deviation, 1)
$y_random3 = Random($y_click3 - $y_deviation, $y_click3 + $y_deviation, 1)

$x_random4 = Random($x_click4 - $x_deviation, $x_click4 + $x_deviation, 1)
$y_random4 = Random($y_click4 - $y_deviation, $y_click4 + $y_deviation, 1)

$x_random5 = Random($x_click5 - $x_deviation, $x_click5 + $x_deviation, 1)
$y_random5 = Random($y_click5 - $y_deviation, $y_click5 + $y_deviation, 1)
;=============================================================================
While 1
While PixelSearch(0, 0, 1381, 885, 0xFF0000) <> @error
MouseClick("left", $x_random, $y_random)
Sleep(100)
WEnd
MouseClick("left", $x_random2, $y_random2)
MouseMove (696, 402)
MouseClick("left", $x_random3, $y_random3)
MouseMove (570, 379)
MouseClick("left", $x_random4, $y_random4)
MouseMove (600, 342)
MouseClick("left", $x_random5, $y_random5)
Sleep(100)
WEnd
;=============================================================================
func exitthescript()
   Exit
EndFunc

 

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

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
×
×
  • Create New...