Log in

View Full Version : Start/Stop Virtualdub by LPT or file.Please help !


lovak1
29th April 2002, 10:42
I am capturing from a sat receiver which can start/stop according to the built in planner. It can start/stop a VCR as well, if connected via a SCART cable. It is 10.5V on pin 8 and 14, which controls the operation. I made a Scart-lpt cable resulting 0 or 1 on pin 13 of the LPT port and found an LPT object to Visual Basic ( I use the one built into Excel ) I was able to start capturing in Vdub when the LPT pin change to 1 from 0 by sending an F6 key but sending the stop key does not work !!! Just if you really press ESC or SPACE.

If anyone could please help me modify Vdub by a new stop condition. LPT pin change or for example check if a certain file exists or the file length >0. I can write into a file by VB.

Darksoul71
1st May 2002, 10:36
Hi lovak !

An interessting idea !
I made a Scart-lpt cable resulting 0 or 1 on pin 13 of the LPT port
Fine, but keep in mind that LPT uses TTL levels only (5V+/0V). Have you use a Zener diode to lower the voltage from your sat receiver ?

But back to topic:
Iīve programmed a VCR frontend for VDub a long time ago in Delphi and I used the Windows Scripting Host for sending keystrokes. As WSH uses VB Script I can tell you definitely that {ESC} works fine for stopping capturing :)

Have you tried sending a stop key (ESC AFAIK) to VDub independently from your LPT pin ?

I really canīt see a problem here. I suspect that your LPT checking routine might be a problem here. BTW: Not to offend you but VB is really no hardware near language. Try VC or Delphi instead.

c u,
D$

Dark-Cracker
1st May 2002, 13:27
in VB have u use the fonction SENDKEY ? perhaps it's will work.

cow
2nd May 2002, 01:59
A little more complicated, but you can also send a WM_CAP_STOP message to the capture window (not the main VirtualDub window). VD doesn't even have to be in focus this way... Or maybe you can find a stop capture WM_COMMAND ID in VD's sources and you can send that to the main window.

Darksoul71
2nd May 2002, 09:57
@cow:
Windows message handling can be pretty much a pain in the a..
I think if lovak1 is used to VB this WM_ message stuff is pretty hard to him.

@lovak1:
BTW: I donīt understand one thing:
Why do you need to launch VDub controlled by your sat receiver ????

Beside that this is a cool "homemade" project, I guess that your receiver is started by a timer, right ?
So why donīt you just use the modified version of Virtual Dub with timer (www.virtualdub.net) and launch VDub a little bit earlier than your receiver starts ?

This saves you from all your problems.

And you should really care about LPT port specs refering to your input voltage because a too high voltage can easily blow up your LPT port or (even worse) mess up your chipset.

-D$

lovak1
2nd May 2002, 11:08
Hi,

Thanks for all your reply.
First the technical side, yes it is a Zener diode which lowers the voltage and I had to put in a 600 ohm resistor as follows
Scart pin 8 -> Z. diode -> lpt pin 13. The z.d. goes also to the resistor -> Scart 14.
And the ground : Scart 14 -> lpt pin 18.
This produce around +1V and a +5V according to the receiver is on/off.
I found this out by trying different resistors and this was the only way I found it to work ( more or less you put to the ground the pin 13 )

The receiver is a digital sat receiver and always shows a schedule for the next 7 days. ( I think it is called EPG ) You can simply select the programme you like to watch and mark it. If the receiver is off it turns on for the time the programme is shown and turns off afterwards. I guess this is a standard method as my Thomson VCR is able to start/stop accordingly this control voltage. The advantage is the precise recording, delay is not a problem.

My plan would be that I mark the programme I'd like to watch and turns on the PC. All the other should be done by a frame program : Start Virtualdub and wait for the LPT pin change to 1. Start
capturing and wait for the pin change back to 0. Close the programmes and shut down the PC. This frame prog is made in VB of Excel. I do not know Delphi or C, sorry. I sent the keys by Sendkeys command, which works fine for all the vdub commands but stopping capturing.

To complete the job the open issues are

1. I have installed WinMe and Win2k to one partition, but without manual change always WinMe starts. Is there a default selection somewhere just like the old MS-DOS times ?
2. Stop capturing
3. Shutting down PC at the end

Thanks again and any contribution is highly appreciated,

cow
2nd May 2002, 21:26
Sending messages is pretty easy. Here's a sample start/stop capture for VD to get you started...

