Jump to content

key down & key up


Recommended Posts

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

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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 )
Link to comment
Share on other sites

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 by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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.

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