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