Sign in to follow this  
Followers 0
LordNeo

_IsPressed problem

8 posts in this topic

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!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Uhmm try this http://www.autoitscript.com/forum/index.php?showtopic=86296&hl=_ispressed%20udf&st=0

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

i dont know the id but u can try with this ControlSend("[active]", "", "", "msg")

Share this post


Link to post
Share on other sites

Try this

#include <Misc.au3>
$dll = DllOpen("user32.dll")
While 1
    if _IsPressed("58", $dll) Then
        send("{x down}")
    EndIf   
WEnd

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