The Naked Scientists

The Naked Scientists Forum

Author Topic: How can I set a program to automatically record?  (Read 10683 times)

Offline syhprum

  • Neilep Level Member
  • ******
  • Posts: 3822
  • Thanked: 19 times
    • View Profile
How can I set a program to automatically record?
« on: 28/04/2009 08:25:32 »
I wish to use my computer to record weather satellite pictures switched on by a time switch.
It is easy enough to have the recording program (WxToIMG) switched on by the start program but I need to get it into an active mode that normally requires two keystrokes, any suggestions.
« Last Edit: 14/05/2009 13:23:10 by BenV »


 

Offline LeeE

  • Neilep Level Member
  • ******
  • Posts: 3382
    • View Profile
    • Spatial
Re: How can I set a program to automatically record?
« Reply #1 on: 28/04/2009 14:27:04 »
Apparently, one of the features of WxToIMG is "completely automated recording, decoding, and web page production and publishing" - doesn't this do what you want, or are you talking about the system being in stand-by or hibernation?
 

Offline syhprum

  • Neilep Level Member
  • ******
  • Posts: 3822
  • Thanked: 19 times
    • View Profile
Re: How can I set a program to automatically record?
« Reply #2 on: 29/04/2009 07:16:35 »
I am indeed talking about the computer being powered down until the 4 hour window in which the satellite provides a useful picture.
There is no problem if the computer is left switched on but I was hoping to economise on power.
 

Offline LeeE

  • Neilep Level Member
  • ******
  • Posts: 3382
    • View Profile
    • Spatial
Re: How can I set a program to automatically record?
« Reply #3 on: 29/04/2009 12:54:55 »
Use one of those timer-plugs.

Set the plug timer to power up and boot the system before the 4-hour window opens, then use a cron entry to shut it down once the window has passed.  Set the timer-plug to switch off 30 minutes or so after the cron shutdown entry has run.
 

Offline nicephotog

  • Sr. Member
  • ****
  • Posts: 387
  • Thanked: 7 times
  • H h H h H h H h H h
    • View Profile
    • Freeware Downloads
Re: How can I set a program to automatically record?
« Reply #4 on: 08/05/2009 02:47:50 »
Use Chron in Linux, or for windows use their job utility system tools- "scheduled tasks".
If the pictures are taken and stored at a URL (Universal Resource Location)"file" or URI (Universal Resource Identifier)"directory" then you can simply obtain them.

For "two key-strokes" there is for either WSH or a language such as java2 (that can be started when a program is written for the system startup folder) to use to make a short program with which to use exec() and an programming code symbolisis syntax action called a "key mask" and "event".

Another point WxToIMG is to "cd" to its folder and if its an (.bin in Linux) .exe on windows type: "WxToIMG.exe /?"   at the prompt to see if it has any special flags and command flags.

E.G.

C:\Documents and Settings\Workstation>Firefox /?
'Firefox' is not recognized as an internal or external command,
operable program or batch file.

C:\Documents and Settings\Workstation>cscript /?
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

Usage: CScript scriptname.extension [option...] [arguments...]

Options:
 //B         Batch mode: Suppresses script errors and prompts from displaying
 //D         Enable Active Debugging
 //E:engine  Use engine for executing script
 //H:CScript Changes the default script host to CScript.exe
 //H:WScript Changes the default script host to WScript.exe (default)
 //I         Interactive mode (default, opposite of //B)
 //Job:xxxx  Execute a WSF job
 //Logo      Display logo (default)
 //Nologo    Prevent logo display: No banner will be shown at execution time
 //S         Save current command line options for this user
 //T:nn      Time out in seconds:  Maximum time a script is permitted to run
 //X         Execute script in debugger
 //U         Use Unicode for redirected I/O from the console

C:\Documents and Settings\Workstation>

AND E.G.:

C:\Documents and Settings\Workstation>cd "C:\Program Files\Mozilla Firefox"

C:\Program Files\Mozilla Firefox>Firefox /?

C:\Program Files\Mozilla Firefox>firefox ?

C:\Program Files\Mozilla Firefox>
« Last Edit: 08/05/2009 02:52:10 by nicephotog »
 

