Lee Mac Posted July 9, 2009 Posted July 9, 2009 grrrr... I don't find. (vlax-invoke mp 'close) don't work Annoying isn't it I tried this, but with no luck: (setq video "Une_video.avi") (setq mp (vlax-create-object "WMPlayer.OCX")) (vlax-invoke mp 'openPlayer (findfile video)) (while (progn (setq pl (vlax-get-property mp 'playstate)) (cond ((eq 3 pl) (vlax-invoke mp 'close)) (t t )))) (vlax-release-object mp) Quote
Lee Mac Posted July 9, 2009 Posted July 9, 2009 (defun kill(qui / item meth1 meth2 obj WMI) (setq WMI (vlax-create-object "WbemScripting.SWbemLocator") meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil) meth2 (vlax-invoke meth1 'ExecQuery "Select * from Win32_Process") ) (vlax-for item meth2 (and (setq obj (vlax-get item 'CommandLine)) (vl-string-search (strcase qui) (strcase obj)) (vlax-invoke item 'Terminate) ) ) (foreach item (list WMI meth1 meth2) (vlax-release-object item) ) ) (kill "wmplayer.exe") @+ Just out of interest, is this process "dangerous" Quote
Patrick_35 Posted July 9, 2009 Posted July 9, 2009 Yes, but you take a break before you kill the process For example (repeat 10000) Otherwise, in my archives, I found this, but I have not the time to present (setq video "Une_video.avi") (setq ie (vlax-create-object "InternetExplorer.Application")) (foreach item (list 'MenuBar 'Toolbar 'AddressBar 'StatusBar) (vlax-put ie item 0) ) (vlax-put ie 'Width 350) (vlax-put ie 'Height 278) (vlax-put ie 'Left 96) (vlax-put ie 'Top 150) (vlax-invoke ie 'Navigate "about:blank") (vlax-put ie 'Resizable -1) (setq doc (vlax-get ie 'Document)) (vlax-put doc 'Title (findfile video)) (foreach item '("<html>" "<head><title>Windows Media Player</title></head>" "<body>" "<OBJECT id=""VIDEO"" width=""320"" height=""240""" "position:absolute; left:0;top:0;""" "CLASSID=""CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6""" "type=""application/x-oleobject"">" "<PARAM NAME=""URL"" VALUE=""" & video & """>" "<PARAM NAME=""SendPlayStateChangeEvents""VALUE=""True"">" "<PARAM NAME=""AutoStart"" VALUE=""True"">" "<PARAM name=""uiMode"" value=""full"">" "<PARAM NAME=""showControls"" VALUE=""1"">" "<PARAM name=""PlayCount"" value=""1"">" "</OBJECT></body></html>") (vlax-invoke doc 'WriteLn item) ) (vlax-put ie 'visible -1) (vlax-release-object ie) @+ Quote
Lee Mac Posted July 9, 2009 Posted July 9, 2009 Nice Patrick, something similar here I think: http://www.autoitscript.com/forum/index.php?showtopic=88091 Quote
Patrick_35 Posted July 9, 2009 Posted July 9, 2009 Just out of interest, is this process "dangerous" Yes, but I have no choice to close mp ActiveX does not always respond to what we want to And normally, we master what we do @+ Quote
Patrick_35 Posted July 9, 2009 Posted July 9, 2009 Nice Patrick, something similar here I think: http://www.autoitscript.com/forum/index.php?showtopic=88091 Good link But, it's don't work with vlisp @+ Quote
Lee Mac Posted July 9, 2009 Posted July 9, 2009 Good link But, it's don't work with vlisp @+ Yeah, VL has its limitations. I just used that link to help with my code in post #21. By the way, what reference do you use for retrieving such information as this: (setq WMI (vlax-create-object "WbemScripting.SWbemLocator") meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil) meth2 (vlax-invoke meth1 'ExecQuery "Select * from Win32_Process") I use vlax-dump-object quite a lot, but it doesn't let you know what args you need to specify, just how many... How do you know to use: "WbemScripting.SWbemLocator"? Thanks, et merci beaucoup mon ami. Lee Quote
Small Fish Posted July 9, 2009 Author Posted July 9, 2009 hey thanks guys...awesome! - that solves some problems for me. Just one thing,- when I when I use the 'kill' function to close windows player I have a "delay" unfortunately it does not like it and I get a hour glass which means I have to ctrl+alt+del. Is there a different way to have a delay before the video finishes? (defun do_avi1 () (setq dcl_id3 (load_dialog "demo.DCL")) (if (not (new_dialog "view_avi" dcl_id3)) (exit)) (setq video "demo.avi") (setq mp (vlax-create-object "WMPlayer.OCX")) (vlax-invoke mp 'openPlayer (findfile video)) (vlax-dump-object mp T) ; to look full functions (vlax-release-object mp) (command "_.delay" 6000) (kill "wmplayer.exe") (start_dialog) (unload_dialog dcl_id3) );defun Quote
Patrick_35 Posted July 10, 2009 Posted July 10, 2009 Lee I found on website (sorry, in french) all that are necessary to use wmi. But I failed to translate into vlisp. It was on that I found TheSwamp For activex, I seek with Vlax-dump-object, but also with google (with createobject ...) ps: thank you for the french Small Fish Why the dialog box ? @+ Quote
Lee Mac Posted July 10, 2009 Posted July 10, 2009 Thanks for the link & info Patrick, much appreciated. Lee Quote
Small Fish Posted July 10, 2009 Author Posted July 10, 2009 Patrick_35Why the dialog box ? Because I have the video launching from my 'help' button. It works fine. I just have problems closing the video. Quote
Lee Mac Posted July 11, 2009 Posted July 11, 2009 If it comes to it, can't the user close the video? Quote
Small Fish Posted July 11, 2009 Author Posted July 11, 2009 yes they can. I guess that's what will have to happen. Quote
Patrick_35 Posted July 15, 2009 Posted July 15, 2009 Hi If I do that, it's work fine. (defun kill(qui / item meth1 meth2 obj WMI) (setq WMI (vlax-create-object "WbemScripting.SWbemLocator") meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil) meth2 (vlax-invoke meth1 'ExecQuery "Select * from Win32_Process") ) (vlax-for item meth2 (and (setq obj (vlax-get item 'CommandLine)) (vl-string-search (strcase qui) (strcase obj)) (vlax-invoke item 'Terminate) ) ) (foreach item (list WMI meth1 meth2) (vlax-release-object item) ) ) (defun do_avi (video / mp video) (if (setq video (findfile video)) (progn (setq mp (vlax-create-object "WMPlayer.OCX")) (vlax-invoke mp 'openPlayer video) (command "_.delay" 6000) (kill "wmplayer.exe") ) ) (princ) ) (do_avi "demo.avi") @+ Quote
Lee Mac Posted July 15, 2009 Posted July 15, 2009 Patrick, won't the delay be different for each video played? Quote
Patrick_35 Posted July 21, 2009 Posted July 21, 2009 Hi I think I found another solution (setq video (findfile "c:/test/volet.avi")) to read the avi file (setq wsh (vlax-create-object "WScript.Shell")) (setq mp (findfile "C:/test/MPlayerc.exe")) (setq run (vlax-invoke-method wsh 'exec (strcat mp " " video))) Close Mplayer (vlax-invoke run 'terminate) (vlax-release-object wsh) to find its time (setq sh (vlax-create-object "Shell.Application")) (setq dir (vlax-invoke sh 'Namespace (vl-filename-directory video))) (setq name (vlax-invoke bb 'parsename (strcat (vl-filename-base video) (vl-filename-extension video)))) (setq time (vlax-invoke-method name 'extendedproperty "duration")) (vlax-release-object sh) @+ Quote
Patrick_35 Posted July 21, 2009 Posted July 21, 2009 and I find this to run avi without WScript.Shell (vlax-invoke-method name 'invokeverbex "open") I search to close it @+ Quote
Lee Mac Posted July 21, 2009 Posted July 21, 2009 I see you use that method a lot now Patrick - is this something new you have learnt? I saw you use it over at theSwamp to open a Notepad file Lee Quote
Patrick_35 Posted July 22, 2009 Posted July 22, 2009 Yes Lee, I just discovered this method and it offers many possibilities. It is the search for the duration that brought me on shell.Application and can be opened with any application, I wanted to share it on theswamp. @+ Quote
Small Fish Posted July 22, 2009 Author Posted July 22, 2009 Patrick thanks - I tried your code out as shown below - it runs okay but wmplayer still does not close after finishing. Do I need to change something? thanks (defun c:playAvi (/ video wsh mp run sh dir name time) (setq video (findfile "c:/test/volet.avi")) ;;;to read the avi file (setq wsh (vlax-create-object "WScript.Shell")) (setq mp (findfile "C:/program files/windows media player/wmplayer.exe")) (setq run (vlax-invoke-method wsh 'exec (strcat mp " " video))) ;;;to find its time (setq sh (vlax-create-object "Shell.Application")) (setq dir (vlax-invoke sh 'Namespace (vl-filename-directory video))) (setq name (vlax-invoke bb 'parsename (strcat (vl-filename-base video) (vl-filename-extension video)))) (setq time (vlax-invoke-method name 'extendedproperty "duration")) (vlax-release-object sh) (command "_.delay" time) ;;;Close Mplayer (vlax-invoke run 'terminate) (vlax-release-object wsh) (princ) );defun Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.