Jump to content

Color Bot > Key Press


Recommended Posts

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

Link to comment
Share on other sites

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

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

 

Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

Did you miss to add some text to your post?

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

  • Developers
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

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

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...