home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CHIP_CD_2004-07.iso / software / nncron_hit / files / nncron189.exe / example.tab next >
Encoding:
Text File  |  2003-09-23  |  14.1 KB  |  502 lines

  1. # This file contains useful nnCron examples.
  2.  
  3. # setting environment variables:
  4.  
  5. SET CurTime=%hh%-%mm%
  6. SET FIDOCONFIG=d:\fido\hpt\fido.cfg
  7. SET SCITE_HOME=d:\tools\scite
  8. SET WGETRC=d:\tools\wget\wget.rc
  9.  
  10. # classic format examples: 
  11. # Minutes Hours Days Months WeekDays Years Command)
  12.  
  13. 30 1 * * * * your_app.exe
  14. 0 12,17 * * * * cmd /c "E:\home\nick\Books\knut\knut\KNUT-ALL.PDF"
  15. 15,20,30 * * 1,2,3,4 1-5 2000 test.cmd XXX-%TempFile%-YYY-%COMPUTERNAME%-ZZ && TIME /T >>xxx
  16. START-TIME cmd /c E:\home\nick\Books\progs\pietrekbook.pdf 
  17.  
  18. # extended format examples:
  19.  
  20. ##############################################################################
  21.  
  22. #( Chime-new 
  23. Time: */15
  24. Action: 
  25.     Min@ 0 =
  26.     IF
  27.         \ every hour
  28.         50 7000 BEEP
  29.     ELSE
  30.         Min@ 30 =
  31.         IF
  32.             \ every 30 minutes
  33.             50 7000 BEEP 
  34.             50 7000 BEEP
  35.             50 7000 BEEP 
  36.         ELSE
  37.             \ on 15 and 45 minutes
  38.             50 7000 BEEP 
  39.             50 7000 BEEP
  40.         THEN
  41.     THEN
  42. )#
  43.  
  44. ##############################################################################
  45. # Use this task to lock your workstation at specified time
  46.  
  47. #( lock-task
  48. WINAPI: LockWorkStation USER32.DLL
  49. Action:
  50.     LockWorkStation DROP
  51. )#
  52.  
  53. ##############################################################################
  54. # This task dials five different phone numbers, trying to establish internet
  55. # connection. When the connection is established 'get-mail.cmd' is started.
  56.  
  57. #( dial-task
  58. Time: 0 * * * * *    \ every hour
  59. Action:
  60.     ONLINE: "e96" 0= \  if _not_ online
  61.     IF
  62.         5 0 DO       \ loop 5 times
  63.             RASUser: "xxxx"
  64.             RASPassword: "yyyyy"
  65.             I        \ loop counter
  66.             CASE     \ choice
  67.                 0 OF RASPhone: "P2128506" ENDOF
  68.                 1 OF RASPhone: "P2128507" ENDOF
  69.                 2 OF RASPhone: "P2128508" ENDOF
  70.                 3 OF RASPhone: "P2128509" ENDOF
  71.                 4 OF RASPhone: "P2128510" ENDOF
  72.             ENDCASE
  73.             DIAL: "e96"
  74.             ONLINE: "e96"   \ online?
  75.             IF              \ Yes
  76.                 LEAVE       \ leave the loop
  77.             THEN           
  78.             10000 PAUSE     \ wait for 10 seconds
  79.         LOOP         \ end of the loop
  80.     THEN
  81.     START-APP: get-mail.cmd
  82. )#
  83.  
  84. ##############################################################################
  85. # This task monitors Windows clipboard contents for URLs that can be 
  86. # downloaded and starts 'wget.exe', passing the URL as command line 
  87. # parameter. Regular Expressions are used to parse the URL.
  88.  
  89. #( WGET_task
  90. : WGET-PAT S" /(http)|(ftp):\/\/[^ ]+?\.(zip)|(gz)|(rar)|(jpeg)|(jpg)|(exe)/i" ;
  91. WatchClipboard: *
  92. Rule: RE-MATCH: %CLIPBOARD% %WGET-PAT%
  93. Action:
  94.     RE-ALL: %CLIPBOARD% %WGET-PAT%
  95.         QUERY: "Download %$0%?"
  96.         IF
  97.             ShowNormal
  98.             StartIn: e:\home\download
  99.             START-APP: e:\bin\wget.exe %$0%
  100.         THEN
  101.    ;RE-ALL
  102. )#
  103.  
  104. ##############################################################################
  105. # The two following tasks are logging dialup activity on your PC (internet
  106. # connect/disconnect). Log files are stored in 'log\ras' folder.
  107.  
  108. <%
  109.     VARIABLE ConnectTime
  110.     VARIABLE DisconnTime
  111.     : raslogname S" log\ras\%YYYY%%MM%.log" EVAL-SUBST ;
  112.     : ConnTimeInSec DisconnTime @ ConnectTime @ - 1000 / ;
  113.     : ConnTimeInMin ConnTimeInSec 60 /MOD SWAP IF 1+ THEN ;
  114. %>
  115.  
  116. #( CONNECT
  117.     WatchConnect
  118.     Action:
  119.         GetTickCount ConnectTime !
  120.         GET-CUR-TIME
  121.         LOG: %raslogname% "%WW% %DD% %hh%:%mm%:%ss% connect %CONNECTION%"
  122. )#
  123.  
  124. #( DISCONNECT
  125.     WatchDisconnect
  126.     Action:
  127.         GetTickCount DisconnTime !
  128.         GET-CUR-TIME
  129.         LOG: %raslogname% "%WW% %DD% %hh%:%mm%:%ss% disconnect %LAST-CONNECTION% %ConnTimeInSec% %ConnTimeInMin%"
  130. )#
  131.  
  132. ##############################################################################
  133. # This task loggs internet activity for Win'9x/ME
  134.  
  135. #( CONNECT-ACTIVITY
  136. VARIABLE CONN-BUSY
  137. VARIABLE CONN?
  138. 0 VALUE BEGIN-CONN-TIME
  139. 0 VALUE CONN-TIME
  140. CREATE (LAST-CONNECTION) 256 ALLOT
  141. : LAST-CONNECTION (LAST-CONNECTION) COUNT ;
  142. Rule: CONN-BUSY @ 0=
  143. Action:
  144.     CONN-BUSY ON
  145.     BEGIN
  146.         ONLINE? 
  147.         IF 
  148.             CONN? @ 0=
  149.             IF CONN? ON
  150.                 CONNECTION (LAST-CONNECTION) PLACE
  151.                 GET-CUR-TIME
  152.                 TimeSec@ TO BEGIN-CONN-TIME
  153.                 LOG: "ras.log" "%WW% %DD%/%MM%/%YYYY% %hh%:%mm%:%ss% connect %LAST-CONNECTION%"
  154.             THEN
  155.         ELSE
  156.             CONN? @
  157.             IF CONN? OFF
  158.                 GET-CUR-TIME
  159.                 TimeSec@ BEGIN-CONN-TIME - TO CONN-TIME
  160.                 LOG: "ras.log" "%WW% %DD%/%MM%/%YYYY% %hh%:%mm%:%ss% disconnect %LAST-CONNECTION% %CONN-TIME%"
  161.             THEN
  162.         THEN
  163.         2000 PAUSE
  164.     AGAIN
  165. )#
  166.  
  167.  
  168. ##############################################################################
  169. # Windows Script Host examples
  170.  
  171. #( the-bat-start
  172. Time: 0 8,12 * * * *
  173. Action:
  174.     <JScript>
  175.         var WshShell = WScript.CreateObject("WScript.Shell");
  176.         WshShell.Run("\"e:\\win\\the bat!\\thebat.exe\" /NOLOGO");
  177.         WScript.Sleep(1000);          // wait one second
  178.         WshShell.AppActivate("The Bat!");
  179.         WScript.Sleep(1000);
  180.         WshShell.SendKeys("{F2}");    // check new messages
  181.     </JScript>    
  182. )#
  183.  
  184. #( find-RunOnce-parameter
  185.     Time: 0 12 * * 5 *
  186.     Action:
  187.       <JScript>
  188.         var WshShell = WScript.CreateObject("WScript.Shell");
  189.         WshShell.Run("regedit.exe");
  190.         WScript.Sleep(1000);
  191.         WshShell.AppActivate("Registry Editor");
  192.         WScript.Sleep(1000);
  193.         WshShell.SendKeys("^fRunOnce{ENTER}");
  194.       </JScript>
  195. )#
  196.     
  197. ##############################################################################
  198. # CD-ROM Insert/Remove events
  199. # cdslow.exe is a program for slowing down the speed of CD-ROM drives
  200. # 'F' is the letter of my CD-ROM drive
  201.  
  202. #( CDinsert
  203.     WatchDriveInsert: F
  204.     Rule: PROC-EXIST: cdslow.exe NOT
  205.     Action:
  206.         START-APP: E:\win\progs\CDSlow\cdslow.exe
  207. )#
  208.  
  209. #( CDremove
  210.     WatchDriveRemove: F
  211.     Rule: PROC-EXIST: cdslow.exe
  212.     Action:
  213.        WIN-CLOSE: "CDSlow 1.5" 
  214. )#
  215.  
  216. ##############################################################################
  217. # Check internet mail example. This task reports, if there is new mail is 
  218. # in your mailbox
  219.  
  220. #( check-new-mail
  221. VARIABLE prev-pop3-cnt
  222. Rule:
  223.     \ read old counter from file  
  224.     PAD 10 S" pop3cnt.txt" FREAD S>NUM prev-pop3-cnt !
  225.     \ check mail
  226.     POP3-CHECK: serv name pass
  227.     DUP DUP 0> prev-pop3-cnt @ <> AND
  228.     IF prev-pop3-cnt ! 
  229.         \ write new counter to file
  230.         FILE-WRITE: pop3cnt.txt "%prev-pop3-cnt @%"
  231.         TRUE ELSE DROP FALSE 
  232.     THEN
  233.    Action:
  234.         MSG: "You have new mail."
  235. )#
  236.  
  237. ##############################################################################
  238. # SEND-KEYS: example
  239.  
  240. #( test-send-keys
  241. RunOnce NoDel
  242. Action:
  243.     ShowNormal
  244.     START-APP: notepad.exe
  245.     HINT: "%crlf%Please, don't touch keybord and mouse during test.%crlf% "
  246.     1000 PAUSE
  247.     SEND-KEYS-DELAY: 50 1000
  248.     SEND-KEYS: "Well, show me the way{ENTER}To the next whiskey bar{ENTER}Oh, don't ask why{ENTER}Oh, don't ask why{ENTER}{ENTER}"
  249.     SEND-KEYS: "Show me the way{ENTER}To the next whiskey bar{ENTER}Oh, don't ask why{ENTER}Oh, don't ask why{ENTER}{ENTER}"
  250.     SEND-KEYS: "For if we don't find{ENTER}The next whiskey bar{ENTER}I tell you we must die{ENTER}I tell you we must die{ENTER}I tell you, I tell you{ENTER}I tell you we must die{ENTER}{ENTER}"
  251.     SEND-KEYS: "This is the END."
  252.     SEND-KEYS: "{LEFT}+({HOME})"
  253.     SEND-KEYS: "^{INSERT}"
  254.     SEND-KEYS: "{END}{ENTER}{ENTER}+{INSERT}!!!{ENTER}{ENTER}2 seconds..."
  255.     2000 PAUSE
  256.     SEND-KEYS: "@{F4}{DELAY 500}{RIGHT}{ENTER}"
  257.     HINT-OFF
  258. )#
  259.  
  260. ##############################################################################
  261. # WatchHotKey & WIN-TO-TRAY
  262. # This task minimizes active window into system tray on 'Alt+Ctrl+t' 
  263. # keystroke. Make sure that plug-in 'win2tray.spf' is loaded.
  264.  
  265. #( Minimize2Tray
  266. WatchHotKey: "@^t"
  267. Action:
  268.     WIN-TO-TRAY: %GetForegroundWindow%
  269. )#
  270.  
  271. ##############################################################################
  272. # Turning off the monitor.
  273.  
  274. #( Power_saving
  275. 600 CONSTANT IdleTime       \ idle time constant in seconds
  276. VARIABLE SaveMonFlg         \ activity flag
  277. Rule: 
  278.     IdleTime IDLE DUP 0= IF SaveMonFlg OFF THEN
  279.     PROC-EXIST: DivX_Player.exe 0= AND    \ don't turn off the monitor, 
  280.     PROC-EXIST: FlyVCD.exe 0= AND         \ if a video player is active 
  281.     PROC-EXIST: microdvd.exe 0= AND
  282.     SaveMonFlg @ 0= AND
  283. Action:
  284.     SaveMonFlg ON           \ sets the activity flag
  285.     MONITOR-LOW             \ turns the monitor to low power state
  286.     IdleTime 1000 * PAUSE   \ waits for 2nd interval 
  287.     IdleTime 3 * 2 / IDLE IF MONITOR-OFF THEN  \ turns the monitor off
  288. )#
  289.  
  290. ##############################################################################
  291. # This task plays a little melody through internal PC speaker, showing
  292. # the lyrics of the song (in Russian)
  293.  
  294. #( music_through_speaker
  295. Action:
  296.     BEEP: 30 247
  297.     HINT-POS: 100 100
  298.     THINTW: "nnCron karaoke:" 3
  299.     THINTW: "Are you ready?.." 2
  300.  
  301.     HINT-POS: 100 100
  302.     HINT: "...┼±δΦ Ω≥ε-≥ε..."
  303.  
  304.     PAUSE: 200
  305.  
  306.     BEEP: 280 330    \ E
  307.     PAUSE: 5
  308.     BEEP: 105 330    \ E
  309.     PAUSE: 100
  310.  
  311.     BEEP: 280 330    \ E
  312.     PAUSE: 5
  313.     BEEP: 105 330    \ E
  314.  
  315.     HINT-OFF
  316.     HINT-POS: 100 100
  317.     HINT: "...πΣσ-≥ε, ΩαΩ-≥ε..."
  318.  
  319.     PAUSE: 70
  320.  
  321.     BEEP: 20 294     \ D
  322.     PAUSE: 10
  323.     BEEP: 290 349    \ F
  324.     BEEP: 200 392    \ G
  325.     PAUSE: 10
  326.     BEEP: 280 440    \ A
  327.     BEEP: 120 262    \ C
  328.  
  329.     HINT-OFF
  330.     HINT-POS: 100 100
  331.     HINT: "...ΓΣ≡≤π, ∩ε≡εΘ..."
  332.  
  333.     PAUSE: 80
  334.  
  335.     BEEP: 320 349    \ F
  336.     BEEP: 180 440    \ A
  337.     BEEP: 500 392    \ G
  338.     PAUSE: 1000
  339.  
  340.     HINT-OFF
  341.     HINT-POS: 100 100
  342.     HINT: "...≈σ±≥φε..."
  343.  
  344.     PAUSE: 450
  345.  
  346.     BEEP: 280 330    \ E
  347.     BEEP: 110 294    \ D
  348.     PAUSE: 400
  349.  
  350.     HINT-OFF
  351.     HINT-POS: 100 100
  352.     HINT: "...µΦ≥ⁿ φσ ⌡ε≈σ≥..."
  353.  
  354.     PAUSE: 670
  355.  
  356.     BEEP: 20 247     \ B
  357.     PAUSE: 10
  358.     BEEP: 280 262    \ C
  359.     BEEP: 110 247    \ B
  360.     PAUSE: 80
  361.     HINT-OFF
  362.     BEEP: 280 220    \ A
  363.     BEEP: 110 330    \ E
  364.  
  365.     PAUSE: 1000
  366.  
  367.     BEEP: 30 247
  368.     HINT-POS: 100 100
  369.     THINT: "Thank you!" 3
  370. )#
  371.  
  372. ##############################################################################
  373. # This task counts how many minutes specified user works on your PC.
  374. # The minutes are logged in special log-file. If the user worked longer than
  375. # 60 minutes in a day the warning message is displayed.
  376.  
  377. #( log_minutes
  378. VARIABLE minutes_count
  379. Action:
  380.     USERNAME S" user_logon_name" COMPARE 0=
  381.     IF
  382.         PAD 10 S" f:\user_log\%DD%-%MM%-%YY%.cnt"
  383.         EVAL-SUBST FREAD S>NUM minutes_count !
  384.         minutes_count @ 61 <
  385.         IF
  386.             minutes_count 1+!
  387.             FILE-WRITE: "f:\user_log\%DD%-%MM%-%YY%.cnt" "%minutes_count @%"
  388.         ELSE
  389.             MSG: "That's enough! Shut down the PC"
  390.         THEN
  391.     THEN
  392. )#
  393.  
  394. ##############################################################################
  395. # This task will reminds you about birthdays of your friends.
  396. # Just create a text file 'birthdays.txt' with the following info on each 
  397. # line (without '#' line comment):
  398. #
  399. # 1968 02 08 Nemtsev Nicholas
  400. # 1968 06 28 Kondakoff Valery
  401. # 1955 10 28 Gates Bill
  402. #
  403.  
  404. #( birthdays
  405. OnceADay
  406. <(
  407. : birthdays.txt S" birthdays.txt" ;
  408. VARIABLE fb
  409. CREATE bline 256 ALLOT
  410. CREATE bname 64 ALLOT
  411. VARIABLE bdate
  412. VARIABLE byears
  413. VARIABLE bdays
  414. \ start reminding <pre-period> days before the birthday
  415. 5 CONSTANT pre-period
  416. )>
  417. Action:
  418.   birthdays.txt R/O OPEN-FILE-SHARED IF DROP ERR-MSG: "Can't open %birthdays.txt% file" EXIT THEN fb !
  419.   BEGIN bline 250 fb @ READ-LINE THROW WHILE
  420.     bline SWAP
  421.     <TIB
  422.        get-number Year@ get-number get-number YMD>DATE bdate !
  423.        Year@ SWAP - byears !
  424.        1 WORD COUNT 63 MIN bname PLACE
  425.        CUR-DATE bdate @ DATE- NEGATE DUP 0 > OVER pre-period < AND
  426.        IF bdays !
  427.           MSG: "Birthday reminder!!!%crlf%%bname COUNT%%crlf%Remining days: %bdays @%.%crlf%Aged: %byears @%.%crlf%Don't forget to send greeting card!"
  428.           \ do smth useful here - play a little melody, for example
  429.        ELSE DROP THEN
  430.     TIB>
  431.   REPEAT
  432.   DROP
  433.   fb @ CLOSE-FILE DROP
  434. )#
  435.  
  436. ##############################################################################
  437. # This task allows you to create your own custom pop-up menu, which will
  438. # be shown when you left-click on nnCron tray icon. You can set specifyed 
  439. # actions to the menu items.
  440.  
  441. #( lelftclick_popup_menu
  442. NoActive
  443. \ 1. Assigning menu items constants (you can use dynamic values there)
  444. 101 CONSTANT MI_1
  445. 102 CONSTANT MI_2
  446. 103 CONSTANT MI_3
  447. 104 CONSTANT MI_4
  448. 105 CONSTANT MI_5
  449. 106 CONSTANT MI_6
  450. \ 2. Creating the menu
  451. : MyMenu ( -- h)
  452.     POPUPMENU
  453.         S" Action 1"  MI_1 MENUITEM
  454.         S" Action 2"  MI_2 MENUITEM
  455.         MENUSEPARATOR
  456.         POPUP
  457.         S" Action 3"  MI_3 MENUITEM
  458.         S" Action 4"  MI_4 MENUITEM
  459.         S" More actions" END-POPUP
  460.     END-MENU
  461. ;
  462. VARIABLE lc_win
  463. VARIABLE lc_menu
  464. \ 3. This word will run the pop-up menu
  465. : run_menu
  466.     WITH TrayIcon
  467.     Z" static" 0 0 Window lc_win !
  468.     ENDWITH
  469.     MyMenu lc_menu !
  470.     lc_win @ SetForegroundWindow DROP
  471.     0 lc_win @
  472.     \ setting the position of the pop-up menu (y x)
  473.     MOUSE-POS SWAP
  474.     [ DECIMAL ] 256 lc_menu @ TrackPopupMenuEx
  475.     \ setting the actions for every menu item
  476.     CASE
  477.         MI_1 OF
  478.             \ MI_1 Action:
  479.             MSG: "Action 1" 
  480.         ENDOF
  481.         MI_2 OF 
  482.             \ MI_2 Action:
  483.             MSG: "Action 2" 
  484.         ENDOF
  485.         MI_3 OF 
  486.             \ MI_3 Action:
  487.             MSG: "Action 3" 
  488.         ENDOF
  489.         MI_4 OF 
  490.             \ MI_4 Action:
  491.             MSG: "Action 4" 
  492.         ENDOF
  493.     ENDCASE
  494.     lc_menu @ DestroyMenu DROP
  495. ;
  496. : run_menu_task lelftclick_popup_menu LAUNCH ;
  497. ' run_menu_task CronIcon OnLB ! 
  498. Action:
  499.     \ running menu when left-clicking on nnCron tray icon:
  500.     run_menu
  501. )#
  502.