Sign in to follow this  
Followers 0
Vindicator209

Hold Key Down

6 posts in this topic

#1 ·  Posted (edited)

My script here is supposed to hold space down until the selected pixel becomes a certain color... however, it only presses the space key ONCE... I put msgboxes in there to do testing, the msgboxes tell me the information is still the same, yet it STILL only hit space once!

You can remove the msgboxes, but it still yeilds the same result =(

HotKeySet("{END}","sent")
HotKeySet("{HOME}","set")
$pos = -1
$pix = -1
Sleep(2000)
SplashOff()
While 1
    Sleep(1000)
WEnd
Func sent()
    If $pix <> -1 Then
        Send("{SPACE DOWN}")
        While 1
            If PixelGetColor($pos[0],$pos[1]) = $pix Then
                MsgBox(0,"",$pos[0]&" "&$pos[1]&" "&$pix)
                Send("{SPACE UP}")
                ExitLoop
            EndIf
        WEnd
    EndIf
EndFunc
Func set()
    $pos = MouseGetPos()
    $pix = PixelGetColor($pos[0],$pos[1])
        MsgBox(0,"",$pos[0]&" "&$pos[1]&" "&$pix)
EndFunc
Edited by MethodZero

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You could have it repeatedly send SPACE, like below. I'm not sure why your code isn't working, it looks alright at a quick glance.

Func sent()
    If $pix <> -1 Then
        While 1
            Send("{SPACE}")
            If PixelGetColor($pos[0],$pos[1]) = $pix Then
                MsgBox(0,"",$pos[0]&" "&$pos[1]&" "&$pix)
                ExitLoop
            EndIf
        WEnd
    EndIf
EndFunc
Edited by mikehunt114

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

Well, okay I just tried this, however, it wont work in-game because you have to hold the key down to move the power meter, have you ever played Gunbound?

Anyway,

MsgBox(0,"",PixelGetColor($pos[0],$pos[1])&" "&$pix)

Now, I put that before

If PixelGetColor($pos[0],$pos[1]) = $pix Then

And it is working as it should, however it STILL only presses it once XD


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites

If you're looking to hold space until the color changes, I think maybe you need this instead of your current if statement:

If PixelGetColor($pos[0],$pos[1]) <> $pix Then

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

Well, no, see, PRESSING HOME will set what $pix is, then, pressing END will hold SPACE untill the pixel is equal to $pix again (because the bar is resets every time)


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites

Your script is probably seeing the color at the position before anything happens after you press space (I'm assuming after you hit space the color at the position you reecorded changes). So just add an appriopriate sleep in between hitting space and checking for the color.


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
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
Sign in to follow this  
Followers 0