abraXas Posted June 1, 2009 Posted June 1, 2009 Ok, I wanted a script to test a guitarhero-like game that sends the right key for a note at the right time and for the right duration. I've tried it like this: $yellow = PixelSearch (left, top, right, bottom, color , shade-variation) If Not @error Then Send("{1 down}") Sleep($sleep) $i = 0 ElseIf @error Then Send("{1 up}") $i = 1 EndIf If $i = 1 Then Sleep($sleep2) EndIf So it searches the colour in the defined area and when found, it sends and holds 1 until the colour is no more found in this area. $i should lower the cpu usage. And the problem is, that when i send 1 he doesn't release it after the colour is long out of the area. The moment it releases the key appears rather random to me. And also if i press any other key not in the script, the key is hold and only released when the script quits or pauses. I've tried this also with multiple notes and the script only hits about 50% and the duration seems totally random. Whereas with this script: $yellow = PixelSearch (left, top, right, bottom, color , shade-variation) If Not @error Then Send("{1}") Sleep($sleep) $i = 0 ElseIf @error Then $i = 1 EndIf If $i = 1 Then Sleep($sleep2) EndIf it hits 100% but (ofcourse) it doesnt hold them for the right duration. I'm gratefull for help. Regards
lordicast Posted June 1, 2009 Posted June 1, 2009 that would totally take all the fun out of the game... [Cheeky]Comment[/Cheeky]
martin Posted June 1, 2009 Posted June 1, 2009 Ok, I wanted a script to test a guitarhero-like game that sends the right key for a note at the right time and for the right duration. I've tried it like this: $yellow = PixelSearch (left, top, right, bottom, color , shade-variation) If Not @error Then Send("{1 down}") Sleep($sleep) $i = 0 ElseIf @error Then Send("{1 up}") $i = 1 EndIf If $i = 1 Then Sleep($sleep2) EndIf So it searches the colour in the defined area and when found, it sends and holds 1 until the colour is no more found in this area. $i should lower the cpu usage. And the problem is, that when i send 1 he doesn't release it after the colour is long out of the area. The moment it releases the key appears rather random to me. And also if i press any other key not in the script, the key is hold and only released when the script quits or pauses. I've tried this also with multiple notes and the script only hits about 50% and the duration seems totally random. Whereas with this script: $yellow = PixelSearch (left, top, right, bottom, color , shade-variation) If Not @error Then Send("{1}") Sleep($sleep) $i = 0 ElseIf @error Then $i = 1 EndIf If $i = 1 Then Sleep($sleep2) EndIf it hits 100% but (ofcourse) it doesnt hold them for the right duration. I'm gratefull for help. Regards I'm not quite clear about what you want to do. I can see that you want to hold down a key for a certain time when a pixel is yellow say, but must successive notes occur at fixed time intervals? And if the pixel stays yellow should the key be ket down? And should the key always be held down for a time $sleep or should it be stoipped as soon as the pixel changes from yellow? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
oMBRa Posted June 1, 2009 Posted June 1, 2009 I'm not quite clear about what you want to do. I can see that you want to hold down a key for a certain time when a pixel is yellow say, but must successive notes occur at fixed time intervals? And if the pixel stays yellow should the key be ket down? And should the key always be held down for a time $sleep or should it be stoipped as soon as the pixel changes from yellow?I think the OP want if the pixel stays yellow the key should be held down, and should be relased as soon as the pixel changes from yellow, and succesive notes doesnt occur at fixed time. ( I think it is what the OP want because I know that game )
abraXas Posted June 1, 2009 Author Posted June 1, 2009 Right, that's what I want. I know that I need a While-WEnd loop, the code is only a snippet.
bogQ Posted June 1, 2009 Posted June 1, 2009 (edited) so something simylar to this shud help? $color = "0xFFFFFF" Do $yellow = PixelSearch (left, top, right, bottom, $color , shade-variation) Sleep(50) Until IsArray($yellow) Send("{a down}") ;Holds the A key down Do $yellow1 = PixelSearch (left, top, right, bottom, $color , shade-variation) Sleep(50) Until Not IsArray($yellow1) Send("{a up}") ;Releases the A key Edited June 1, 2009 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
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