PotPlayer x64 Function Library

Post your working scripts, libraries and tools
x32
Posts: 85
Joined: 25 Nov 2016, 16:44

PotPlayer x64 Function Library

09 Mar 2018, 23:27

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:

Code: Select all

play:
PotPlayer_Play()
Return
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:

Code: Select all

playlist:
PotPlayer(10011) 
Return
Save script as PotPlayer.ahk and add to your function library folder.

Code: Select all

; PotPlayer Function Library by Specter333

; A complete list of functions can be found at the bottom of the page.
; Use Send functions to control PotPlayer with out it being active.


PotPlayer(msg) 
	{
	; For "msg" use a number from the list of commands at the bottom of the page.
	SendMessage,0x0111,msg,,,ahk_class PotPlayer64
	}
PotPlayer_Play()
	{
	SendMessage,0x0111,20001,,,ahk_class PotPlayer64
	}
PotPlayer_Pause()
	{
	SendMessage,0x0111,20000,,,ahk_class PotPlayer64
	}
PotPlayer_PlayPause()
	{
	SendMessage,0x0111,10014,,,ahk_class PotPlayer64
	}
PotPlayer_Stop()
	{
	SendMessage,0x0111,20002,,,ahk_class PotPlayer64
	}
PotPlayer_Previous()
	{
	SendMessage,0x0111,10123,,,ahk_class PotPlayer64
	}
PotPlayer_Next()
	{
	SendMessage,0x0111,10124,,,ahk_class PotPlayer64
	}
PotPlayer_VolumeUp()
	{
	SendMessage,0x0111,10035,,,ahk_class PotPlayer64
	}
PotPlayer_VolumeDown()
	{
	SendMessage,0x0111,10036,,,ahk_class PotPlayer64
	}
PotPlayer_Mute()
	{
	SendMessage,0x0111,10037,,,ahk_class PotPlayer64
	}
PotPlayer_Close()
	{
	WinClose, ahk_class PotPlayer64
	}
PotPlayer_Current()
	{
	SendMessage, 0x0400, 0x5004,,, ahk_class PotPlayer64
	PotPlayerConvert := PotPlayerConvertMillisecToTime(ErrorLevel)
	Return, %PotPlayerConvert%
	}
	
;;;;;;;;;;;;;   This function provided by Odlanir 	
PotPlayerConvertMillisecToTime(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)
	}
	
PotPlayer_GetVol()
		{
		SendMessage, 0x0400, 0x5000,,, ahk_class PotPlayer64
		Return, %ErrorLevel%
		}
PotPlayer_SetVol(newvol)
		{
		SendMessage, 0x0400, 0x5001,newvol,, ahk_class PotPlayer64
		}		
PotPlayer_GetTotalTime()
		{
		SendMessage, 0x0400, 0x5002,,, ahk_class PotPlayer64
		PotPlayerTotalTime := PotPlayerConvertMillisecToTime(ErrorLevel)
		Return, %PotPlayerTotalTime%
		}		
PotPlayer_SetTime(newtime) ; Value in milliseconds
		{
		SendMessage, 0x0400, 0x5005,newtime,, ahk_class PotPlayer64
		}

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%	
		}
PotPlayer_Status() 
		{
		SendMessage, 0x0400, 0x5006,,, ahk_class PotPlayer64
		Return, %ErrorLevel%
		}	

PotPlayer_AOT() 
		{
		WinSet, AlwaysOnTop, Toggle, ahk_class PotPlayer64
		}		
	
/*	
Use one of the numbers from the commands below with the PotPlayer(msg)
function to call commands not included in this library.  

Use only the number, example: the Open File function = PotPlayer(10158)

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
POT_GET_VOLUME   0x5000 // 0 ~ 100
POT_SET_VOLUME   0x5001 // 0 ~ 100
POT_GET_TOTAL_TIME  0x5002 // ms unit
POT_GET_PROGRESS_TIME 0x5003 // ms unit
POT_GET_CURRENT_TIME 0x5004 // ms unit
POT_SET_CURRENT_TIME 0x5005 // ms unit
POT_GET_PLAY_STATUS  0x5006 // -1:Stopped, 1:Paused, 2:Running
POT_SET_PLAY_STATUS  0x5007 // 0:Toggle, 1:Paused, 2:Running
POT_SET_PLAY_ORDER  0x5008 // 0:Prev, 1:Next
POT_SET_PLAY_CLOSE  0x5009
POT_SEND_VIRTUAL_KEY 0x5010 // Virtual Key(VK_UP, VK_DOWN....)
*/