I'm not a real VB guy, so this may not be pretty...

Const WM_COMMAND As Long = &H111
Const WM_CAP_STOP = &H444
Const ID_CAPTURE_CAPTUREVIDEOINTERNAL = 40100 ' from VD's resource.h

Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWndParent As Int32, ByVal hWndChildAfter As Int32, _
ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hWnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, _
ByVal lParam As Int32) As Int32

... etc ...

Dim hVDWnd As Int32
Dim hVDCapWnd As Int32

hVDWnd = FindWindowEx(0, 0, "VirtualDub", vbNullString)
hVDCapWnd = FindWindowEx(hVDWnd, 0, vbNullString, "Capture window")

... start cap ...

PostMessage(hVDWnd, WM_COMMAND, ID_CAPTURE_CAPTUREVIDEOINTERNAL, 0)

... stop cap ...

PostMessage(hVDCapWnd, WM_CAP_STOP, 0, 0)

If you have problems with INT32, try LONG. I don't know which works with VBA.

As for dual booting... If you're using Win2K's boot loader, I think you can set the default in Control Panel/System. Either that, or try messing around with the bootcfg command.

[edit: width trimmed]

Darksoul71
3rd May 2002, 13:50
Argh, VBA for a VCR frontend for Virtual Dub ?

I thought that you were using at least the "standalone" version of Visual Basic.

OK, this script is used by my VCR frontend to stop VDub after capturing and closes VDub:

dim osh
set osh = wscript.createobject("wscript.shell")
osh.sendkeys "{ESC}"
wscript.sleep 2000
osh.sendkeys "%F{x}"
wscript.sleep 2000
osh.sendkeys "%F{q}"

Works fine for me. So once again:
Try sending a ESC indipendently from your LPT function. If it work then something goes wrong with your LPT checking.

For shuting down windows you can use the following:

Windows 98 Instructions
by Paul Maxson

One Step Windows 98 Shutdown - Part 1
This month's Windows' tip is an economic way to shut down or restart Windows 98. In part 2
(next month) I will show you how you can schedule when your Windows machine shuts down.
With this tip you will create an icon that when you double-click on it will shut your machine off.
We will create another icon that will reboot your computer. The procedure to do this is outlined
below:

1. Right-click on a blank part of your desktop and choose New, then select Shortcut.
2. In the Command line, type the following exactly as you see it. There is no space on either side
of the comma.

rundll.exe shell32.dll,SHExitWindowsEx 1

3. Click on Next. In the next screen you can give your shortcut a name, probably something like
Windows Shutdown.


Now you can double-click on this icon and shut your computer down without using the Start
menu. If you use the MS Office Toolbar, you can drag this icon onto it and shut down your
computer with a single click.


You can create a similar shortcut to Reboot your computer with a double-click. Follow the steps
above, but in the Command line use the following syntax:

rundll.exe shell32.dll,SHExitWindowsEx 2

This shortcut will do a total reboot of your computer. Replace the 2 with a 0 and you can log off
and allow a different user to log on. If you would prefer not to create these files, they can be
found in the Tips folder on the Shared (S:) drive.


If you have any questions about this tip, feel free to call me. In Part 2 of this tip next month we
will learn how to shut down your computer at a preset time.



-D$

lovak1
8th May 2002, 08:08
cow, Darksoul,

Selection of default op.sys. works as you wrote System/Control Panel, thanks. Messages I have not tried as I found another solution.It is a program called ghostmouse, which able to record and play back mouse movements. I wrote two scripts, one of them is to click on Vdub window to stop capturing and another one for clicking on Start/Shutdown. Windows '98 Shutdown instructions does not work for Win2k.
I agree that VBA is not the language for this purpose. I'd rather write in Visual C but don't know how to begin ( learning ) it. If someone would translate my VBA program to Visual C than I could have a good start. It is not so complicated, contains Sendkeys, Calling external applications, wait commands. Plus an LPT object, checking one bit of a port.

And thanks again for your help,

Darksoul71
8th May 2002, 12:04
@lovak1:

could you please be so kind and drawn down your circuit (how LPT is connected to SCART) with the Z-Diode and resistor (values included). Post it here or send it to me via e-mail to darksoul@debitel.net.

This would be somewhat interesting for me to play around if I get the time.
May be I could add such a function to my VCR frontend for VDub.

BTW: What signal of the LPT port do you use to check for SCART data ?

Thanx,
D$