Jump to content

Better way to do this?


Recommended Posts

I am using a script to auto-login to StarCraft Broodwar. I sometimes have a problem because the time it takes the game to startup varies... I was wondering if there is some way to find out what screen the game is on and have it press buttons respectively. Here is my horribly simple script.

Run('C:\Program Files\Starcraft\starcraft.exe')
Sleep(2500)
Send("M")
Sleep(500)
Send("E")
Sleep(1000)
Send("O")
Sleep(4500)
Send("{TAB 7}USER{TAB}PASSWORD{ENTER}")

I am wondering if there is someway to use PixelSearch to tell it when to Send the keys...

Link to comment
Share on other sites

I am using a script to auto-login to StarCraft Broodwar. I sometimes have a problem because the time it takes the game to startup varies... I was wondering if there is some way to find out what screen the game is on and have it press buttons respectively. Here is my horribly simple script.

Run('C:\Program Files\Starcraft\starcraft.exe')
Sleep(2500)
Send("M")
Sleep(500)
Send("E")
Sleep(1000)
Send("O")
Sleep(4500)
Send("{TAB 7}USER{TAB}PASSWORD{ENTER}")

I am wondering if there is someway to use PixelSearch to tell it when to Send the keys...

Use RunWait()
Link to comment
Share on other sites

Thanks for the tip!

I went with the PixelSearch way of doing it and here is what I have...

Opt("PixelCoordMode", 2)
Dim $a = 1
Dim $c1 = 0xA6DA7F
Dim $c2 = 0xC5F892
Dim $c3 = 0x305A3C
Dim $c4 = 0x241C80
Run("C:\Program Files\Starcraft\starcraft.exe")
While 1
    Do
        If PixelSearch(78, 218, 100, 234, $c1) = 1 Then
            Send("M")
            $a = 2
        EndIf
    Until $a = 2
    Do
        If PixelSearch(335, 321, 346, 335, $c2) = 1 Then
            Send("E")
            $a = 3
        EndIf
    Until $a = 3
    Do
        If PixelSearch(63, 7, 63, 7, $c3) = 1 Then
            Send("o")
            $a = 4
        EndIf
    Until $a = 4
    Do
        If PixelSearch(388, 257, 400, 262, $c4) = 1 Then
            MouseClick("left", 154, 221)
            Send("USER123")
            MouseClick("left", 102, 284)
            Send("PASS123")
            $a = 5
        EndIf
    Until $a = 5
    If $a = 5 Then
        Exit
    EndIf
WEnd

Now, it gets to $a=3 (so it pressed "M" and "E" just fine) and ends before it does the last 3 Do's.... I cant figure out why!

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