Jump to content
Sign in to follow this  
Vegar

Send keystroke to window

Recommended Posts

Vegar

Hello..

with a Hotkey How could i send a keystroke (Ctrl+{Right}) to another window without opening that window? :)

Share this post


Link to post
Share on other sites
Tinutron

You can do this using ControlSend. Read the helpfile for more information. :)

Share this post


Link to post
Share on other sites
Vegar

I've tried this but i dont get it to work

but i'l try to explane better...

If i have the Spotify (music program) window active on the screen and push the buttons: Ctrl+{Right} then it changes song...

but when i have another window open/Active this hotkey does not work..

And i want this hotkey to work even do i have another window open..

ive tried the Controlsend, but i just do not get it to work :S

Share this post


Link to post
Share on other sites
Tinutron

Does the titel of your musicplayer change, when another song is playing? And can you maybe post some code?

Share this post


Link to post
Share on other sites
Vegar

Yes i changes for each song

Hotkeyset ("^{RIGHT}","Right")

while 1

sleep (10)

wend

Func Right ()

ControlSend("Spotify", "", "", "^{LEFT}")

EndFunc

Share this post


Link to post
Share on other sites
Tinutron

So if it changes, you cant just use "spotify" as its title, or am i wrong? :)

Share this post


Link to post
Share on other sites
Vegar

yesh i think that would work?!?!

or?

Share this post


Link to post
Share on other sites
AgentSmith15

Every post you make is "How do I do this"....

I don't think anyone's going to write it for you.

Share this post


Link to post
Share on other sites
oMBRa

Hotkeyset ("^{RIGHT}","Right")


while 1
sleep (10)
wend

Func Right ()

$a = ControlSend("Spotify", "", "", "^{LEFT}")
msgbox(0, '', $a)
EndFunc

if $a = 0 then the window title is wrong...

Share this post


Link to post
Share on other sites
Vegar

Hmm, i got it to work to some degree...

it changes the song but it seems like it holds Ctrl in, so it is imposible to do anything else on the computer..??

and the "Space" Func does not work!?!, i dont know why...

and the "Up"/"Down" Func is ment to adjust the volume, but i cant just hold the Ctrl button, i must push the button for each step.. why so?

Hotkeyset ("^{RIGHT}","Right")

Hotkeyset ("^{LEFT}","Left")

Hotkeyset ("^{UP}","Up")

Hotkeyset ("^{DOWN}","Down")

Hotkeyset ("^{SPACE}","space")

while 1

sleep (10)

wend

Func Right ()

$a = ControlSend("Spotify", "", "", "^{RIGHT}")

EndFunc

Func Left ()

$b = ControlSend("Spotify", "", "", "^{LEFT}")

EndFunc

Func Up ()

$c = ControlSend("Spotify", "", "", "^{UP}")

EndFunc

Func Down ()

$d = ControlSend("Spotify", "", "", "^{DOWN}")

EndFunc

Func Space ()

$e = ControlSend("Spotify", "", "", "{SPACE}")

EndFunc

Edited by Vegar

Share this post


Link to post
Share on other sites
Vegar

Is not that better than writing "Bump" in a new post?

Share this post


Link to post
Share on other sites
Authenticity

You can add additional function or the same lines in every function to loop until the ctrl key is released.

#include <Misc.au3>
$hDll = DllOpen('user32.dll')
;....
;....

Func OnAutoItExit()
    DllClose($hDll)
EndFunc

Func CtrlRelease()
     While _IsPressed('11', $hDll)
           Sleep(50)
     WEnd
EndFunc

Func Hoyre ()
     CtrlRelease()
     $a = ControlSend("Spotify", "", "", "^{right}")
EndFuncoÝ÷ Úò¢çǧuËkêr¢êìçÚºÚ"µÍÙ[
    ÌÎNÞÐÕTIÌÎNÊ

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  

×