Offline techmatt

  • Jr. Member
  • **
  • Posts: 28
    • View Profile
Re: How can I set a program to automatically record?
« Reply #5 on: 12/05/2009 04:03:06 »
Most system BIOS or setup will allow you to tell the computer to turn on at a specified time.
Then use task scheduler to run the shutdown command at a specified time. Place the program you want to use in the startup folder in the start menu. This should give you all the functions you asked for except the clicks but as LeeE stated it the program supports this action on its own. Hope this helps.
 

Offline syhprum

  • Neilep Level Member
  • ******
  • Posts: 3822
  • Thanked: 19 times
    • View Profile
How can I set a program to automatically record?
« Reply #6 on: 01/06/2009 07:51:38 »
I have found the solution, after breakfast I go upstairs, switch on the computer and enter file, record, auto record, switch off the monitor and forget about till after lunch when I go up again and look at the received pictures.
 

Offline nicephotog

  • Sr. Member
  • ****
  • Posts: 387
  • Thanked: 7 times
  • H h H h H h H h H h
    • View Profile
    • Freeware Downloads
How can I set a program to automatically record?
« Reply #7 on: 02/06/2009 09:03:30 »
THE SCRIPT .vbs has been modified because of grubby work by me
Fri, Jun 5, 2009
AND AGAIN WITH THE NEW .sh Linux / .bat Win server 2003 Resource Kit Tools (works in XP desktop and newer)
UPDATED Sat, Jun 6, 2009 at approx. 8:00 PM


Note: Adjust all the lines in the scripts/batches for the X and Y arguments to the
java class.
e.g.
java -classpath "/home/scripJbat" Mpress 50 180

SUCCESS (but with both .vbs WSH script AND a Java2 class together in a folder)

MS Corp.Windows OS only:
(requires at least versions: Microsoft Windows Script Host Shell "WSH 5.6"
and also as minimum level Java2 Runtime Environment JVM of later sub-version Sun Microsystems Inc. JRE 1.4.2):

Robot mouse press script - Download URL:
http://www.nicephotog-jsp.net/scrip(05-06-2009).zip
or Download URL 2 (zipped "php is the CGI script"):
http://www.nicephot.xlphp.net/scrip-05-06-2009.php
Empty the zip onto drive c:\ with your zip archive decompressor using its' setting "use folder names". There is only one folder that contains the scripts and must be on c:\ drive at that folder path level. So it should be c:\scrip

A few points about setting up WXtoImg to use with this first.
note: The location of the program in the .vbs for program start
is C:\Progra~1\WXtoImg\xwxtoimg.exe . If you place the program somewhere else
when you install WXtoImg you will need to change that line to the .exe but don't
forget to use the \\ double back-slash (reverse modulus reverse solidus {sorry about the name mistake}) syntax when writing it in.
1. After install, put in your land based location as close as possible first.
2. Be sure to update the "kelpers" for the sattelites or the WXtoImg program will
crash.
3. Before attempting to tune this robot script-system to the job; restart
the WXtoImg program and always leave it in the position and size you have pre tuned
the robot mouse pointer movement to land at for the button press or it will miss when
you use this automation script system.
4. If you use the "advanced GUI" option of the WXtoImg program be sure that it is set
and tuned to that before using this automated script system or the mouse pointer
could miss pressing the record button.


 [O8)]

NEXT UPDATED Sat, Jun 6, 2009 at approx. 8:00 PM for timing system at startup
Alternate (easier) MS Win .bat system / OR / LINUX SHELL and the Java class
Requires a download from Microsoft.com of approx. 12 Mbytes
Windows Server 2003 Resource Kit Tools (download rktools.exe)
http://technet.microsoft.com/en-au/windowsserver/bb405955.aspx

and a 1.4.2 Java2 JRE as above.
Alternative download URL:

http://www.nicephotog-jsp.net/scripJbat(06-06-2009).zip

(so all you need to know now is how to wake a computer and have pre set up a task to start WXtoImg by the .vbs and java.awt.Robot java class)

