Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 28th December 2012, 18:08   #1  |  Link
WarpEnterprises
C64
 
WarpEnterprises's Avatar
 
Join Date: Apr 2002
Location: Austria
Posts: 830
Get the calling program of an avisynth script

Hi!
Is it possible to get the name of the program which called the
current script?

My sample usage would be:
virtualdub calls script -> don't use e.g. deshaker filter
else -> use deshaker

Of course, any hint how to achieve the same is welcome, too!
WarpEnterprises is offline   Reply With Quote
Old 28th December 2012, 20:04   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
This gets a number of hits in google:- "get parent process name"
you'de need a plugin of course.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 28th December 2012, 20:26   #3  |  Link
WarpEnterprises
C64
 
WarpEnterprises's Avatar
 
Join Date: Apr 2002
Location: Austria
Posts: 830
OK - I forget to add "with already existing tools"
WarpEnterprises is offline   Reply With Quote
Old 29th December 2012, 13:05   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by WarpEnterprises View Post
OK - I forget to add "with already existing tools"
Not already existing, but having a go at your requirement.
So far, got a plug that outputs list of current processes, names,
PID, parent PID (to Debugview).

Found that what you want is actually the name of the current
process rather than parent (did not know if Avisynth dll had it's own process ID or not, I am not a Win programmer).

I'll have it return a string (process name) if successful and maybe an int or bool to flag failure.

When it's done, (not too long I hope) perhaps you would be good enough to give a report on how it fares and on what system.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 29th December 2012 at 19:35.
StainlessS is offline   Reply With Quote
Old 29th December 2012, 14:20   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Last bit was easier than anticipated, here it is:
http://www.mediafire.com/?3ri1n01hh3wacmy
Code:
GetProcessName(bool "Parent"=false,bool "Debug"=false)

Args:-

Parent, if false gives name of current process (eg mplayer2.exe or VirtualDubMod.exe).
 	if true gives name of parent to current process (eg Explorer.exe or AVSEdit.exe).

Debug, if true outputs stuff to DebugView (need debugview, see google)



Returns:-

Type int 

-1 = Cant create  process snapshot. (CreateToolhelp32Snapshot)

-2 = Cant walk Process List. (Process32First)

-3 = Cant find my own PID in process list (???).

-4 = Cant find Parent PID in process list (No longer executing).

Type String = ExeName as shown in Taskmanager.


Test Script GetProcessName.avs

# -----------------------
  Me = GetProcessName(parent=false,debug=true)

  RT_Debug("MY NAME IS ",String(Me))

  Mum= GetProcessName(parent=true ,debug=true)

  RT_Debug("MUMS NAME IS ",String(Mum))

  return colorbars()	# Avoid ThrowError
# -----------------------


Gives this output in DebugView

00000004	1.88071465	[3364] GetProcessName: ExeFile    = VirtualDubMod.exe	
00000005	1.88075864	[3364] GetProcessName: ProcessID  = 0x00000D24	
00000006	1.88080537	[3364] GetProcessName: Threads    = 3	
00000007	1.88085139	[3364] GetProcessName: ParentProc = 0x00000140	

00000008	1.88463914	[3364] RT_Debug: MY NAME IS VirtualDubMod.exe	

00000009	1.88716698	[3364] GetProcessName: ExeFile    = VirtualDubMod.exe	
00000010	1.88721681	[3364] GetProcessName: ProcessID  = 0x00000D24	
00000011	1.88726258	[3364] GetProcessName: Threads    = 3	
00000012	1.88730943	[3364] GetProcessName: ParentProc = 0x00000140	
00000013	1.88757229	[3364] GetProcessName: ExeFile    = explorer.exe	
00000014	1.88761711	[3364] GetProcessName: ProcessID  = 0x00000140	
00000015	1.88766301	[3364] GetProcessName: Threads    = 13	
00000016	1.88770759	[3364] GetProcessName: ParentProc = 0x000007DC	

00000017	1.88853240	[3364] RT_Debug: MUMS NAME IS explorer.exe
EDITED

Tested only on XP32 (XP and above, NOT W2K)

If a Win progger could check out the source for obvious errors, that would be nice. Thank you.

EDIT: Tested on XP32, Vista32, W7-32 & also works on W2K
EDIT: Detects AVSPmod fine.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 30th December 2012 at 05:35.
StainlessS is offline   Reply With Quote
Old 29th December 2012, 14:46   #6  |  Link
jmartinr
Registered User
 
jmartinr's Avatar
 
Join Date: Dec 2007
Location: Enschede, NL
Posts: 301
See here: http://forum.doom9.org/showthread.ph...97#post1260197

And download the plugin here: http://www.roelofs-coaching.nl/blobs...rogramName.zip
__________________
Roelofs Coaching

Last edited by jmartinr; 20th December 2015 at 23:51. Reason: update download link
jmartinr is offline   Reply With Quote
Old 29th December 2012, 16:40   #7  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Post #5 updated with two new args Parent and Debug. (will also be adding to RT_Stats).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 29th December 2012 at 17:07.
StainlessS is offline   Reply With Quote
Old 29th December 2012, 19:34   #8  |  Link
WarpEnterprises
C64
 
WarpEnterprises's Avatar
 
Join Date: Apr 2002
Location: Austria
Posts: 830
@StainlessS: thanks very much - tested on XP and W2K, works as expected!
WarpEnterprises is offline   Reply With Quote
Old 29th December 2012, 19:44   #9  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Verify, W2K work OK ? (not supposed to).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 29th December 2012, 22:06   #10  |  Link
WarpEnterprises
C64
 
WarpEnterprises's Avatar
 
Join Date: Apr 2002
Location: Austria
Posts: 830
Well, at least it did not crash and returned the correct task name (loaded from vdub).
Which function did you suspect to be incompatible?
WarpEnterprises is offline   Reply With Quote
Old 30th December 2012, 04:42   #11  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
GetCurrentProcessId : Minimum supported client Windows XP [desktop apps only]
http://msdn.microsoft.com/en-gb/libr...=vs.85%29.aspx

CreateToolhelp32Snapshot : Minimum supported client Windows XP [desktop apps only]
http://msdn.microsoft.com/en-gb/libr...=vs.85%29.aspx

Process32First : Minimum supported client Windows XP [desktop apps only]
http://msdn.microsoft.com/en-gb/libr...=vs.85%29.aspx

Process32Next : Minimum supported client Windows XP [desktop apps only]
http://msdn.microsoft.com/en-gb/libr...=vs.85%29.aspx

Might be a case of "We no longer support W2K, and so now neither do you !"

Thanks for the verification.

EDIT: Tested on XP32, Vista32, W7-32 & also works on W2K
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 30th December 2012 at 05:30.
StainlessS is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:17.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.