confiscated

Color Bot > Key Press

7 posts in this topic

#1 ·  Posted

Hello, I am wondering if anyone can point me in the right direction for making a simple script that will do the following.

 

1. Script is run

2. Script will wait until a certain color appears on screen.

3. Once the color is on screen, then the script will press a certain key such as "k"

4. Once "k" has been pressed, then sleep for 500 and then press "y" and then the script will repeat from step 1 and so on...

 

Any help is appreciated, thanks in advance

Share this post


Link to post
Share on other sites



#2 ·  Posted

Sounds like game automation. You would need to scan the screen constantly, and depending on how big the area is, it could be very slow.

Share this post


Link to post
Share on other sites

#3 ·  Posted

Welcome to AutoIt and the forum!

Can you please tell us which program you try to automate and what the goal of your script is (e.g. wait until the program has finished a task and then press a button).
Most of the time there are more reliable ways than to process single pixels.


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

#4 ·  Posted

I have what you need. Problem is i cant resolve why its not searching window i specify.

Opt("WinTitleMatchMode", 2)
$WindowToSearch = "0.jpg"
$PixelColor = 0x6FDD00 ;lime green


While 1
    If WinExists ($WindowToSearch) = 1 Then
        $WindowHandle = WinGetHandle ($WindowToSearch)
        $WinPos = WinGetPos ($WindowToSearch)
        $R = $WinPos[2] ;to right
        $B = $WinPos[3] ;to bottom
        $Search = PixelSearch(0,0,200,400, $PixelColor, 2, 1,$WindowHandle) ;2 for shade variation,1 for steps, and window name to search
        If IsArray($Search) = True Then
            ConsoleWrite (@CRLF & "Found it at X=" & $Search[0]& " Y=" & $Search[1] & " WinPos " & $R & " " & $B & " ")
            Send ("{K}")
            sleep (100)
        Else
            ConsoleWrite (@CRLF & "nothing found " & $WindowHandle)
            sleep (100)
        Endif
    Else
            ConsoleWrite (@CRLF & "Loking for window")
            sleep (100)
    EndIf
Wend

 

Share this post


Link to post
Share on other sites

#5 ·  Posted

 

1 hour ago, water said:

Can you please tell us which program you try to automate and what the goal of your script

 


ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Share this post


Link to post
Share on other sites

#6 ·  Posted

Did you miss to add some text to your post?


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

#7 ·  Posted

4 hours ago, FengHuangWuShen said:

Sounds like game automation. You would need to scan the screen constantly, and depending on how big the area is, it could be very slow.

Don't state this is to automate a game and still continue to give pointers! 

Same counts for you @tonycst...  You should also know better.

@confiscated,

Welcome to the AutoIt forum. :)

It looks like you are are trying to do game automation and unfortunately have missed the Forum rules on your way in. (there is also a link in my signature) 
Please read them now particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. :naughty:

See you soon with a legitimate question I hope. :)

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
Guest
This topic is now closed to further replies.