Some Posted February 20, 2006 Share Posted February 20, 2006 Hello, allAs 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 easyAnyhow, I have created a script that plays BlackJack on a website in Firefox. Here you can see it in action: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 againOk, 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 method2) 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 exampleWell, 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 knowCheers Link to comment Share on other sites More sharing options...
Valuater Posted February 20, 2006 Share Posted February 20, 2006 Welcome to the forums!!! nice first post just a small idea $Rn = "5" $Wn = "3" $Ls = "2" $Mny = "$10.00" TrayTip("Runs= " & $Rn & " Wins= " & $Wn & " Losses= " & $Ls &" Bank= " & $Mny, "My Game Machine", 5, 1) Sleep(8000) 8) Link to comment Share on other sites More sharing options...
Some Posted February 20, 2006 Author Share Posted February 20, 2006 (edited) 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: expandcollapse popupHotKeySet("^!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 Edited February 20, 2006 by Some Link to comment Share on other sites More sharing options...
Valuater Posted February 20, 2006 Share Posted February 20, 2006 nice... you could put aRun(mozilla Firefox) at the start... then when you run your program it will run firefox for you 8) Link to comment Share on other sites More sharing options...
Some Posted February 20, 2006 Author Share Posted February 20, 2006 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 Link to comment Share on other sites More sharing options...
greenmachine Posted February 20, 2006 Share Posted February 20, 2006 Just curious since not everyone has Firefox - would using Internet Explorer work? Then you could use the IE.au3 library and have a much more reliable script. Link to comment Share on other sites More sharing options...
Some Posted February 20, 2006 Author Share Posted February 20, 2006 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 More sharing options...
greenmachine Posted February 20, 2006 Share Posted February 20, 2006 I like Firefox as well, it's just that I have been automating IE recently so I thought I'd bring it up.http://www.autoitscript.com/forum/index.php?showtopic=13398In case you need the link. Link to comment Share on other sites More sharing options...
Some Posted February 20, 2006 Author Share Posted February 20, 2006 Thanks, gonna check it out Link to comment Share on other sites More sharing options...
themax90 Posted February 20, 2006 Share Posted February 20, 2006 Hey, I wrote a Blackjack game in AutoIt. Check it out in my signature. AutoIt Smith Link to comment Share on other sites More sharing options...
Valuater Posted February 20, 2006 Share Posted February 20, 2006 Thanks, gonna check it outYou should check out this IE.au3 Builder alsohttp://www.autoitscript.com/forum/index.php?showtopic=19368#8) Link to comment Share on other sites More sharing options...
Some Posted February 21, 2006 Author Share Posted February 21, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now