Function library for the short list of available commands for the new(ish) PotPlayer media player. Updated with new functions 3/12/18.
https://potplayer.daum.net/
I prefer using SendMessage over Hotkeys because the player does not need to have focus or even be showing to receive the messages. This library is for the 64 bit version of the player. It can be modified for the 32 bit version by changing the AHK Class (ahk_class PotPlayer64) to however Window Spy detects it.
Basic messages are called with no other info needed.
Example:
Other functions and functions added in the future can be called by passing the correct value. A chart at the bottom of the library list the value for each known function.
Example:
Save script as PotPlayer.ahk and add to your function library folder.
PotPlayer x64 Function Library
PotPlayer x64 Function Library
Last edited by x32 on 06 Mar 2023, 17:57, edited 7 times in total.
-
- Posts: 175
- Joined: 24 Dec 2016, 13:16
- Location: Antarctica
Re: PotPlayer x64 Function Library
But i think every thing here can be sent by using media keys, if there was rewind,fast forward,etc... that would be useful but as it is i prefer to use mediakeys,they work with any media player(for the most part)...
https://www.autohotkey.com/docs/KeyList ... media_keys
https://www.autohotkey.com/docs/KeyList ... media_keys
Outsourcing Clicks & Presses Since 2004.
Re: PotPlayer x64 Function Library
The media keys won't work if the player doesn't have focus, which is why I prefer SendMessage. I have a hard time just sitting still and watching videos. I'm always working on something else on the other screen.brutus_skywalker wrote:But i think every thing here can be sent by using media keys, if there was rewind,fast forward,etc... that would be useful but as it is i prefer to use mediakeys,they work with any media player(for the most part)...\
I suspect other functions will be added as development improves. For now there are not enough for PotPlayer to be useful for me but I thought I'd post this in case someone finds it useful.
Re: PotPlayer x64 Function Library
Nice project! I love Potplayer Thank you
Is it possible to add a function that gets current time of played video?
Is it possible to add a function that gets current time of played video?
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
Re: PotPlayer x64 Function Library
Code: Select all
SendMessage, 0x0400, 0x5004,,, ahk_class PotPlayer64
MsgBox %ErrorLevel%
Re: PotPlayer x64 Function Library
Nice. If it's not too much trouble, would you mind educating me on how this works? 0x0400 is WM_USER, what does this actually do? And I can't find anything on 0x5004 what is it's function?Guest wrote:Code: Select all
SendMessage, 0x0400, 0x5004,,, ahk_class PotPlayer64 MsgBox %ErrorLevel%
Re: PotPlayer x64 Function Library
I'm sorry, I don't know, myself. I saw a list of messages like that for PotPlayer on a website some years back and kept that as a snippet as I thought I might need it one day.
Actually, searching for 0x5004 potplayer brings up the page I was talking about. Knock yourself out!
Actually, searching for 0x5004 potplayer brings up the page I was talking about. Knock yourself out!
Re: PotPlayer x64 Function Library
Thanks. I just added the function provided by Guest and one to convert the milliseconds to hs, provided by Odlanir, to the library in the original post. Now you can call the function PotPlayer_Current() and get the current position.vasili111 wrote:Nice project! I love Potplayer Thank you
Is it possible to add a function that gets current time of played video?
Re: PotPlayer x64 Function Library
Yes, I found a page (in Japanese) with some more functions. I'm trying to add a few to the current library.Guest wrote:Actually, searching for 0x5004 potplayer brings up the page I was talking about. Knock yourself out!
Trying to use the "get current position" and " set current position" functions to add "jump forward" and "jump backward" functions but I seem to get random results. i.e. if i add 10 seconds to the current time it seems to jump anywhere between 0 and 10 seconds.
Code: Select all
PotPlayer_JumpForward() ; Set for 5 seconds but seems to jump an arbitrary amount.
{
ppct := ppctm()
newtime := ppct+5000 ; Add 5 seconds to current time.
SendMessage, 0x0400, 0x5005,newtime,, ahk_class PotPlayer64
}
PotPlayer_JumpBackward() ; Set for -5 seconds but seems to jump an arbitrary amount.
{
ppct := ppctm()
newtime := ppct-5000 ; Subract 5 seconds from current time.
SendMessage, 0x0400, 0x5005,newtime,, ahk_class PotPlayer64
}
ppctm() ; Retrives the current possition in milliseconds
{
SendMessage, 0x0400, 0x5004,,, ahk_class PotPlayer64
Return, %ErrorLevel%
}
Re: PotPlayer x64 Function Library
I have no real knowledge, but I think:
Video formats can be a series of all pictures, or a series of key-frames followed by instructions of how to calculate the frames in between.
In the latter case I guess the player can only jump to key-frames ???
Video formats can be a series of all pictures, or a series of key-frames followed by instructions of how to calculate the frames in between.
In the latter case I guess the player can only jump to key-frames ???
-
- Posts: 175
- Joined: 24 Dec 2016, 13:16
- Location: Antarctica
Re: PotPlayer x64 Function Library
x32 wrote:The media keys won't work if the player doesn't have focus, which is why I prefer SendMessage. I have a hard time just sitting still and watching videos. I'm always working on something else on the other screen.brutus_skywalker wrote:But i think every thing here can be sent by using media keys, if there was rewind,fast forward,etc... that would be useful but as it is i prefer to use mediakeys,they work with any media player(for the most part)...\
I suspect other functions will be added as development improves. For now there are not enough for PotPlayer to be useful for me but I thought I'd post this in case someone finds it useful.
U sir have swayed me,useful indeed,my scripts for vlc use the 'http' interface, so that didn't occur to me,
Outsourcing Clicks & Presses Since 2004.
Re: PotPlayer x64 Function Library
Unfortunately VLC doesn't respond to SendMessage commands. I made a HTTP interface library for VLC a few years ago, as user Specter333, but I can't get it to work with the latest version. If yours is working can you post it?
Re: PotPlayer x64 Function Library
x32 and Guest
Thanks
Thanks
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
-
- Posts: 175
- Joined: 24 Dec 2016, 13:16
- Location: Antarctica
Re: PotPlayer x64 Function Library
x32 wrote:Unfortunately VLC doesn't respond to SendMessage commands. I made a HTTP interface library for VLC a few years ago, as user Specter333, but I can't get it to work with the latest version. If yours is working can you post it?
Mines' a tad obsolete as well,the old http interface was more or less plain http, but you can check out my other script https://autohotkey.com/boards/viewtopic ... dia+Remote which basically allows you to control for the MOST PART,(see features below), ALTHOUGH IT NEEDS VLC TO BE ACTIVE to control playback(only draw back), and has a premitive html ONLY interface for speed(and because i was too lazy to figure out how to modify AHKHTTP server to accept images).
Here's a list of features,note some might be missing, such as OSD for currently playing media,because it merely uses active window title and i thought it inadequate to include as a 'feature'
Features:
Previous,Pause/Play,Stop,Next
VLC/KMPlayer only Forward/Rewind with Multiplier in config.
VolumeUp/Down/MuteToggle AND 20/50/80/100% Presets //20-30-30-20 increments//|//VolumeUp/Down Dec/Increments by 5%//.
standby/hibernate with a timer,timer default is '0',timer can be inc/decreased by 30min inc/decrements or reset,if timer is reset any timer delayed standby/hibernate action will be reset.
Monitor_On/Off.
mrcexit hotstring to kill the server.
VLC Bring To Front/Turn off VLC/FullScreen Toggle.
VLC/KMPlayer/MPlayer Display NowPlaying File Notification on browserInterface.
VLC - Continue to resume playback. If it is enabled in vlc settings & the 'continue playback' floating panel is active,i.e If The 'Continue' Notification is visible.
Quick launch media folders,Each media folder is assigned a button on the browser interface. Media folders can be added using config section on browserInterface or manually in the iniFile. Quick Launch folders are run with an always-on-top,qt-minimal-view vlc instance.
Bi-directional AUTOSKIP, skips file automatically with respect to Next/Previous button press. Also actively checks if NowPlaying file is flagged for autoSkip,for when playback ends & next file comes up.
Search And Play Files/Paths button, to allow input of search string in browser UI,to only play files/paths that match search string.Preserves Search history for 20 of the last search strings. Up to three space delimited strings can be provided where each space is considered an 'AND' logical operator,if more than three spaces are in given search string,entire sequence will be considered a single search term.
Un/Bookmark now playing file, to play back only bookmarked files at a later time.
Config - section/button for easy addition of media folders,monitor switching buttons on/off,fwd/rwd multiplier settings,demo folders on/off,error message suppression on/off & quick access to config file/working dir.
OSD for on-screen notification.
Browser Interface NowPlaying notification, with context sensitive CurrentVolume notification only when volume is in/decreased.
Monitor Switching,buttons appear only when two monitors are detected,can be manually enabled from config,if display is not automatically detected.
VLC Error Message automatic suppression,can be disable or enabled in config. Includes suppression of 'Broken AVI Index files',tries to play the file with out building index.
Outsourcing Clicks & Presses Since 2004.
Re: PotPlayer x64 Function Library
- Media Player Classic is one of most powerful media players out there, and plays very nicely with AutoHotkey for automation, anybody who uses a media player or AutoHotkey should try it out.
jeeswg's Media Player Classic tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 74&t=41683
- Also, when automating media players, consider Acc. If AccViewer can retrieve info about the control/element, then you should be able to retrieve it via Acc. Also you can 'click' buttons by using Acc.ahk and accDoDefaultAction.
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201
jeeswg's Media Player Classic tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 74&t=41683
- Also, when automating media players, consider Acc. If AccViewer can retrieve info about the control/element, then you should be able to retrieve it via Acc. Also you can 'click' buttons by using Acc.ahk and accDoDefaultAction.
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: PotPlayer x64 Function Library
I do have MPC HC but still prefer VLC. I wrote a MPCHC library quite a while back and just reposted on these forums.jeeswg wrote:- Media Player Classic is one of most powerful media players out there, and plays very nicely with AutoHotkey for automation, anybody who uses a media player or AutoHotkey should try it out.
https://autohotkey.com/boards/viewtopic.php?f=6&t=45755
Re: PotPlayer x64 Function Library
Just a note: As of April 2020, the ahk_class name for PotPlayer is PotPlayer, not PotPlayer64. Your code, as posted, does not work, but works fine by simply changing all occurrences of PotPlayer64 to PotPlayer.x32 wrote: ↑09 Mar 2018, 23:27Function library for the short list of available commands for the new(ish) PotPlayer media player. Updated with new functions 3/12/18.
https://potplayer.daum.net/
I really think you should get some sort of medal for your script. Not having to give focus back to the PotPlayer to toggle playback is incredibly useful. I work on a Word document to transcribe video, and your script has made my life so much easier. Thank you.
Re: PotPlayer x64 Function Library
You are welcome, I'm glad it has been useful to someone. I use VLC most of the time and only occasionally PotPlayer, so I haven't updated the script since I wrote it. Maybe I should...
Re: PotPlayer x64 Function Library
I just now got around to downloading the latest version and checking this. I believe you must have the x32 version as the latest x64 version still requires "PotPlayer64", and is still seen by WindowSpy as "ahk_class PotPlayer64".
It is good to know that taking off the 64 is all that's required to make the library work in x32 Windows. Thanks
- Delta Pythagorean
- Posts: 628
- Joined: 13 Feb 2017, 13:44
- Location: Somewhere in the US
- Contact:
Re: PotPlayer x64 Function Library
I quickly made a class to handle the player pretty easily.
Just read the USAGE section and have your fun.
Keep in mind, I don't own a copy of PotPlayer, I just saw an opportunity to create a quick library.
Just read the USAGE section and have your fun.
Code: Select all
/*
; PotPlayer Function Library
; Original by Specter333
; Modified by Delta
; USAGE:
; Press play on the player and after 1 second get the current time.
Player := New PotPlayer()
Player.Message("PLAY")
Sleep, 1000
MsgBox, % Player.GetTime()
Return
; Set the volume to 10% and toggle play state on the player.
Player := New PotPlayer()
Player.SetVol(10)
Player.Message("PLAY_PAUSE")
Return
; Get the current state of the player.
Player := New PotPlayer()
MsgBox, % Player.Status()
Return
; NOTES:
; Use one of the numbers from the commands below with the Instance.Message(MSG)
; function to call commands not included in this library.
; Use only the number or a string after CMD.
; Example: the Open File function:
; Player.Message(10158) ; Open a file with the player.
; Player.Message("TOGGLE_OSD") ; Toggle the OSD of the player.
; These commands use 0x0111 as the Msg parameter.
Local CMD_PLAY := 20001
Local CMD_PAUSE := 20000
Local CMD_STOP := 20002
Local CMD_PREVIOUS := 10123
Local CMD_NEXT := 10124
Local CMD_PLAY_PAUSE := 10014
Local CMD_VOLUME_UP := 10035
Local CMD_VOLUME_DOWN := 10036
Local CMD_TOGGLE_MUTE := 10037
Local CMD_TOGGLE_PLAYLIST := 10011
Local CMD_TOGGLE_CONTROL := 10383
Local CMD_OPEN_FILE := 10158
Local CMD_TOGGLE_SUBS := 10126
Local CMD_TOGGLE_OSD := 10351
Local CMD_CAPTURE := 10224
; These commands use 0x0400 as the Msg parameter
Local POT_GET_VOLUME := 0x5000 ; 0 ~ 100
Local POT_SET_VOLUME := 0x5001 ; 0 ~ 100
Local POT_GET_TOTAL_TIME := 0x5002 ; ms unit
Local POT_GET_PROGRESS_TIME := 0x5003 ; ms unit
Local POT_GET_CURRENT_TIME := 0x5004 ; ms unit
Local POT_SET_CURRENT_TIME := 0x5005 ; ms unit
Local POT_GET_PLAY_STATUS := 0x5006 ; -1:Stopped, 1:Paused, 2:Running
Local POT_SET_PLAY_STATUS := 0x5007 ; 0:Toggle, 1:Paused, 2:Running
Local POT_SET_PLAY_ORDER := 0x5008 ; 0:Prev, 1:Next
Local POT_SET_PLAY_CLOSE := 0x5009
Local POT_SEND_VIRTUAL_KEY := 0x5010 ; Virtual Key(VK_UP, VK_DOWN....)
*/
/*
[CLASS] PotPlayer {
[INSTANCE || FALSE] __New {
[STR || HWND] Handle [ahk_class PotPlayer]
// Handle == The handle of the window to control. Default is "ahk_class PotPlayer".
}
[INT || STR] Send {
[STR || HEX] MsgValOrName
// MsgValOrName == The message to send to the player. Can be a string or integer/hex value.
}
[INT || STR] GetVol
[NULL] SetVol {
[INT] NewVol
// NewVol == The new volume to set the player to.
}
[STR] GetTotalTime
[NULL] GetTime {
[BOOL] Convert [False]
// Conver == Say whether to convert the time into a user-readable time or to milliseconds. Default is False.
}
[NULL] SetTime {
[INT] NewTime
// NewTime == The new time to set the player to in Milliseconds.
}
[NULL] JumpForward {
[INT] Time [5000]
// Time == The new time to jump the player forward to in Milliseconds. Default is 5000 milliseconds.
}
[NULL] JumpBackward {
[INT] Time [5000]
// Time == The new time to set the player backward to in Milliseconds. Default is 5000 milliseconds.
}
[INT || STR] Status
}
*/
Class PotPlayer {
__New(Handle := "ahk_class PotPlayer") {
If (DllCall("IsWindow", "Ptr", Handle)) { ; Check to see if the passed parameter is a handle or not.
This.WindowHandle := "ahk_id " . Handle
} Else {
This.WindowHandle := WinExist(Handle)
}
If (This.WindowHandle == Null) { ; If This.WindowHandle is blank (somehow).
Return, (False)
}
Return, (This)
}
Send(MsgValOrName) {
Static Names := {
(LTrim Join
"PLAY": 20001,
"PAUSE": 20000,
"STOP": 20002,
"PREVIOUS": 10123,
"NEXT": 10124,
"PLAY_PAUSE": 10014,
"VOLUME_UP": 10035,
"VOLUME_DOWN": 10036,
"TOGGLE_MUTE": 10037,
"TOGGLE_PLAYLIST": 10011,
"TOGGLE_CONTROL": 10383,
"OPEN_FILE": 10158,
"TOGGLE_SUBS": 10126,
"TOGGLE_OSD": 10351,
"CAPTURE": 10224
)}
Msg := ((Names.HasKey(MsgValOrName)) ? (Names[MsgValOrName]) : (MsgValOrName))
SendMessage, 0x0111, Msg,,, % This.WindowHandle
Return, (ErrorLevel)
}
GetVol() {
SendMessage, 0x0400, 0x5000,,, % This.WindowHandle
Return, (ErrorLevel)
}
SetVol(NewVol) {
SendMessage, 0x0400, 0x5001, NewVol,, % This.WindowHandle
}
GetTotalTime() {
SendMessage, 0x0400, 0x5002,,, % This.WindowHandle
PotPlayerTotalTime := ConvertMillisecToTime(ErrorLevel)
Return, (PotPlayerTotalTime)
}
GetTime(Convert := True) {
SendMessage, 0x0400, 0x5004,,, % This.WindowHandle
PotPlayerConvert := ConvertMillisecToTime(ErrorLevel)
Return, ((Convert == True) ? (PotPlayerConvert) : (ErrorLevel))
}
SetTime(NewTime) { ; Value in milliseconds.
SendMessage, 0x0400, 0x5005, NewTime,, % This.WindowHandle
}
JumpForward(Time := 5000) { ; Set for 5 seconds but seems to jump an arbitrary amount.
PPCT := This.GetTime(False)
NewTime := PPCT + Time ; Add 5 seconds to current time.
SendMessage, 0x0400, 0x5005, NewTime,, % This.WindowHandle
}
JumpBackward(Time := 5000) { ; Set for -5 seconds but seems to jump an arbitrary amount.
PPCT := This.GetTime(False)
NEWTIME := PPCT - Time ; Subract 5 seconds from current time.
SendMessage, 0x0400, 0x5005, NEWTIME,, % This.WindowHandle
}
Status() {
SendMessage, 0x0400, 0x5006,,, % This.WindowHandle
Return, (ErrorLevel)
}
}
; External functions, used by PotPlayer class but can be replaced.
; This function provided by Odlanir.
ConvertMillisecToTime(MSec) {
Secs := Floor(Mod((MSec / 1000), 60))
Mins := Floor(Mod((MSec / (1000 * 60)), 60))
Hour := Floor(Mod((MSec / (1000 * 60 * 60)), 24))
Return, (Format("{:02}:{:02}:{:02}", Hour, Mins, Secs))
}
[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 110 guests