All you need know now also is how to modify the coordinates X and Y position of where to land your mouse-pointer when running the script.
These two arguments in these lines in the script
after testing where the mouse pointer  should land
using test-run.bat first...
Note: if the mouse pointer ever lands where you cannot see it e.g. the test-run.bat DOS prompt or somehow another window, All you need do in
MS Windows is Hold down the ALT key and tap on the TAB key once, then a small window will appear in the center of the screen with the task-bar
icons on it. Continue to hold down the ALT key and tap TAB key until the selection colour reaches the windows' icon you want to be the top window,
then release the ALT KEY and the Window will lift to the top.
XcoordButton = "150"
YcoordButton = "455"


Two things i should have explained..........

1. wherever the window was last opened in pixel position in the screen and (usually size) is how and where the application will start.
b. do not have any other windows open either at startup or when running the .bat
Don't move your application window around or resize it after that!!!!!!!!!!!!!!!!!!!!!!!!

AUTO-WX-ATTEMPT.vbs next  [O8)]

Code: [Select]
'
' AUTO-WX-ATTEMPT.vbs written by Mr.Samuel A Marchant Sydney Australia May 2009 in SucommanderXer Last Pre Beta (version: 31-01-2009)
set wscl = WScript.CreateObject("WScript.Shell")
WScript.Sleep 60000
exline="C:\\Progra~1\\WXtoImg\\xwxtoimg.exe"
WScript.Sleep 60000
wscl.exec(exline)
WScript.Sleep 60000 ' ( SHOULD BE SET AT - 60000 = 1 MINUTE - ) THIS ONE MUST ALWAYS TAKE MORE THAN 20 SECONDS
'
' NEXT ARE THE SCREEN POSITION OF THE BUTTON IN WXtoImg FOR "record" ON THE SUB GUI
' THEY ARE LITERALS MEANING REPLACE THEM WITH AN INTEGER(in this instance) NUMBER ONLY AS THEY ARE READ ON THE LINE
' THESE ARE COMMANDLINE ARGUMENTS SO BE SURE THEY ARE ENCLOSED IN DOUBLE QUOTES (NO SPACES ON EITHER END)
' IN MY VERSION AT 1024 X 768
XcoordButton = "150"
YcoordButton = "455"
'
' NEXT sleeps the script and WAITS FOR THE GUI TO BE PROPERLY BUILT AND REMOVED OF THE SPLASH SCREEN
WScript.Sleep 5000
' WXtoImg is the spelling on my copy
wscl.AppActivate "WXtoImg [Freeware edition]"
WScript.Sleep 1000
' NEXT ALT key on the first menu
wscl.SendKeys("%")
WScript.Sleep 100
wscl.SendKeys("{DOWN}")
WScript.Sleep 100
wscl.SendKeys("{DOWN}")
WScript.Sleep 100
wscl.SendKeys("{DOWN}")
WScript.Sleep 100
wscl.SendKeys("{DOWN}")
WScript.Sleep 100
wscl.SendKeys("{DOWN}")
WScript.Sleep 100
wscl.SendKeys("{DOWN}")
WScript.Sleep 100
wscl.SendKeys("{DOWN}")
WScript.Sleep 100
' NEXT enter is on the record tab 7th down the list
wscl.SendKeys("{ENTER}")
WScript.Sleep 6000
' ==================== MODIFY THE MOUSE PRESS COORDINATES ABOVE ON LINES 14 (XcoordButton) AND 15 (YcoordButton) AS DESCRIBED IN THE COMMENTS =========
' == USE test-run.bat BY EDITING THEN TRIGGERING TO TEST WHERE THE MOUSE WILL LAND AND PRESS (IT TRIGGERS THE Mpress CLASS ALONE ONLY) ==
exline="javaw Mpress " & XcoordButton & " " & YcoordButton
wscl.exec(exline)



MpressControl.sh FOR LINUX NOTE:the first # @@@@ comment line below   [O8)]

