Jump to content
Sign in to follow this  
unknown12

Quick Question

Recommended Posts

unknown12

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
automagician

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
unknown12

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

Share this post


Link to post
Share on other sites
automagician

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

Share this post


Link to post
Share on other sites
Blue_Drache

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
automagician

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.