Author Topic: How to move mouse cursor out of your window's application with QB64 keywords  (Read 6285 times)

0 Members and 1 Guest are viewing this topic.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Hi guys and gals
Thanks for your contribute to the  thread.

@SMcNeill
Hi Stevw. I have tryed to  use only  _Dest  and _Source  without change the acreen ... and it doesnt  work because _Mousemove acts on active screen

So I have tried using Screen  in order to  change window dimensions  and then _mousemove. But each time you call Screen it resets the output and mouse moves itself in the window.

I'll get a try to use the pageactive and the pageshowed  parametwrs of Screen.

@SpriggsySpriggs
Fine suggestion _mouseclick  I  know it mow.
And I'll try it.
Programming isn't difficult, only it's  consuming time and coffee

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
I finally had a change to head home for just a few minutes today, so here's my take for this type of problem:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(500, 400, 32)
  2.     k$ = INKEY$
  3.     IF k$ = " " THEN MoveDesktopMouse RND * _DESKTOPWIDTH, RND * _DESKTOPHEIGHT
  4.     LOCATE 24, 1: PRINT " press space to move mouse on screen, m to quit";
  5.     _LIMIT 30
  6. LOOP UNTIL k$ = "m"
  7.  
  8.  
  9. SUB MoveDesktopMouse (x AS INTEGER, y AS INTEGER)
  10.  
  11.     STATIC tempscreen
  12.     SX = _SCREENX: SY = _SCREENY
  13.     D = _DEST
  14.     IF tempscreen = 0 THEN
  15.         tempscreen = _NEWIMAGE(_DESKTOPWIDTH, _DESKTOPHEIGHT, 32)
  16.     END IF
  17.     SCREEN tempscreen
  18.     ScreenMove 0, 0
  19.     _MOUSEMOVE x, y
  20.     SCREEN D
  21.     _SCREENMOVE SX, SY
  22.  
  23.  
  24. SUB ScreenMove (x, y)
  25.     $IF BORDERDEC = UNDEFINED THEN
  26.         $LET BORDERDEC = TRUE
  27.         DECLARE LIBRARY
  28.             FUNCTION glutGet& (BYVAL what&)
  29.         END DECLARE
  30.     $END IF
  31.     BorderWidth = glutGet(506)
  32.     TitleBarHeight = glutGet(507)
  33.     _SCREENMOVE x - BorderWidth, y - BorderWidth - TitleBarHeight
  34.  
  35.  
  36.  

I'm using just QB64 commands to move our mouse to random spots outside our window.  The screen DOES have a slight flicker to it when this happens, but I consider this a FEATURE rather than a BUG, as I'd consider it to be a way to notify the end user of such an odd action.  It's not every day where you want to toss your cursor to someplace random across the screen after all!

;)
« Last Edit: May 01, 2021, 09:59:37 am by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
@SMcNeill Works for me, don't see ever needing it but fun little challenge. :)

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
@SMcNeill
Yes Steve you got it. You have avoid the quicksand of _FULLSCREEN and it works with no issue.
Grat Job!
Programming isn't difficult, only it's  consuming time and coffee