Jump to content

Keyboard Shortcuts


117
 Share

Recommended Posts

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 :)

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

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

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