How to move the mouse

61 views
Skip to first unread message

Louis LaBrunda

unread,
Sep 17, 2023, 10:19:43 AM9/17/23
to VAST Community Forum
Hi All,

Does anyone know/remember how to move the mouse pointer?  I think I use to know how to do this but can't remember hot to do it or in what program I did it.  Of course it may have been something I did just to see how and then it never got into a program.  I need to do it on Raspberry Pi Linux but would like it to work on Windows too.

Lou

Louis LaBrunda

unread,
Sep 17, 2023, 11:06:11 AM9/17/23
to VAST Community Forum
This:

PlatformFunctions::SetCursorPos callWith: 200 with: 200.

will do it on windows.  I'm still looking on Linux.

Lou

Louis LaBrunda

unread,
Sep 17, 2023, 1:06:03 PM9/17/23
to VAST Community Forum
it is a little more work under Linux:

| xDisplay xRootWindow |

xDisplay := OSDisplayPtr xOpenDisplay: ''.
xRootWindow := xDisplay xRootWindow: 0.

xDisplay xWarpPointer: nil destW: xRootWindow srcX: 0 srcY: 0 srcWidth: 0 srcHeight: 0 destX: 200 destY: 200.
xDisplay xFlush.

Louis LaBrunda

unread,
Sep 19, 2023, 7:34:34 AM9/19/23
to VAST Community Forum
Well, the Linux code works in the development environment but gets the attached walkback in production.  Do I need to know the name of the display and if so where do I find it?

Lou
walkback.log

VAST Community Forum

unread,
Sep 19, 2023, 12:51:43 PM9/19/23
to VAST Community Forum
Hi Guys,

It turns out the problem wasn't with the display name but with my #preform:withArguments: call.  I forgot to turn the OrderedCollection into an Array.  I knew I had to do it, my fingers just forgot to type it.

As you can tell from the code below, I have the code for both Windows and Linux in the same method.  Yes, I know it is awful.  But I didn't want to go through the hassle of adding two sub-applications, one for windows and one for Linux.  Each sub-application with one method extending the class that calls it.

It would be nice if a method named something like #setCursorPos:y: we made common to both Windows and Linux as part of the new push to add common OS controls.

Also, it would be cool if there was some way, maybe with a pragma, of putting the Windows and Linux code in one method.  I'm fine with the multiple sub-application feature with the sub-app being loaded based upon the OS being used when there are lots of classes and methods  but this is one little method.  It is also nice to be able to see the Windows and Linux code at the same time.

Lou


moveMousePointerOffScreen
"Hide the mouse pointer by moving it off screen."
| xDisplay xRootWindow oSDisplayPtrClass xArgs swp2 shp2 |

swp2 := shellWidth + 2.
shp2 := shellHeight + 2.
controller isWindows ifTrue: [(OSCall new) perform: #setCursorPos:y: with: swp2 with: shp2] ifFalse: [
oSDisplayPtrClass := Smalltalk at: #OSDisplayPtr.
xDisplay := oSDisplayPtrClass perform: #xOpenDisplay: with: 0.
xRootWindow := xDisplay perform: #xRootWindow: with: 0.
xArgs := OrderedCollection new.
xArgs
add: nil;
add: xRootWindow;
add: 0; add: 0; add: 0; add: 0;
add: swp2;
add: shp2.
xDisplay perform: #xWarpPointer:destW:srcX:srcY:srcWidth:srcHeight:destX:destY: withArguments: xArgs asArray.
xDisplay perform: #xFlush.
].
Reply all
Reply to author
Forward
0 new messages