home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / autodial.zip / suspend.cmd < prev    next >
OS/2 REXX Batch file  |  1997-03-10  |  3KB  |  74 lines

  1. /* suspend.cmd */
  2. /* By Jeff Jackowski       */
  3. /*    jeffj@ro.com         */
  4. /*    http://ro.com/~jeffj */
  5. /* Puts the commuupter into suspend mode
  6.    This script uses the apmtst library of REXX based PM automation functions
  7.    To run:
  8.       APM suport must be installed and hardware must have APM supprt
  9.       apmtst must be installed (its IBM EWS availble at hobbes.nmsu.edu)
  10.       the Power object from system setup must be open
  11.    Arguments:
  12.       suspend x fname
  13.       x is the number of seconds to wait
  14.       fname is a file name to check for the string "NoSuspend". If the file
  15.         is not present or does not contatin the string, the computer will be
  16.         suspended
  17.       Both arguments or just fname may be omitted
  18.    What happens:
  19.       suspend.cmd changes the keyboard focus to the Power object
  20.       it selects "Suspend" from the menus
  21.       changes keyboard focus to the 'Are you sure?' dialog
  22.       presses enter
  23.    Note:
  24.       The system will begin to enter suspend mode 6 seconds after this script
  25.        is run with a delay of a specified number of seconds passed as a parameter
  26.       The delays in the script are intentional for 2 reasons:
  27.         If input is given too fast, input may be lost. This is most notable
  28.          on systems using multiple desktops when the Power object is on a
  29.          non-visible desktop. 
  30.         Other programs (and other scripts of mine) may call this script and
  31.          then need to do a little more processing. An example is AutoDial.
  32.          It runs this script in a seporate process and then enters a loop to
  33.          read data from the modem. If it doesn't reach this loop, it won't
  34.          respond to the modem when someone calls its number. Being able to
  35.          respond is a major part of AutoDial's functionality.
  36. */
  37.  
  38. call rxfuncadd  'APMTLoadFuncs',  'apmtext', 'APMTLoadFuncs' 
  39. call APMTLoadFuncs;
  40. rc = INIT_SESSION();
  41. if rc \= 0
  42.    then do
  43.      say "Not connected"
  44.      /* call END_SESSION */
  45.      'path'
  46.      exit
  47. end
  48.  
  49. parse arg DelayTime CheckFile
  50.  
  51. if DelayTime \= '' then do
  52.    DelayTime = DelayTime * 1000
  53.    call WAIT DelayTime
  54. end
  55. if CheckFile \= '' then do   /* if file has string "NoSuspend", then quit */
  56.    scan = linein(CheckFile)
  57.    parse upper var scan chkStr
  58.    if (chkStr = "NOSUSPEND") then exit
  59. end
  60.  
  61. call SELECT_WINDOW "Power*"
  62. call WAIT 2000               /* delay needed or keyboard input may be lost */
  63. call KEYBOARD "F10"  /* the only pull down menu */
  64. call WAIT 1000
  65. call KEYBOARD "LEFT" /* move to the root of the menu (window submenu will appear) */
  66. call WAIT 1000
  67. call KEYBOARD "P"    /* select suspend */
  68. call WAIT 1000
  69. call SELECT_WINDOW "Workplace Shell"  /* goto the conformation dialog */
  70. call WAIT 1000
  71. call KEYBOARD "ENTER"                 /* say yes */
  72. call END_SESSION
  73.  
  74.