mouse5.pp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {example for GetLastButtonPress and GetLastButtonRelease}
  2. Uses MsMouse, Crt;
  3. Var x, y, times: Longint;
  4. c: Char;
  5. Begin
  6. If MouseFound Then
  7. Begin
  8. ClrScr;
  9. ShowMouse;
  10. Writeln('Move the mouse and click the buttons (press escape to quit).');
  11. Writeln('Press the L-key to see the stats for the left button.');
  12. Writeln('Press the R-key to see the stats for the right button.');
  13. Writeln('Press the M-key to see the stats for the middle button.');
  14. GotoXY(1,19);
  15. Write('Since the last call to GetLastButtonPress with this button as parameter, the');
  16. GotoXY(1,22);
  17. Write('Since the last call to GetLastButtonRelease with this button as parameter, the');
  18. Repeat
  19. If Keypressed Then
  20. Begin
  21. c := UpCase(Readkey);
  22. Case c Of
  23. 'L':
  24. Begin
  25. GotoXY(1, 20);
  26. ClrEol;
  27. times := GetLastButtonPress(LButton, x, y);
  28. Write('left button has been pressed ',times,
  29. ' times, the last time at (',x,',',y,')');
  30. times := GetLastButtonRelease(LButton, x, y);
  31. GotoXY(1,23);
  32. ClrEol;
  33. Write('left button has been released ',times,
  34. ' times, the last time at (',x,',',y,')')
  35. End;
  36. 'R':
  37. Begin
  38. GotoXY(1, 20);
  39. ClrEol;
  40. times := GetLastButtonPress(RButton, x, y);
  41. Writeln('right button has been pressed ',times,
  42. ' times, the last time at (',x,',',y,')');
  43. times := GetLastButtonRelease(RButton, x, y);
  44. GotoXY(1,23);
  45. ClrEol;
  46. Write('right button has been released ',times,
  47. ' times, the last time at (',x,',',y,')')
  48. End;
  49. 'M':
  50. Begin
  51. GotoXY(1, 20);
  52. ClrEol;
  53. times := GetLastButtonPress(MButton, x, y);
  54. Writeln('middle button has been pressed ',times,
  55. ' times, the last time at (',x,',',y,')');
  56. times := GetLastButtonRelease(MButton, x, y);
  57. GotoXY(1,23);
  58. ClrEol;
  59. Write('middle button has been released ',times,
  60. ' times, the last time at (',x,',',y,')')
  61. End
  62. End
  63. End;
  64. Until (c = #27); {escape}
  65. While KeyPressed do ReadKey;
  66. GotoXY(1,24);
  67. HideMouse
  68. End
  69. End.