Jump to content
Sign in to follow this  
117

Keyboard Shortcuts

Recommended Posts

117

Hi there im completely new to programing and autoit i just would like some advice on how to creat a script that would assign keyboard short cuts so i can change next/previous songs in wmp11 eg <super> [ and <super> ] thanks a lot :)

Share this post


Link to post
Share on other sites
daniel02

HI,

I think you are looking for HotKeySet.

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d

;;;; Body of program would go here ;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

Share this post


Link to post
Share on other sites
117

Thanks that was usefull but how do i make it link with windows media palyer 11?

Share this post


Link to post
Share on other sites
Pandemic

Thanks that was usefull but how do i make it link with windows media palyer 11?

You'd probably want the ControlClick function, http://www.autoitscript.com/autoit3/docs/functions/ControlSend.htm.

Basically, this sends buttons to a window whether or not that window is active. It's pseudo-sending, if you will :).

HotKeySet("^!f", "nextSong");Ctrl + shift + f
HotKeySet("^!r", "previousSong");Ctrl + shift + r
HotKeySet("{ESC}", "quit")

;;; Main

ToolTip("Script active", 0, 0)
While 1
    sleep(200)
WEnd


;;; Functions

Func nextSong()
    ControlSend("Windows Media Player", "", "", "^f")
EndFunc

Func previousSong()
    ControlSend("Windows Media Player", "", "", "^b")
EndFunc

Func quit()
    Exit(1)
EndFunc

Find out what keyboard shortcuts WMP has built-in, then use AutoIT to make those shortcuts accessible, no matter the window that you have active :).

-Pandemic

Share this post


Link to post
Share on other sites
117

CTRL+F plays next track and

CTRL+B Plays previous

So would this work?

HotKeySet("^!f", "nextSong");Ctrl+ f

HotKeySet("^!r", "previousSong");Ctrl+ b

HotKeySet("{ESC}", "quit")

;;; Main

ToolTip("Script active", 0, 0)

While 1

sleep(200)

WEnd

;;; Functions

Func nextSong()

ControlSend("Windows Media Player", "", "", "^f")

EndFunc

Func previousSong()

ControlSend("Windows Media Player", "", "", "^b")

EndFunc

Func quit()

Exit(1)

EndFunc

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.