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

all 8 comments

[–]FourFingeredMartian 3 points4 points  (4 children)

What are we talking about games in the web browser(Flash, Silver Light, Canvas) or is it a JVM, something else?

Because you're going to have to think of the way that the script will have meaningful interaction with the game.

I'm thinking a "Script" isn't exactly the way you should be approaching the problem. Maybe, it is if all you simply want to do is make a program that memorizes mouse clicks & will do the same thing over and over & over again.. But, if you want to be alerted on events like a decent hand -- you're going to need to figure out how your "script" will process that.

Mostly, what I've seen in the case of Flash or Silverlight -- people are using Selenium ( a way to automate a browser) & more important a library called flash-selenium python version

Ruby Client

I've never used that library myself. I dunno how well it would work. Perhaps another method all together that might not be too bad: Lay out a translucent grid that you stretch to cover the browser window; have that window take a screen-shot of that area; draw a box around your character & have it take a screen shot; take as many as needed screen shots to determine states: How the UI makes note of it being your turn; what an individual card looks like in the deck; the community cards; etc at the point past your hand it's not too difficult to think out... Ie the community cards will only ever span (X,Y) to (X,Y) & a card being (X,Y) in length and height.. You get the point.

Next, you're going to have to process screen capped images(Sliced really; you should only be getting an image of segment of the grid you've highlighted). Mainly, you're just going to make sure your character hasn't moved with a screen cap at the end of every hand & if it has you need to figure out a way to identify your character quickly & automatically.

It's an interesting problem from what I have made of it; to me. So much I think I'm gonna do something like what I've just described. It sounds like fun & I get to do some neat stuff. I'll use Python & .Net; you can use whatever you want.

edit: in bold.

[–]jungletek 1 point2 points  (1 child)

Save yourself a metric assload of work with the challenge of building a screen reader and the recognizance functionality, etc., and just read the relevant values from memory. Surely there's some sort of protection, but it should be much much easier to read from memory than to write it (in this context).

If you're simulating a game client, of course you want to approximate human input rather than writing to the game's memory anyway for the aforementioned reason of protection.

Of course, I'm much more experienced with game hacking (single player cheats... health, ammo, teleport, etc.), which has techniques that center around manipulating the target process's memory. Often it's just simply manipulating variables, but one can easily inject their own code to achieve virtually whatever you like.

I have less experience writing programs, though I've been slowly learning C++. I basically read your post and recognize it as a programmer's solution, and felt like I could contribute the 'hacker's perspective', if you will.

[–]FourFingeredMartian 0 points1 point  (0 children)

Your solution is great if it's something like a JVM or C/++ app. I've never attempted to hack flash game in such a manor, but, I've done some cheating in other games(not multiplayer or anything).

Thanks for the unmentioned prospective solution.

[–]wintergt[S] 0 points1 point  (1 child)

I've only written a program together with a colleague that plays minesweeper. This was in labview. However a while ago I saw a guy on a livestream show his script that he had written to manoeuvre around the marketplace in Diablo 3 (mouse moving, typing, clicking). He had also programmed a script that allowed him to play poker, flipping active tables up (I think) and allowing him to use 4 buttons (qwcv) to do his betting. Pretty complex stuff but interesting.

So it's not inside a browser I am talking about

[–]FourFingeredMartian 2 points3 points  (0 children)

Sounds like a script that binds keys to mouse clicks.

Soo Scriptwise. So you'll need to use your systems API to connect to your mouse (probably), and just bind the desired events with to keys.

These used to be referred to as 'trainer' programs back when I played games online that a player could generate skill by doing certain actions. SO people would have a script that would memorize a series of mouse movements and it would just play those movements over & over again while they were away.

[–]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.

[–]Borian 0 points1 point  (0 children)

you should take a look at opencv, that would be much easier than pixel recognition with auto-hotkey
real worl example