%! % Simulate mouse movement and clicks, with shifted keypad arrows % % Don Hopkins, University of Maryland Human Computer Interaction Lab % % Copyright (C) 1988 by Don Hopkins. All rights reserved. % This program is provided for unrestricted use, provided that this % copyright message is preserved. There is no warranty, and no author % or distributer accepts responsibility for any damage caused by this % program. % % Fake mouse movement: % % Control: small step (1 point) % Shift: medium step (16 points) % Meta: big step (100 points) % % R7 R8 R9 % R10 R12 % R13 R14 R15 % % Fake mouse clicks: % % Control-R11: Left mouse click % Shift-R11: Middle mouse click % Meta-R11: Right mouse click % % Unshifted function keys are just send through. % systemdict begin % Later: % Express interest in function key UpTransitions some how, leave % the Action field alone, and just send one event... /fake-button { % event name => event 1 index createevent copy % event name event begin % event name /Name exch def % event currentdict end % event FakeDownEvent dup createevent copy % event FakeDownEvent FakeDownEvent sendevent % event FakeDownEvent begin % event /Action /UpTransition def currentdict end % event FakeUpEvent sendevent % event } def /push-button { true 1 index /KeyState get { { /Control { pop /LeftMouseButton fake-button false exit } /Shift { pop /MiddleMouseButton fake-button false exit } /Meta { pop /RightMouseButton fake-button false exit } } case } forall { redistributeevent } if } def /move-mouse { % event dx dy => event gsave framebuffer setcanvas 2 index begin /Name /MouseDragged def YLocation add /YLocation exch def XLocation add /XLocation exch def XLocation YLocation setcursorlocation currentdict end sendevent grestore } def /mouse-small-step 1 def /mouse-medium-step 16 def /mouse-big-step 100 def /push-mouse { % event x y => event true 3 index /KeyState get { { /Control { pop mouse-small-step mul exch mouse-small-step mul exch move-mouse false exit } /Shift { pop mouse-medium-step mul exch mouse-medium-step mul exch move-mouse false exit } /Meta { pop mouse-big-step mul exch mouse-big-step mul exch move-mouse false exit } } case } forall { pop pop redistributeevent } if } def /FunctionR7 { -1 1 push-mouse } bindkey /FunctionR8 { 0 1 push-mouse } bindkey /FunctionR9 { 1 1 push-mouse } bindkey /FunctionR10 { -1 0 push-mouse } bindkey /FunctionR12 { 1 0 push-mouse } bindkey /FunctionR13 { -1 -1 push-mouse } bindkey /FunctionR14 { 0 -1 push-mouse } bindkey /FunctionR15 { 1 -1 push-mouse } bindkey /FunctionR11 { push-button } bindkey end % systemdict