home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / rexxintuition_463.lzh / RexxIntuition / RexxIntui.lzh / scripts / Keys.rexx < prev    next >
OS/2 REXX Batch file  |  1990-06-27  |  2KB  |  50 lines

  1. /* An example of using the dissidents rx_intui.library */
  2.  
  3. wind = GetWindow('Press keys on the keyboard',,,,,,,,,)
  4. IF wind == '' | wind == 0 THEN SAY 'Window open error'
  5. err=SetDraw(wind,3,,1)
  6.  
  7. /* Since RAWKEY isn't one of the default IDCMP we get, we need to ask for it. */
  8. /* I'm going to ask for IDCMP = CLOSEWINDOW (512) + RAWKEY (1024).  */
  9. /* Also, I want CONVERT_RAW (8) for the extraFlags so that I get ascii values */
  10. /* back from the keyboard. */
  11. err=ModIDCMP(wind,8,512+1024,)
  12.  
  13. DO WHILE class > 0
  14. spec=WaitMsg(wind)
  15. /* divide the spec into separate parts */
  16. PARSE var spec class part1 part2 part3
  17.  
  18. /* Handle a RAWKEY event. Print all chars to the window except Function key, */
  19. /* cursor key, or Help. Translate these events into appropriate messages. */
  20. /* Press all of the keys on the keyboard, with and without the SHIFT, ALT, */
  21. /* and CTRL keys. Note that control chars such as BACKSPACE are reverse   */
  22. /* highlighted automatically when you do a Text(). This is because its value */
  23. /* is really 8 instead of the value of the ascii 'H' which is 72. */
  24. IF class == 5 THEN DO
  25. err=Erase(40,wind,5,20)
  26.  
  27. /* Now check to see if it is a Function key, cursor, or Help. */
  28. IF part2 > 0 THEN DO
  29. /* Now let's see whether the shift or Alt key was being held down with it */
  30. err=Text(,wind,5,20)
  31. IF part2 == 2 THEN err=Text('SHIFT ',wind,,)
  32. IF part2 == 4 THEN err=Text('ALT ',wind,,)
  33. /* If part1 is 0 to 9, then a function key */
  34. IF part1 < 10 THEN err=Text('Function #'part1,wind,,)
  35. /* Let's check for each cursor key and help key */
  36. IF part1 == 10 THEN err=Text('UP cursor',wind,,)
  37. IF part1 == 11 THEN err=Text('DOWN cursor ',wind,,)
  38. IF part1 == 12 THEN err=Text('RIGHT cursor ',wind,,)
  39. IF part1 == 13 THEN err=Text('LEFT cursor ',wind,,)
  40. IF part1 == 14 THEN err=Text('Help key',wind,,)
  41. END
  42.  
  43. /* Must not be a function, cursor, or help key if part2 == 0. So print that char */
  44. IF part2 == 0 THEN err=Text(part1,wind,5,20)
  45. END
  46.  
  47. END
  48.  
  49. err=EndWindow(wind)
  50.