MadChen Posted July 19, 2009 Posted July 19, 2009 Hey everyone, I have a simple code to heal myself whenever I get low on health in a game. It works... except when I'm actually playing the game. Basically, the code searches a certain area of the health bar for the background color and if it finds it, it drinks a potion. I know it works because it brings up the F1 help menu when I put something of that color in those pixel areas without running the game haha. But when I'm actually playing, the code doesn't work. I tried testing it by using one MouseClick function at the beginning but that didn't register either. $c_HPBar = PixelSearch(370, 160, 420, 170, 0x4a4531, 0) If Not @error And IsArray($c_HPBar) Then Send("{F1 1}") ;Drink potion. Sleep(3000) EndIf The game is GoonZu online, or I guess Luminary Online now. I was wondering if anyone had any idea why this was happening?
Authenticity Posted July 19, 2009 Posted July 19, 2009 Can you post some more code if you have. Another thing may be that pressing another key while you have another key already pressed may not work, not sure but possible.
DYONISII Posted July 19, 2009 Posted July 19, 2009 (edited) hmmm... Send("{F1 1}") ;Drink potion <<-- actually just sends F1 once. if you have Send("{F1 2}"), this will send F1 twice. the second value indicates how many times the key should be pressed. perhaps you may have meant: Send("{F1}") Send("1") and since this is supposed to be an online game, i'd say you should consider latency and give it a wait, such that: Send("{F1}") Wait(500) Send("1") hope this helps. Edited July 19, 2009 by DYONISII http://dev.dyonisii.com/
MadChen Posted July 19, 2009 Author Posted July 19, 2009 This is all of my code. HotKeySet("{ESC}", "_Done") HotKeySet("{F7}", "_Start") While 1 Sleep(100) ; WEnd Func _Start() While 1 $c_HPBar = PixelSearch(370, 160, 420, 170, 0x4a4531, 0) ;Search HP bar for background color. If Not @error And IsArray($c_HPBar) Then Send("{F1 1}") ;Drink potion. Sleep(3000) EndIf WEnd EndFunc Func _Done() Exit EndFunc F1 is the hotkey I set up for health potions, so I want it to be pressed once. The code works, just not when I'm running the game. In fact my problem is not that my code doesn't work, but that no code works when I run the game. I tried putting just a MouseClick("left"); Sleep(3000); in the start section and when I'm just using my computer, it works fine, but it doesn't work when I'm in the game window.
Authenticity Posted July 19, 2009 Posted July 19, 2009 So did it ever work in your game? Sending F1 to the focus window will probably work but sending keystroke to your game doesn't work? Maybe you game is resisting automation?
MadChen Posted July 19, 2009 Author Posted July 19, 2009 $c_HPBar = PixelSearch(370, 160, 420, 170, 0x4a4531, 0) ;Search HP bar for background color. If Not @error And IsArray($c_HPBar) Then ControlSend("GoonZu", "", "", "{F1}") ;Send(("{F1 1}") ;Drink potion. Sleep(3000) EndIf Nah, it never really worked with the game. I tried doing a control send to the window itself, but that didn't seem to work either. I heard some others had some success getting automation to run with this game, but maybe things have changed since then. The funny thing is, the game runs in a window, so when I run the code with the game in the background, the code detects the health bar and sends f1, which brings up the help menu. When I'm actually playing the game, it doesn't do anything haha.
MadChen Posted July 20, 2009 Author Posted July 20, 2009 Haha, okay, I found out how to get the code to work in the game. It's kinda ghetto, but basically I wrote a program that opens up the game, enters my info into the fields, selects characters, and then for some reason, the script can do it's thing haha. Just in case someone had a similar problem.
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