bosk20

Question controlsend "x" times when finde pixel

8 posts in this topic

#1 ·  Posted (edited)

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

Share this post


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

Share this post


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

-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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

When i try do it with {left 30} script dont work. I don't know how  to set the condition that after a given amount ControlSend(left and right) script will perform another action?

Share this post


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

 

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

 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

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