-
Notifications
You must be signed in to change notification settings - Fork 130
VideoCapture
We don't want the Twiki to be no more than a code depository, but for the moment this snippet is the best way to illustrate this tricky example of using sendkeys.
- Category= Security
=begin comment This program illustrates the use of sendkeys to control a program (WinTV32) and capture TV pictures from a Hauppage WinTV? card. Sendkeys creates the equivalent of keyboard presses for a running program. Most Windows show valid key commands with an underlined or bold letter in the dropdown menus. Otherwise you can systematicly try every key, including shift, alt, and control versions to see what they do. There are often hidden features. To send eg "alt f" you send "alt" then "f" then deactivate " alt" with "alt-". But to send "alt" rather than "a", "l", "t", you send \alt\. But \ is a special character so it has to be escaped with \, so you actually send \\alt\\. phew! The basis is an original program by Jeff P. which captures pictures and files them under date and time. The unused bits of that are commented out. My cheat to speed it up just gets the picture into a holding file in \ia5\security\images by first manually saving a picture there in WinTV32 so that the program remembers that location. Then I changed the img tag in ia5\security\main.shtml to img src="images/Q.jpg" so the security web page displays it. Baz =cut # ------------------------------------------------------- $v_CaptureWinTv32 = new Voice_Cmd("Capture Camera");
if (said $v_CaptureWinTv32) { &CaptureWinTv32 ; }
- -------------------------------------------------------
- my $string1 = '\\ALT\\f\\ALT-\\a\\ALT\\t\\ALT-\\j\\ALT\\n\\ALT-\\';
- my $FileName = sprintf("Car_%s_%2.2i__%2.2i_%2.2i_%2.2i",$Year_Month_Now, substr($Date_Now, 9, 2), $Hour, $Minute, $Second);
- my $FileName = "frontdoorcam";
- my $string2 = '\\TAB\\\\TAB\\\\TAB\\\\TAB\\\\TAB\\\\TAB\\\\TAB\\90';
my $KeyCommand = $string1.$FileName.$string3;
- my $KeyCommand = $string1.$FileName.$string2.$string3; # building command like this is versatile
- WinTV32 must be running, but you can minimise it
- adjust for your CPU speed, I'm running 1500MHz. Start with a bigger number to see how it works
- my $SourcePath = 'c:\mh\mh\web\images\\'.$FileName.".jpg";
- my $DestPath = 'E:\mh\data\proxy\carftp\\'.$FileName.".jpg";
- print_log "CarCam SourcePath?: $SourcePath";
- print_log "CarCam DestPath?: $DestPath";
- my $rc = copy("$SourcePath", "$DestPath") or print_log "Error copying carcam to proxy: $!";
- print_log "CarCam copy results: $rc";
-- BazUK - 13 Mar 2004