Jump to content

Looking for suggestions


Some
 Share

Recommended Posts

Hello, all

As this is my first post, first of all a huge thanks to the AutoIt crew for an amazing app. Having the best coding experiencce with simple languages, like ZX Basic and later QBasic it really is an awesome thing to use, fun and easy

Anyhow, I have created a script that plays BlackJack on a website in Firefox. Here you can see it in action:

Posted Image

What it basically does (simplified description) is selecting certain areas on screen by dragging the mouse, then copying the data to clipboard, then making a choice to get one more card or stand. It waits a little and then goes on again

Ok, my questions are:

1) Right now I use simple Send commands of Ctrl+C to copy the selected bits. This didn't always work so now I have two commands separated by a 250 ms Sleep. It works ok now, but I wonder if there's a more efiicient method

2) Currently for waiting for the page to load I use a preset Sleep value. When using WinActive checks it seems to say a window is active even when the page is still loading. Could there be a more efficient way to judge this?

3) Not seen in the demo above is a TrayTip that I have recently added, with information on how many runs have been done and what gains or losses acquired. Is there any way to format the text it outputs? Make it larger or bold, for example

Well, any other suggestions are welcome as well. I'm sure that my current approach can be improved.

I could throw in the code, but it just uses hard screen coordinates matched to my screen res so it might be of little use, but if that helps do let me know

Cheers

Link to comment
Share on other sites

Thanks for the welcome. It has something similar right now

Thing is it's on a bittorrent tracker (basically a download thing where your upload determines things) and you play with the upload as points. 100 Mb is one bet. So right now the script copies the total upload once at the sart and then again, every cycle, and gives out a traytip with a status report:

;Drags the mouse to select the text to copy and copies it
MouseClickDrag ("left",460,265,490,265,5)
sleep(250)
Send("^c")
sleep(250)
Send("^c")
;Shows a status report on that traytip
TrayTip("BlackJack Status report", "This is run number "&$Test&". Current gains: "&StringFormat( "%.2f" ,Clipget()-$StartCapital)&" Gb", 15, 1)

I wish there was a way to make the numbers big, like size 24 or so, but I guess that's not possible as I have never seen the windows tooltips do that

It won't make much sense, but Iļl just throw in my current code:

HotKeySet("^!x", "MyExit")

$Wait = 15000

AutoItSetOption ("WinTitleMatchMode",2)
WinActivate("Mozilla Firefox")

$Test = 1

MouseClick("left",320,70,1,2)
Send("http://XXXXX/blackjack.php{ENTER}")

sleep($Wait)

MouseClickDrag ("left",460,265,490,265,5)
sleep(250)
Send("^c")
sleep(250)
Send("^c")
$StartCapital = ClipGet()

while $Test < 100

MouseClick("left",475,335,1,2)
sleep(Random($Wait,$Wait+3000,1))

MouseClickDrag ("left",460,265,490,265,5)
sleep(250)
Send("^c")
sleep(250)
Send("^c")
TrayTip("BlackJack Status report", "This is run number "&$Test&". Current gains: "&StringFormat( "%.2f" ,Clipget()-$StartCapital)&" Gb", 15, 1)

ClipPut("")
MouseClickDrag ("left",520,390,750,390,5)
sleep(250)
Send("^c")
sleep(250)
Send("^c")
ToolTip (ClipGet())
if ClipGet() <> "" AND ClipGet() <> "BlackJack" then
    $Dive = 50
else
    $Dive = 0
EndIf

MouseClick("left",640,620+$Dive,1,2)

sleep($Wait)

$Points = 0

;$Limit = 17
$Limit = Random(16,17,1)

Do
  ClipPut("")
  MouseClickDrag ("left",250,385+$Dive,350,385+$Dive,5)
  sleep(250)
  Send("^c")
  sleep(250)
  Send("^c")
  ToolTip (ClipGet())
  if ClipGet() = "Game Over" OR ClipGet() = "Spēle galā" OR ClipGet() = "Sasodīts ..." then
    ExitLoop
  EndIF
  ClipPut("")
  MouseClickDrag ("left",550,530+$Dive,700,530+$Dive,5)
  sleep(250)
  Send("^c")
  sleep(250)
  Send("^c")
  ToolTip (ClipGet())

$Points = StringRight(ClipGet(),2)
StringStripWS ($Points,8)

  ToolTip ($Points)
    if $Points > $Limit then
    MouseClick("left",640,590+$Dive,1,2);
    sleep($Wait)
    ExitLoop
    EndIF
  MouseClick("left",640,560+$Dive,1,5)
  sleep($Wait)
Until $Points > $Limit

$Test = $Test+1
WEnd

Func MyExit()
    Exit
EndFunc

Some of the weird things it does in the middle ar for checking if there are any extra messages so the screen controls have shifted and maybe it should click lower or higher. Actually I should make it do that every time it clicks something, but usually it works :o

Edited by Some
Link to comment
Share on other sites

I had that. But since Firefox is almost always open anyways it's not in there currently. In theory I would build a completely self sufficient script, that could run Firefox, play some amount of games, save the statistics to a file and quit. But that's far away :o

Link to comment
Share on other sites

In theory using IE would work, Firefox is just a personal preferrence (due to security, tabs, etc, etc)

I assume the IE.au3 library is a set of functions that ease interfacing with IE? Wish there was one for Firefox, but I'll have a look at it, thanks for the tip

Link to comment
Share on other sites

That blackjack game thread had some interesting info, thanks for the heads up

Also, gotta look into using IE, even though I'm not too fond of it

Still, any ideas if anything could be more efficient for copying things than sending a Ctrl+C command using send and the other qustions?

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