As requested here is the HTTP function library for MPC-HC a very nice media player that can be downloaded from Source Forge. Media Player Classic Home Cinema
I like using these functions because unlike hotkeys the player can be controlled when it is not the active window. The library is only a small sample of the commands available but any command can be easily added.
Updated 12/17/11
Thanks to XX0, I've now created a "Send" library for MPC. The Send command responds faster and requires no setup in Media Player Classic.
In addition to the basic commands I've add a function to use any of the 138 command numbers as a parameter.
The HTTP library now uses the host computer's IP and port as a parameter making it usable for controlling MPC over a network.
A demo script has been added to a later post. Media Player Classic Functions Libraries Demo Script
The Send library:
No setup is required in MPC.
MediaPlayerClassicHC.ahk
; Media Player Classic Home Cinema Function Library by Specter333 ; http://www.autohotkey.com/forum/viewtopic.php?p=490310#490310 ; A complete list of functions can be found at the bottom of the page. ; Use Send functions to control Media Player Classic Home Cinema ; with out it being active. ; Home page, http://mpc-hc.sourceforge.net/ ; If being used on a local machine this function responds faster than MPCHTTP MediaPlayerClassicHC(msg) { ; For "msg" use a number from the list of commands at the bottom of the page. SendMessage,0x0111,msg,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_Play() { SendMessage,0x0111,887,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_Pause() { SendMessage,0x0111,888,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_PlayPause() { SendMessage,0x0111,889,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_Stop() { SendMessage,0x0111,890,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_FullScreen() { SendMessage,0x0111,830,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_JumpForward() { SendMessage,0x0111,902,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_JumpBackward() { SendMessage,0x0111,901,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_PlayFaster() { SendMessage,0x0111,895,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_PlaySlower() { SendMessage,0x0111,894,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_PlayNormal() { SendMessage,0x0111,896,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_VolumeUp() { SendMessage,0x0111,907,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_VolumeDown() { SendMessage,0x0111,908,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_Mute() { SendMessage,0x0111,909,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_RootMenu() { SendMessage,0x0111,923,,,ahk_class MediaPlayerClassicW } MediaPlayerClassicHC_Exit() { SendMessage,0x0111,816,,,ahk_class MediaPlayerClassicW } /* Use one of the numbers from the commands below with the MediaPlayerClassicHC(msg) function to call commands not included in this library. Use only the number, example the Open File function = MediaPlayerClassicHC(800) 800 Open File 801 Open DVD 802 Open Device 805 Save As 806 Save Image 807 Save Image (auto) 809 Load Subtitle 810 Save Subtitle 804 Close 814 Properties 816 Exit 889 Play/Pause 887 Play 888 Pause 890 Stop 891 Framestep 892 Framestep back 893 Go To 895 Increase Rate 894 Decrease Rate 896 Reset Rate 905 Audio Delay +10ms 906 Audio Delay -10ms 900 Jump Forward (small) 899 Jump Backward (small) 902 Jump Forward (medium) 901 Jump Backward (medium) 904 Jump Forward (large) 903 Jump Backward (large) 898 Jump Forward (keyframe) 897 Jump Backward (keyframe) 921 Next 920 Previous 919 Next Playlist Item 918 Previous Playlist Item 817 Toggle Caption&Menu 818 Toggle Seeker 819 Toggle Controls 820 Toggle Information 821 Toggle Statistics 822 Toggle Status 823 Toggle Subresync Bar 824 Toggle Playlist Bar 825 Toggle Capture Bar 826 Toggle Shader Editor Bar 827 View Minimal 828 View Compact 829 View Normal 830 Fullscreen 831 Fullscreen (w/o res.change) 832 Zoom 50`% 833 Zoom 100`% 834 Zoom 200`% 967 Zoom Auto Fit 860 Next AR Preset 835 VidFrm Half 836 VidFrm Normal 837 VidFrm Double 838 VidFrm Stretch 839 VidFrm Inside 840 VidFrm Outside 884 Always On Top 861 PnS Reset 862 PnS Inc Size 864 PnS Inc Width 866 PnS Inc Height 863 PnS Dec Size 865 PnS Dec Width 867 PnS Dec Height 876 PnS Center 868 PnS Left 869 PnS Right 870 PnS Up 871 PnS Down 872 PnS Up/Left 873 PnS Up/Right 874 PnS Down/Left 875 PnS Down/Right 877 PnS Rotate X+ 878 PnS Rotate X- 879 PnS Rotate Y+ 880 PnS Rotate Y- 881 PnS Rotate Z+ 882 PnS Rotate Z- 907 Volume Up 908 Volume Down 909 Volume Mute 969 Volume boost increase 970 Volume boost decrease 971 Volume boost Min 972 Volume boost Max 922 DVD Title Menu 923 DVD Root Menu 924 DVD Subtitle Menu 925 DVD Audio Menu 926 DVD Angle Menu 927 DVD Chapter Menu 928 DVD Menu Left 929 DVD Menu Right 930 DVD Menu Up 931 DVD Menu Down 932 DVD Menu Activate 933 DVD Menu Back 934 DVD Menu Leave 943 Boss key 948 Player Menu (short) 949 Player Menu (long) 950 Filters Menu 886 Options 951 Next Audio 952 Prev Audio 953 Next Subtitle 954 Prev Subtitle 955 On/Off Subtitle 2302 Reload Subtitles 956 Next Audio (OGM) 957 Prev Audio (OGM) 958 Next Subtitle (OGM) 959 Prev Subtitle (OGM) 960 Next Angle (DVD) 961 Prev Angle (DVD) 962 Next Audio (DVD) 963 Prev Audio (DVD) 964 Next Subtitle (DVD) 965 Prev Subtitle (DVD) 966 On/Off Subtitle (DVD) 32769 Tearing Test 32778 Remaining Time 32770 Toggle Pixel Shader 32779 Toggle Direct3D fullscreen 32780 Goto Prev Subtitle 32781 Goto Next Subtitle 32782 Shift Subtitle Left 32783 Shift Subtitle Right 32784 Display Stats 24000 Subtitle Delay - 24001 Subtitle Delay + 808 Save thumbnails */
The HTTP library:
To enable the HTTP interface, click "View/Options", then in the "Player" menu chose "Web Interface".
Check "Listen on port:", port number is 13579. The latest version includes UrlDownloadToVar by olfen
MPCHTTP.ahk
; Media Player Classic Home Cinema Function Library by Specter333 ; A complete list of HTTP functins can be found at ; http://www.autohotkey.com/forum/viewtopic.php?p=490310#490310 ; Use HTTP functions to control Media Player Classic Home Cinema with out it being active. ; Home page, http://mpc-hc.sourceforge.net/ ; To enable the HTTP interface, click View/Options, then in the Player menu chose Web Interface. ; Check "Listen on port:", port number is 13579. MPCHTTP_Play(ip,port) ; localhost:13579 { url = http://%ip%:%port%/command.html?wm_command=887 MPCUrlDownloadToVar(url) } MPCHTTP_Pause(ip,port) { url = http://%ip%:%port%/command.html?wm_command=888 MPCUrlDownloadToVar(url) } MPCHTTP_PlayPause(ip,port) { url = http://%ip%:%port%/command.html?wm_command=889 MPCUrlDownloadToVar(url) } MPCHTTP_Stop(ip,port) { url = http://%ip%:%port%/command.html?wm_command=890 MPCUrlDownloadToVar(url) } MPCHTTP_FullScreen(ip,port) { url = http://%ip%:%port%/command.html?wm_command=830 MPCUrlDownloadToVar(url) } MPCHTTP_JumpForward(ip,port) { url = http://%ip%:%port%/command.html?wm_command=902 MPCUrlDownloadToVar(url) } MPCHTTP_JumpBackward(ip,port) { url = http://%ip%:%port%/command.html?wm_command=901 MPCUrlDownloadToVar(url) } MPCHTTP_PlayFaster(ip,port) { url = http://%ip%:%port%/command.html?wm_command=895 MPCUrlDownloadToVar(url) } MPCHTTP_PlaySlower(ip,port) { url = http://%ip%:%port%/command.html?wm_command=894 MPCUrlDownloadToVar(url) } MPCHTTP_VolumeUp(ip,port) { url = http://%ip%:%port%/command.html?wm_command=907 MPCUrlDownloadToVar(url) } MPCHTTP_VolumeDown(ip,port) { url = http://%ip%:%port%/command.html?wm_command=908 MPCUrlDownloadToVar(url) } MPCHTTP_Mute(ip,port) { url = http://%ip%:%port%/command.html?wm_command=909 MPCUrlDownloadToVar(url) } MPCHTTP_RootMenu(ip,port) { url = http://%ip%:%port%/command.html?wm_command=923 MPCUrlDownloadToVar(url) } MPCHTTP_Exit(ip,port) { url = http://%ip%:%port%/command.html?wm_command=816 MPCUrlDownloadToVar(url) } MPCHTTP(ip,port,msg) { url = http://%ip%:%port%/command.html?wm_command=%msg% MPCUrlDownloadToVar(url) } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; UrlDownloadToVar by olfen ; http://www.autohotkey.com/forum/viewtopic.php?p=64230#64230 MPCUrlDownloadToVar(URL, Proxy="", ProxyBypass="") { AutoTrim, Off hModule := DllCall("LoadLibrary", "str", "wininet.dll") If (Proxy != "") AccessType=3 Else AccessType=1 ;INTERNET_OPEN_TYPE_PRECONFIG 0 // use registry configuration ;INTERNET_OPEN_TYPE_DIRECT 1 // direct to net ;INTERNET_OPEN_TYPE_PROXY 3 // via named proxy ;INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4 // prevent using java/script/INS io_hInternet := DllCall("wininet\InternetOpenA" , "str", "" ;lpszAgent , "uint", AccessType , "str", Proxy , "str", ProxyBypass , "uint", 0) ;dwFlags iou := DllCall("wininet\InternetOpenUrlA" , "uint", io_hInternet , "str", url , "str", "" ;lpszHeaders , "uint", 0 ;dwHeadersLength , "uint", 0x80000000 ;dwFlags: INTERNET_FLAG_RELOAD = 0x80000000 // retrieve the original item , "uint", 0) ;dwContext If (ErrorLevel != 0 or iou = 0) { DllCall("FreeLibrary", "uint", hModule) return 0 } VarSetCapacity(buffer, 512, 0) VarSetCapacity(NumberOfBytesRead, 4, 0) Loop { irf := DllCall("wininet\InternetReadFile", "uint", iou, "uint", &buffer, "uint", 512, "uint", &NumberOfBytesRead) NOBR = 0 Loop 4 ; Build the integer by adding up its bytes. - ExtractInteger NOBR += *(&NumberOfBytesRead + A_Index-1) << 8*(A_Index-1) IfEqual, NOBR, 0, break ;BytesReadTotal += NOBR DllCall("lstrcpy", "str", buffer, "uint", &buffer) res = %res%%buffer% } StringTrimRight, res, res, 2 DllCall("wininet\InternetCloseHandle", "uint", iou) DllCall("wininet\InternetCloseHandle", "uint", io_hInternet) DllCall("FreeLibrary", "uint", hModule) AutoTrim, on return, res }
Here is the complete list of commands, MPC-HTTP Commands
<option value="800">Open File <option value="801">Open DVD <option value="802">Open Device <option value="805">Save As <option value="806">Save Image <option value="807">Save Image (auto) <option value="809">Load Subtitle <option value="810">Save Subtitle <option value="804">Close <option value="814">Properties <option value="816">Exit <option value="889">Play/Pause <option value="887">Play <option value="888">Pause <option value="890">Stop <option value="891">Framestep <option value="892">Framestep back <option value="893">Go To <option value="895">Increase Rate <option value="894">Decrease Rate <option value="896">Reset Rate <option value="905">Audio Delay +10ms <option value="906">Audio Delay -10ms <option value="900">Jump Forward (small) <option value="899">Jump Backward (small) <option value="902">Jump Forward (medium) <option value="901">Jump Backward (medium) <option value="904">Jump Forward (large) <option value="903">Jump Backward (large) <option value="898">Jump Forward (keyframe) <option value="897">Jump Backward (keyframe) <option value="921">Next <option value="920">Previous <option value="919">Next Playlist Item <option value="918">Previous Playlist Item <option value="817">Toggle Caption&Menu <option value="818">Toggle Seeker <option value="819">Toggle Controls <option value="820">Toggle Information <option value="821">Toggle Statistics <option value="822">Toggle Status <option value="823">Toggle Subresync Bar <option value="824">Toggle Playlist Bar <option value="825">Toggle Capture Bar <option value="826">Toggle Shader Editor Bar <option value="827">View Minimal <option value="828">View Compact <option value="829">View Normal <option value="830">Fullscreen <option value="831">Fullscreen (w/o res.change) <option value="832">Zoom 50% <option value="833">Zoom 100% <option value="834">Zoom 200% <option value="967">Zoom Auto Fit <option value="860">Next AR Preset <option value="835">VidFrm Half <option value="836">VidFrm Normal <option value="837">VidFrm Double <option value="838">VidFrm Stretch <option value="839">VidFrm Inside <option value="840">VidFrm Outside <option value="884">Always On Top <option value="861">PnS Reset <option value="862">PnS Inc Size <option value="864">PnS Inc Width <option value="866">PnS Inc Height <option value="863">PnS Dec Size <option value="865">PnS Dec Width <option value="867">PnS Dec Height <option value="876">PnS Center <option value="868">PnS Left <option value="869">PnS Right <option value="870">PnS Up <option value="871">PnS Down <option value="872">PnS Up/Left <option value="873">PnS Up/Right <option value="874">PnS Down/Left <option value="875">PnS Down/Right <option value="877">PnS Rotate X+ <option value="878">PnS Rotate X- <option value="879">PnS Rotate Y+ <option value="880">PnS Rotate Y- <option value="881">PnS Rotate Z+ <option value="882">PnS Rotate Z- <option value="907">Volume Up <option value="908">Volume Down <option value="909">Volume Mute <option value="969">Volume boost increase <option value="970">Volume boost decrease <option value="971">Volume boost Min <option value="972">Volume boost Max <option value="922">DVD Title Menu <option value="923">DVD Root Menu <option value="924">DVD Subtitle Menu <option value="925">DVD Audio Menu <option value="926">DVD Angle Menu <option value="927">DVD Chapter Menu <option value="928">DVD Menu Left <option value="929">DVD Menu Right <option value="930">DVD Menu Up <option value="931">DVD Menu Down <option value="932">DVD Menu Activate <option value="933">DVD Menu Back <option value="934">DVD Menu Leave <option value="943">Boss key <option value="948">Player Menu (short) <option value="949">Player Menu (long) <option value="950">Filters Menu <option value="886">Options <option value="951">Next Audio <option value="952">Prev Audio <option value="953">Next Subtitle <option value="954">Prev Subtitle <option value="955">On/Off Subtitle <option value="2302">Reload Subtitles <option value="956">Next Audio (OGM) <option value="957">Prev Audio (OGM) <option value="958">Next Subtitle (OGM) <option value="959">Prev Subtitle (OGM) <option value="960">Next Angle (DVD) <option value="961">Prev Angle (DVD) <option value="962">Next Audio (DVD) <option value="963">Prev Audio (DVD) <option value="964">Next Subtitle (DVD) <option value="965">Prev Subtitle (DVD) <option value="966">On/Off Subtitle (DVD) <option value="32769">Tearing Test <option value="32778">Remaining Time <option value="32770">Toggle Pixel Shader <option value="32779">Toggle Direct3D fullscreen <option value="32780">Goto Prev Subtitle <option value="32781">Goto Next Subtitle <option value="32782">Shift Subtitle Left <option value="32783">Shift Subtitle Right <option value="32784">Display Stats <option value="24000">Subtitle Delay - <option value="24001">Subtitle Delay + <option value="808">Save thumbnails
Also check out my VLC Media Player HTTP Function Library,
jballi's Winamp functions,
And to control your media players with a IR remote just like a DVD or Blu Ray player see the USB-UIRT Function Library.