Jump to content

Send keystroke to window


Recommended Posts

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

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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Ê
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...