Code: [Select]
#!/bin/sh
# @@@@@@@  /home/scripJbat MUST BE THE LOCATION OF the scripJbat folder and java class Mpres
# @@@@@@@  OR ERROR WILL RESULT
# written by mr. Samuel A Marchant Sydney Australia 06-06-2009
#
# GRANT THIS PERMISSION TO ==EXECUTE== ON THE FILES PROPERTIES TAB FIRST
#
# NOTE: ***AUTOMATIC START AND RESTART*** OF THE MACHINE IS DONE BY "BIOS" POWER MANAGEMENT
# WHILE IT CAN BE PROGRAMMED IT IS OFTEN DONE THROUGH USE OF A SYSTEM CALLED W.O.L.
# Wake On LAN(Local Area Network) of some Main-Boards have a special jack connector or
# is on a 10/100 network card, HOWEVER, THE MAIN METHOD IS DONE BY USING A SPECIAL
# EXTERNAL DEVICE CALLED A MANAGED U.P.S. (Uninterrupted Power Supply) AND ITS SOFTWARE.
# http://www.newbtopro.com/guide/part_3_setting_bios
# http://www.linux.com/news/hardware/laptops/8253-how-to-suspend-and-hibernate-a-laptop-under-linux
#
# swsusp command kernal 2.6. [poweroff reboot shutdown and halt ARE NOT OF USE FOR
# AUTOMATIC RESTART]
# http://fchabaud.free.fr/English/Tricks/Laptop/Swsusp/Doc/Software-suspend-1.html#ss1.1
# http://www.tuxonice.net/HOWTO-4.html#ss4.1
#
# note: that cron itself is simply the daemon and is modified by the
# crontab command http://webtools.live2support.com/linux/crontab.php
#
# NOTE: crontab does not like su as the user so use a username that
# the machine will either start into or running when the command is run
# to run this shell script
#
# cron emails the output of the command to the user but that can be
# suppressed SEE: http://webtools.live2support.com/linux/crontab.php
#http://www.linux.com/archive/feature/43774
#
# BE SURE CRON IS ALWAYS SET TO BE STARTED AT MACHINE STARTUP
#
# this script should remain in the folder where the folder is placed
# and chrontab should be used to set the command ro issue a shell
# command by the cron daemon
# ==================================================================================================
# if the next shell command line(pair) does not operate check ownership of the
# wxtoimg binary. Also that it has executable ability on the properties tab
# or just attempt any these pair lines set below by uncommenting
#cd /usr/local/bin
#./wxtoimg
# or this
#cd /usr/local/bin
#wxtoimg
# or finally this (can be the case for a binary)
#cd /
#/usr/local/bin/wxtoimg
#
cd /usr/local/bin
exec ./wxtoimg
# sleep until startup is complete
sleep 180
# caution on 8 bit speed systems note sleep is not real world timimg
sleep 20
# first the alt button
java -classpath "/home/scripJbat" Mpress 50 45
sleep 5
# open record panel
java -classpath "/home/scripJbat" Mpress 50 180
sleep 10
# press record button after waiting for sub GUI to build
java -classpath "/home/scripJbat" Mpress 175 470



  [O8)]
MpressControl.bat Win XP and beyond
(must have Windows 2003 server toolkit shell intalled)

Code: [Select]
REM found info at http://malektips.com/xp_dos_0002.html
REM Windows Server 2003 Tools shell in XP rktools.exe
REM http://technet.microsoft.com/en-au/windowsserver/bb405955.aspx
REM using toolkits shell command SLEEP
REM sleep until startup is complete
sleep 180
call c:\scripJbat\bump.bat
sleep 15
REM first the alt button
javaw -classpath "c:\scripJbat";. Mpress 50 45
sleep 5
REM open record panel
javaw -classpath "c:\scripJbat";. Mpress 50 180
sleep 10
REM press record button after waiting for sub GUI to build
javaw -classpath "c:\scripJbat";. Mpress 175 470


Mpress Java2 class next NOTE: args 0 AND args 1 ARE NOT PROPERLY PRINTED IN THE CODE BELOW BECAUSE OF SQUARE BRACKETS AND ARE ONLY SHOWING AS args  [O8)]

modified for completeness with a static convertor method.

