home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxtech06.zip / VXTECH06 / EMPLIST / SENDKEYS.VRX < prev    next >
Text File  |  1994-10-25  |  1KB  |  51 lines

  1. /*:VRX         Main
  2. */
  3. /*
  4.     ok = SendKeys( caption, keys, timeout )
  5.  
  6.     - Wait for a window with caption "caption" to become
  7.     active then send keys "keys".
  8. */
  9. Main:
  10.     parse arg targetCaption, keys, timeout
  11.     retVal = 0
  12.     if targetCaption \= "" then do
  13.         ok = SKWait( targetCaption, timeout )
  14.         if \ok then do
  15.             call Error 'Unable to send "' || keys || '" to' targetCaption 'in' timeout 'seconds.'
  16.             signal SendKeysDone
  17.         end
  18.     end
  19.     ok = VRMethod( "Application", "SendKeyString", '', keys )
  20.     if \ok then signal SendKeysDone
  21.     call SysSleep 1
  22.     retVal = 1
  23. SendKeysDone:
  24. exit retVal
  25.  
  26. /*:VRX         SKWait
  27. */
  28. /*  
  29.     ok = SKWait( caption, timeout )
  30.  
  31.     - Wait for a specified window to become active
  32.     - Only compares up to length of <caption> so titles that change when MDI
  33.     windows are maximized are still found.
  34. */
  35. SKWait: procedure
  36.     parse arg targetCaption, timeout
  37.  
  38.     ok = 0
  39.     do timeout
  40.         window = VRMethod( "Screen", "FindWindow", targetCaption, "Desktop", "descendents", "mixed", "substring" )
  41.         if window \= "" then do
  42.             ok=1
  43.             call VRMethod window, "Activate"
  44.             signal SKWFound
  45.         end
  46.         call SysSleep 1
  47.     end
  48.  
  49. SKWFound:
  50. return ok
  51.