Jump to content

Question controlsend "x" times when finde pixel


bosk20
 Share

Recommended Posts

Hi, i wgot problem with send key when script found pixel.

$pixel = PixelSearch(448, 250, 458, 550, 16775664, 0, 1)
                If NOT @error Then
                        ControlSend($win, "", "", "{LEFT}");30 repeat?
                EndIf
                $pixel = PixelSearch(574, 245, 583, 548, 16775664, 0, 1)
                If NOT @error Then
                        ControlSend($win, "", "", "{RIGHT}");30 repeat?
                EndIf

How to send  key for expamle 30 times then stop it?

Edited by bosk20
Link to comment
Share on other sites

Does not work, I tried earlier. I put in in while but i try to set after 30 repeats this function enable break and run another  but nothing work.

 

HotKeySet("{up}", "start")

func start()
while 1 ;hot to repeat 30 times this comends?
                $pixel = PixelSearch(425, 413, 481, 463, 14655792, 0, 1)
                If NOT @error Then
                        ControlSend($win, "", "", "{LEFT}")
                EndIf
                $pixel = PixelSearch(425, 518, 481, 567, 14655792, 0, 1)
                If NOT @error Then
                        ControlSend($win, "", "", "{RIGHT}")
                     EndIf
wend
;break()
   EndFunc
   
   func break()
   while 1 
   sleep(100)
   wend
   endfunc

Its random send key but how to do that for send 30 times in one function?

any sugestion?

Link to comment
Share on other sites

  • Developers

Does not work, I tried earlier. I put in in while but i try to set after 30 repeats this function enable break and run another  but nothing work.

-snip-

Its random send key but how to do that for send 30 times in one function?

any sugestion?

You got the solution, so what exactly did you do that didn't work?
Maybe also give a much better description of what you are trying to do so we can actually try and help.

 Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

You can also use for loop:

 

Func start()

While 1

    $pixel = PixelSearch(425, 413, 481, 463, 14655792, 0, 1)
    If NOT @error Then
        For $i = 0 To 30
            ControlSend($win, "", "", "{LEFT}")
        Next
            ;End of loop
    EndIf
    
    $pixel = PixelSearch(425, 518, 481, 567, 14655792, 0, 1)
    If NOT @error Then
        For $i = 0 To 30
            ControlSend($win, "", "", "{RIGHT}")
        Next
            ;End of loop
    EndIf
    
WEnd

EndFunc

 

Link to comment
Share on other sites

Can you please tell us which program you try to automate? So maybe we can suggest a more reliable solution.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

 Problem solved. Thank you for answers. I do not know why it did not work before

Local $i = 0

While $i <= 30
          $pixel = PixelSearch(422, 413, 479, 463, 14655792, 0, 1)
                 If NOT @error Then
                        ControlSend($win, "", "", "{LEFT}")
                        $i += 1
                        EndIf

Now is working perfectly

Edited by bosk20
Edit
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...