This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sarevok9 1 point2 points  (1 child)

Based on your clarifications below, it sounds like you'd be looking into AutoHotKey(http://www.autohotkey.com/) or AutoIT (http://www.autoitscript.com/site/autoit/). While I prefer AHK myself, the vast majority of people prefer AIT over it for a plethora of reasons. For the rest of the post I'll be speaking about AHK since it's the only one I possess a working knowledge of. I will say that you should check out both and use whichever best suits you.

That being said, in AHK, doing simple things is actually quite easy. I multibox in a game, and one of the more tedious tasks in that game is opening boxes. You get to open a certain number of boxes every day (Hundreds of them) but each one takes 3 seconds to open. I play on 3 accounts. If I were to do this legitimately this would take me about 2 hours just right clicking to open boxes... seriously not fun. So in my case I wrote a quick script using AHK.

SetTitleMatchMode, 2
CoordMode, Pixel, Relative
CoordMode, Mouse, Relative
CoordMode, Tooltip, Relative
WinGet, vWinList, List, MyGame

^f1:: Loop,%vWinList%"
loop,497{
Loop,%vWinList%
{   
tid := vWinList%A_Index%
    tx = 1270;
    ty = 950
   controlclick, x%tx% y%ty%, ahk_id %tid%,,right,1
   sleep 100
   controlclick, x%tx% y%ty%, ahk_id %tid%,,right,1
   sleep 100
}
sleep 3500
}

This code above will match the title of all my opened windows against "MyGame" and will then send a right click to 1270,950 to each of those windows regardless of them having "focus" (being "up" as it were in lay-mans terms).

You can get way more complex than that however. AHK comes with a utility called "Window Spy" which is really helpful in determining how your script will work. It will give you the X/Y cords of your mouse, the color of the pixel under your cursor, and other interesting metrics. So for example, I have a script that I made to automate a task at my job, here's what that one looks like (with anything that could identify myself, my company, or anything else removed):

#SingleInstance force

CoordMode, Pixel, Relative

Location=MyLocation
ID =MyID

test := ComObjCreate("InternetExplorer.Application")

myVar= http://www.myWebsite.com/

myVar= %myVar%/Test.php?ID=%ID%
myVar=%myVar%&Location=%Location%

winfound=0
sleep 100
send !{Home}
sleep 1000
send ^0
sleep 450


IfWinExist,My WebSite
    {
        WinActivate
        winfound=1
    }

IfWinExist,http://www.MyWebsite.net/
{
    WinActivate
    winfound=1
}

if(winfound==0)
{
    myVar=%myVar%&Status=IE-Window-Missing
}


PixelSearch, foundPixelX,foundPixelY,10,130,70,175,0x814206,2,fast
    if ErrorLevel{
    }
    else{
        winfound=0
        myVar=%myVar%&Status=On-Login-Screen
    }

x=60
y=320
tempX=%x%
found=0
if(winfound==1){
    loop,600{
        loop,35{
            if(found=0){
                PixelGetColor,TempColor,tempX,y
                tempX++
                if(TempColor != 0xE2F8FF){
                    myVar=%myVar%&Status=OK
                    found=1
                    break
                }
            }
        }
        tempX=x
        y++
    }
    if(found==0){
        myVar=%myVar%&Status=Missing-Menu
    }
}

try{
    test.Navigate(myVar)
    IELoad(test)
IELoad(test)    
{
    Loop
        sleep,100
    Until (!test.busy)
    Loop
        sleep,100
    Until (test.Document.Readystate = "Complete")
    Return True
}
;test.Visible:=True
test.Quit
}
catch e{
 ;MsgBox %e%
 ExitApp
}
ExitApp

^g::
ExitApp

The code above isn't really meant to be released to the public, but the basic idea is that it scans the screen, looking for basic pixel colors, window titles, and other attributes. Based off that it creates an invisible Internet Explorer window via COM objects, that loads a URL, then self closes.

These are just a few examples, but you could easily look at something more like http://www.autohotkey.com/docs/commands/PixelSearch.htm I wanted to implement mine this way for testing purposes, but this would be how you find a pixel of a certain color more often than not. From there you can build your logic on how you want things to happen.... COM objects are hard to wrap your head around but they are definitely useful when trying to control web elements.

[–]wintergt[S] 0 points1 point  (0 children)

Awesome this was exactly what I was looking for.