Jump to content

Other alternative to Hotkeyset


Vegar
 Share

Recommended Posts

Hello

I have made a small script witch does that i can change the song in the music-player without having to open the music-players window..

realy simple script witch i have used "Hotkeyset's", and "controlsend" in func's..

the button's i use is Ctrl + Arrow

but the problem is that i have to release the Ctrl before the song changes.. so its preaty annoying when i'm going to change many song..

so i woundered if there was any way possible that i can hold the Ctrl-button, and that the song changes at once i hit the right/left arrow?

Thanx for all help :)

Link to comment
Share on other sites

Maybe

#include <Misc.au3>

$dll = DllOpen("user32.dll")
$key = 11 ;$key = 11 (CTRL key)
$switchkey = ;set here your keys to change song

While 1
    Sleep ( 250 )
    If _IsPressed("$key", $dll) Then
Send($switchkey); Maybe you need to use controlsend, i hate control send =]
    EndIf
WEnd
DllClose($dll)

I think i am on good way to do this :)

Link to comment
Share on other sites

Hmm, this made the song change if i only hit the Ctrl button ... nad i dont know what happend but seemd like the Ctrl was stuck or something, because the pc acted all weird after i had run the script.. like if the Ctrl button was down...

the ide'a was that if i hold Ctrl and then hit Right Arrow then it changes song, and i can hold the Ctrl button and just skip to next song by pushing the right arrow again without realysing the Ctrl button between each song..

I tried this

#include <Misc.au3>

$dll = DllOpen("user32.dll")
$key = 11 ;$key = 11 (CTRL key)
$switchkey = "^{RIGHT}" ;Ctrl + "Right Arrow" to change to next song

While 1
    Sleep ( 50 )
    If _IsPressed(11, $dll) and _IsPressed (27, $dll) Then ;11 = Ctrl ... 27 = Right Arrow
ControlSend ("MusicProgramTitle","","",$switchkey)
    EndIf
WEnd
DllClose($dll)

But with these i had to realease the Ctrl button between each song :/

Link to comment
Share on other sites

So what's the problem with Hotkeyset? Works just fine for me

HotKeySet("^{DOWN}","_down")
HotKeySet("^{UP}","_up")
HotKeySet("{esc}","_exit")

$win = GUICreate("Test123")
GUISetState(@SW_SHOW)
$trans = 255

While 1
    Sleep(10)
WEnd

Func _down()
    $trans-=20
    WinSetTrans("Test123","",$trans)
EndFunc

Func _up()
    $trans+=20
    WinSetTrans("Test123","",$trans)
EndFunc

Func _exit()
    Exit
EndFunc

Hi ;)

Link to comment
Share on other sites

So what's the problem with Hotkeyset? Works just fine for me

HotKeySet("^{DOWN}","_down")
HotKeySet("^{UP}","_up")
HotKeySet("{esc}","_exit")

$win = GUICreate("Test123")
GUISetState(@SW_SHOW)
$trans = 255

While 1
    Sleep(10)
WEnd

Func _down()
    $trans-=20
    WinSetTrans("Test123","",$trans)
EndFunc

Func _up()
    $trans+=20
    WinSetTrans("Test123","",$trans)
EndFunc

Func _exit()
    Exit
EndFunc

yeah it works alright... but when i try just that with ControlSend when i'm finnished changeing song it seems like the Ctrl Button is stuck ... so it holds the Ctrl button down until i hit the button myself again, then it "realeses"

HotKeySet("^{RIGHT}","_RIGHT")
HotKeySet("^{LEFT}","_LEFT")
HotKeySet("{esc}","_exit")


While 1
    Sleep(10)
WEnd

Func _right()
        Controlsend ("MusicPlayerTitle","","","^{Right}")
EndFunc

Func _left()
    Controlsend ("MusicPlayerTitle","","","^{Left}")
EndFunc

Func _exit()
    Exit
EndFunc
Edited by Vegar
Link to comment
Share on other sites

Simple solution: Unbind the hotkey!

Help file says how.

Hmm, turned in to a litle problem with this "Unbinding"

Now it works to change 2 songs, but then i have to release the Ctrl button to change more songs :/

but at least now the Ctrl button did not get "Stuck", dow evrything else worked fine..

but i'm unsure if i understand the "Unbinding" concept?

anyways, here is what i tried:

HotKeySet("^{RIGHT}","_right")
HotKeySet("^{left}","_left")


While 1
    Sleep(10)
WEnd

Func _right()
    ControlSend ("Spotify","","","^{Right}")
    call ("unbind")
EndFunc

Func _left()
    ControlSend ("Spotify","","","^{left}")
    call ("unbind")
EndFunc

func unbind()
    HotKeySet("^{RIGHT}","_right")
    HotKeySet("^{left}","_left")
EndFunc
Link to comment
Share on other sites

hmm, i'm not understanding this ... i've trid just what you say, and exactly what it says in the help file ... but i'm not getting it to work :/

This works only for changeing 2 songs?! :S

HotKeySet("^{RIGHT}","_right")    

While 1     
   Sleep(10) 
WEnd    

func _right()       
    HotKeySet ("^{RIGHT}")  ;1: unbind
    ControlSend ("Musikprogram","","","^{right}")   ;2 Send hotkey
    HotKeySet("^{RIGHT}","_right");3 rebind
EndFunc
Edited by Vegar
Link to comment
Share on other sites

hmm, i'm not understanding this ... i've trid just what you say, and exactly what it says in the help file ... but i'm not getting it to work :/

This works only for changeing 2 songs?! :S

HotKeySet("^{RIGHT}","_right") 

While 1 
 Sleep(10) 
WEnd 

func _right()   
 HotKeySet ("^{RIGHT}")     ;1: unbind
 ControlSend ("Musikprogram","","","^{right}")  ;2 Send hotkey
 HotKeySet("^{RIGHT}","_right");3 rebind
EndFunc

I think your problem is the fact that you are using a modifyer key in a HotKeySet combination which is used to start sending text in some way. This results in the modifyer key being 'stuck' down if it has not been released befor ethe text is sent. The only way I can think of to stop this is to use the approach in a post I made here but this would mean that you would need to release the keys, including the Ctrl key, before the song changed and that might not be what you want. Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I think your problem is the fact that you are using a modifyer key in a HotKeySet combination which is used to start sending text in some way. This results in the modifyer key being 'stuck' down if it has not been released befor ethe text is sent. The only way I can think of to stop this is to use the approach in a post I made here but this would mean that you would need to release the keys, including the Ctrl key, before the song changed and that might not be what you want.

Yeah, i have already made a script witch works like that.. that i have to release the Ctrl between each song ... cind of just that i wanted to get rid of...

And i woundered if there is any way to do it with some _ispressed functions?

Link to comment
Share on other sites

Hmm, did not get anything to work with the ALT-key :/

Any combination which uses a modifyer key is likely to have the same problem. You could use keys that are rarely used. For example Pause, ScrollLock, or some function key perhaps.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Ok, After givin up 7-8 times trying to make this work, i actualy think i have found a way..

i tried many ways using _ispressed functions a stuff like that.. but when giving up on that i went back to what i originaly tried...

And if i use the Windows-Button it worked :)

preaty simple actualy:

HotKeySet("#{RIGHT}","_right")



While 1
    Sleep(100)
WEnd



func _right()
    
    HotKeySet ("#{RIGHT}")
    ControlSend ("Musicprogramtitle","","","^{right}")
    HotKeySet("#{RIGHT}","_right")

EndFunc
Edited by Vegar
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...