Last edited by x32 on 12 Mar 2018, 13:03, edited 6 times in total.
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: PotPlayer x64 Function Library

10 Mar 2018, 14:44

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
Outsourcing Clicks & Presses Since 2004.
x32
Posts: 85
Joined: 25 Nov 2016, 16:44

Re: PotPlayer x64 Function Library

10 Mar 2018, 17:14

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

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.
vasili111
Posts: 747
Joined: 21 Jan 2014, 02:04
Location: Georgia

Re: PotPlayer x64 Function Library

12 Mar 2018, 00:40

Nice project! I love Potplayer :) Thank you :)
Is it possible to add a function that gets current time of played video?
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
Guest

Re: PotPlayer x64 Function Library

12 Mar 2018, 01:02

Code: Select all

SendMessage, 0x0400, 0x5004,,, ahk_class PotPlayer64
MsgBox %ErrorLevel%
x32
Posts: 85
Joined: 25 Nov 2016, 16:44

Re: PotPlayer x64 Function Library

12 Mar 2018, 07:00

Guest wrote:

Code: Select all

SendMessage, 0x0400, 0x5004,,, ahk_class PotPlayer64
MsgBox %ErrorLevel%
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

Re: PotPlayer x64 Function Library

12 Mar 2018, 07:34

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! :)
x32
Posts: 85
Joined: 25 Nov 2016, 16:44

Re: PotPlayer x64 Function Library

12 Mar 2018, 07:54

vasili111 wrote:Nice project! I love Potplayer :) Thank you :)
Is it possible to add a function that gets current time of played video?
Thanks. I just added the function provided by Guest and one to convert the milliseconds to h:m:s, provided by Odlanir, to the library in the original post. Now you can call the function PotPlayer_Current() and get the current position.
x32
Posts: 85
Joined: 25 Nov 2016, 16:44

Re: PotPlayer x64 Function Library

12 Mar 2018, 10:32

Guest wrote:Actually, searching for 0x5004 potplayer brings up the page I was talking about. Knock yourself out! :)
Yes, I found a page (in Japanese) with some more functions. I'm trying to add a few to the current library.

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%	
		}
Any ideas as to why?
wolf_II
Posts: 2225
Joined: 08 Feb 2015, 20:55

Re: PotPlayer x64 Function Library

12 Mar 2018, 13:05

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 ???
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: PotPlayer x64 Function Library

12 Mar 2018, 13:36

x32 wrote:
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)...\
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.

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.
x32
Posts: 85
Joined: 25 Nov 2016, 16:44

Re: PotPlayer x64 Function Library

12 Mar 2018, 14:51

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?
vasili111
Posts: 747
Joined: 21 Jan 2014, 02:04
Location: Georgia

Re: PotPlayer x64 Function Library

12 Mar 2018, 21:13

x32 and Guest

Thanks :thumbup:
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: PotPlayer x64 Function Library

16 Mar 2018, 23:15

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.
User avatar
jeeswg
Posts: 5406
Joined: 19 Dec 2016, 01:58
Location: UK

Re: PotPlayer x64 Function Library

17 Mar 2018, 05:23

- 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
x32
Posts: 85
Joined: 25 Nov 2016, 16:44

Re: PotPlayer x64 Function Library

17 Mar 2018, 08:11

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.
I do have MPC HC but still prefer VLC. I wrote a MPCHC library quite a while back and just reposted on these forums.
https://autohotkey.com/boards/viewtopic.php?f=6&t=45755

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Portwolf and 72 guests