Andaho Posted February 13, 2007 Share Posted February 13, 2007 Hello, I'm really new to all this programming stuff and am trying to make a really basic script for a game... It waits for the on screen cursor to turn red (target in cursor) and then shoots. It doesn't work very well, can anyone help me with this basic script to make it work properly? WinWaitActive("Game") While WinActive("Game") While PixelGetColor(555, 432) <> 13107200 Sleep(1) WEnd Send("p") WEnd Thanks, Andaho. Link to comment Share on other sites More sharing options...
Zedna Posted February 13, 2007 Share Posted February 13, 2007 (edited) It doesn't work very well What's the exact problem? EDIT: Your script looks good WinWaitActive("Game") While WinActive("Game") While PixelGetColor(555, 432) <> 13107200 Sleep(1) WEnd Send("p") WEnd Edited February 13, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Andaho Posted February 13, 2007 Author Share Posted February 13, 2007 It only seems to randomly work... sometimes I'll hover over a target and it will shoot right away, sometimes I'll hover a target and it will shoot after a second or 2... sometimes it just doesn't shoot at all. I thought at first that maybe the colour of the pixel changes different shades of red, but when it wasn't firing I took a screenshot and checked the colour and it was the shade I originally found. I just don't understand why it doesn't work properly... is there a better way of doing code for this job? Link to comment Share on other sites More sharing options...
Andaho Posted February 13, 2007 Author Share Posted February 13, 2007 Also, I'm a little confused as to how I got the loop working... I was expecting to use some kind of 'goto line' command to make it loop, but when I discovered there is no goto command I read about the While commandand didn't understand it but made the code this way anyway... I don't understand why the script never ends, with the game open, or when you close it, the script keeps running... I was expecting from the code I wrote, that it would end when you minimize the game, from the window not being active anymore. Link to comment Share on other sites More sharing options...
Zedna Posted February 13, 2007 Share Posted February 13, 2007 (edited) WinWaitActive("Game") While 1 If WinActive("Game") Then While PixelGetColor(555, 432) <> 13107200 Sleep(1) WEnd Send("p") EndIf WEnd For pixel shade use PixelSearch with the same Left/Right Top/Bottom positions (only for your one pixel) You may also use some Hotkeys for activate/deactivate your script see HotkeySet() Edited February 13, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Andaho Posted February 13, 2007 Author Share Posted February 13, 2007 Hi, thanks for the speedy reply and edited code... it works the same with that code... what is the 1 in the "while 1" command? it's weird because sometimes it shoots like a machine gun but other times a big delay or nothing. Link to comment Share on other sites More sharing options...
jessem Posted February 13, 2007 Share Posted February 13, 2007 WinWaitActive("Game") While 1 If WinActive("Game") Then While PixelGetColor(555, 432) <> 13107200 Sleep(1);This isnt much of a delay WEnd Send("p") EndIf WEnd Sleep(1) may be whats causing the lag on your system when its checking the color. Bump it up to (250) or (500) and you should see some performance improvements. Link to comment Share on other sites More sharing options...
Andaho Posted February 13, 2007 Author Share Posted February 13, 2007 (edited) Thanks for another reply, I will try increasing the pause after I fix this problem... this keeps coming up with While and Wend errors and I can't work out why! CODEWinWaitActive("Game") While 1 If WinActive("Game") Then PixelSearch( 555, 432, 555, 432, 0xC80000, 1000 ) If Not @error Then Sleep(1) WEnd Send("p") EndIf WEnd Edited February 13, 2007 by Andaho Link to comment Share on other sites More sharing options...
Zedna Posted February 13, 2007 Share Posted February 13, 2007 (edited) Sleep(1) may be whats causing the lag on your system when its checking the color. Bump it up to (250) or (500) and you should see some performance improvements. Yes: WinWaitActive("Game") While 1 If WinActive("Game") Then While PixelGetColor(555, 432) <> 13107200 Sleep(100) WEnd Send("p") EndIf Sleep(100) WEnd Edited February 13, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Andaho Posted February 14, 2007 Author Share Posted February 14, 2007 ok, it still behaves the same apart from it never fires super fast anymore - it still sometimes never fires, or takes ages before it fires. and I gave up on the pixel search command cause I kept comming up with errors with end commands Link to comment Share on other sites More sharing options...
Andaho Posted February 14, 2007 Author Share Posted February 14, 2007 Ok, I have an update already, I changed the "send ("p")" to a left mouseclick and it works more often now! but still irratically, still want to know if anyone knows why it might be behaving irratically. 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