Sign in to follow this  
Followers 0
unknown12

Quick Question

7 posts in this topic

How would I make a sound play when the "U" key is pressed on the keyboard?

thanks

(I have looked the manual)

Share this post


Link to post
Share on other sites

I got it :)

Share this post


Link to post
Share on other sites

What did you use?

I was going to say use something with this statement, but I didn't get it working yet:

$ret = DllCall("user32.dll","short","GetAsyncKeyState","int", "55")

Share this post


Link to post
Share on other sites

HotKeySet("u","HotKeyFunction")
func HotKeyFunction()
    soundplay(@ScriptDir & "sound.mp3")
EndFunc

Share this post


Link to post
Share on other sites

Wow, I was making it much harder than it had to be :)

Share this post


Link to post
Share on other sites

What did you use?

I was going to say use something with this statement, but I didn't get it working yet:

$ret = DllCall("user32.dll","short","GetAsyncKeyState","int", "55")

<{POST_SNAPBACK}>

LoL... overly complicated, but probably a good learning experience anyway. I'd be interested in seeing if you can get it done with a DLL call....that way you don't have to tie up a hotkey with "HotKeySet"

:)


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

How about this:

$initial = DllCall("user32.dll","short","GetKeyState","int", 0x55)
While 1
    $ret = DllCall("user32.dll","short","GetKeyState","int", 0x55)
    If NOT ($ret[0] = $initial[0]) Then 
       ; Do what you want here!!!
        Exit(0)
    EndIf
WEnd

Now you don't have to tie up the HotKey :)

Edited by automagician

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