Code: [Select]
/* Mpress.java written by Mr S.A.Marchant June 2009 */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Mpress{
static int x;
static int y;

Mpress(){}
/*
 the techinally correct way to set a global variable
 because of scope "use a returning method"
 */
static int mkInt(String cmmdlnStr){
// static class call to static convertor method
return Integer.parseInt(cmmdlnStr);
}//enmeth
// THE SQUARE BRACKETS AROUND THE NUMERALS FOR THE args ARRAY
// ARE NOT SHOWN HERE BECAUSE THE FORUM CGI SCRIPT DOES NOT
// ALLOW FOR THEM
//the zip containing the scripts/batches has this code in it for
// recompile or modification and is as is without warranty or guarantee
public static void main(String args  )throws AWTException{
if(args.length > 1){
try{
x=mkInt(args 0 ); //Integer.parseInt(args 0 );
} catch (NumberFormatException e){
System.err.println("Argument must be an integer args-0 (first argument)");
System.exit(1);
}
try{
y=mkInt(args 1 ); //Integer.parseInt(args 1 );
} catch (NumberFormatException e){
System.err.println("Argument must be an integer args-1 (second argument)");
System.exit(1);
}
}else{
System.out.println("Argument length not sufficient");
System.exit(1);
}//enif
// DEBUG OUTPUT ONLY
//System.out.println("arg0: "+args 0 );
//System.out.println("arg1: "+args 1 );
Robot rb = new Robot();
rb.mouseMove(x,y);  //120,460  THIS LINE HERE CONTROLS WHERE THE BUTTON IS PUSHED X AND Y COORDS
rb.delay(1000);
rb.mousePress(InputEvent.BUTTON1_MASK);
rb.delay(1000);
rb.mouseRelease(InputEvent.BUTTON1_MASK);
}//enmain
}//enclss

EXECUTION BATCH CODE  "wxtoim-startup.bat"  [O8)]

Code: [Select]
REM this goes in the startup folder
REM below is exactly where the scrip folder should be and the .vbs
wscript c:\scrip\AUTO-WX-ATTEMPT.vbs

"test-run.bat" self explaining    [O8)]

Code: [Select]
REM SOMEWHERE NEAR SCREEN MIDDLE FOR 1024 X 768
REM MIDDLR APPROX. 500 330
REM be sure there is only one space between all parts of the next
REM commandlines arguments and no spaces on the ends
REM change the two integer numbers below to change the position to test
REM where the mouse press will be when moved to then triggered
REM this batch only runs the mouse press-move class alone
javaw Mpress 150 450
pause

"test-run.sh" FOR LINUX self explaining    [O8)]

Code: [Select]
#!/bin/bash
# written by mr. Samuel A Marchant Sydney Australia 06-06-2009
# USE THIS SCRIPT BY CALLING IT ONLY FROM WITHIN THIS DIRECTORY
# (cd into this directory first) OR IT WILL NOT OPERATE
# KEEP YOUR PROMPT WINDOW AS SMALL AS POSSIBLE
# somewhere near screen middle for 1024 x 768
java Mpress 500 300


Bit more on monitors and sleep...

..."switch off the monitor and forget about till after lunch when I go up again and look at the received pictures"...
You can set the monitor inside windows to switch off as a power saver mechanism until you hit enter or the space key.

"Display(icon)" - "screen saver"(tab) - "power"(GUI button)

See microsoft.com and search for "hibernate" and as it is you want to find "Standby"
http://www.microsoft.com/windowsxp/using/tabletpc/getstarted/standby.mspx

Stanby is the one to use.
Play with the power scheme drop down list to get an idea of how to set these.
To run a script, you will want to keep the hard drive active so select "Never" for a hard drive.
With WSH you will at least require to use, wscl.AppActivate "WXtiImg [Freeware edition]" to push
the window to the top and alert the monitor(though that may not be required if some auto record technique is used).

It seems i overshot the bit about 137 MHz reciever equipment being reasonably cheap and nasty for the purpose on
the soundcard.

Note: NEVER PUT IN A MOUSE EMULATOR PROGRAM (UNLESS YOU SERIOUSLY REQUIRE TO) IF YOU WANT THE ROBOT AND SCRIPT TO OPERATE (IT OFTEN CHANGES KEYS AND ACTIONS AROUND).
« Last Edit: 17/06/2009 08:08:28 by nicephotog »
 

The Naked Scientists Forum

How can I set a program to automatically record?
« Reply #7 on: 02/06/2009 09:03:30 »

 

SMF 2.0.10 | SMF © 2015, Simple Machines
SMFAds for Free Forums