Jump to content

_IsPressed problem


LordNeo
 Share

Recommended Posts

I usually don't ask for help but in this case I really can't seem to find the answer I'm looking for elsewhere.

I've been writing autoit scripts for years from extreme basic to moderately advanced but this input problem is puzzling me.

Here's the simple script.

#include <Array.au3>
#include <Misc.au3>

HotKeySet("{F9}", "quit");hotkey to quit

While 1==1
    While _IsPressed("58")
        Send("x")
    WEnd
WEnd

func quit()
  MsgBox(0, "Goodbye", "DOH!")
  Exit
EndFunc

Basically the script works fine it spams the x key just great.

However it seems the way IsPressed works is not good enough for a turbo button.

If you press X and hold it great it will work but if you press anything else while holding it then it will forget it is pressed.

So what I'm looking for is what other scripting languages usually call states.

Is there an easy way to view current key states (up / down) or even a manual way to store the information in an array?

Thank you!

Link to comment
Share on other sites

#include <Misc.au3>
Global $turbo
$dll = DllOpen("user32.dll")
HotKeySet("{PAUSE}", "Turbo")
Func Turbo()
    $turbo = NOT $turbo
    While $turbo
        Send("x")
    WEnd
EndFunc
While 1
    if _IsPressed("31", $dll) Then
        send("1")
    EndIf   
WEnd

Press the "Pause" button to enable turbo. You can press any button while "turbo" is initiated.

Edited by harmor
Link to comment
Share on other sites

Thank you for the suggestion though I am trying to make it so it's turbo while I am holding the button.

I am aware I could use a toggle but it is a lot less convenient.

This is why I felt I would need to somehow read the key states.

Link to comment
Share on other sites

Bump

Could still use help on this.

I had to use another program that I really dislike because it is pretty much garbage to achieve these results and I would much prefer to do it with autoit... lol

Edit: Something such as _IsReleased would be GREAT!

I have found the problem it's actually quite simple though I could still use some assistance with how to work around this 'flaw' if you will

While 1 == 1
    If _IsPressed("58") Then
        Send("{x down}")
        Sleep(75)
        Send("{x up}")
    EndIf
WEnd

Ok so 58 is the code for X being pressed right?

Well Since the script is pressing and releasing it it ends that part of the script when another key is pressed... /hmm

If I change the key the script pushes to anything else it's fine.

So the question has slightly changed. How do I use _IsPressed for the same key without causing this problem?3

Another Edit:

More developments...

Using controlsend instead of just send will fix this issue... interesting isn't it?

Edited by LordNeo
Link to comment
Share on other sites

This UDF has the exact same issues ;) Unfortunately

So this now brings up the question to possibly pursue the ControlSend work around....

How in the world can I find the controlID for a directX program? (gave up on this forever ago...)

I've already searched this topic many times in the past and even recently but it always ends up going nowhere.

Same thing always said... window info shows blank controlID...

Edited by LordNeo
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...