Cannot Move Mouse in Windows??

Just starting out? Need help? Post your questions and find answers here.
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Cannot Move Mouse in Windows??

Post by Randy Walker »

:shock:
Nothing happens with the mouse using MouseLocate()
I was expecting this to move my mouse, but nothing happens with mouse.

Code: Select all

MouseLocate(100,100)
Delay(1000)
MouseLocate(200,200)
Delay(1000)
MouseLocate(300,300)
INSTEAD, DO THIS:

Code: Select all

SetCursorPos_(100,100)
Delay(1000)
SetCursorPos_(200,200)
Delay(1000)
SetCursorPos_(300,300)
NOTE: MouseLocate requires InitMouse which also requires a special window be opened first.


// Moved from "Tricks 'n' Tips" to "Coding Questions" (Kiffi)
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
User avatar
mk-soft
Always Here
Always Here
Posts: 6320
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Cannot Move Mouse in Windows??

Post by mk-soft »

PB-Help wrote

PureBasic provides full access to mice plugged into the computer. It supports standard mice with up to 3 buttons. This library is optimized and uses very low level functions especially for games. Do not use the functions of this library in a regular application, in this case carry out the mouse queries with WindowMouseX(), WindowMouseY() and EventType().

Also for OpenScreen or OpenWindowedScreen
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: Cannot Move Mouse in Windows??

Post by RASHAD »

Hi Randy
MouseLocate() is for Sprite business (Windows DirectX)
It don't show the mouse cursor as in Windows application
For more info look at the Mouse.pb in doc
Egypt my love
User avatar
Mijikai
Addict
Addict
Posts: 1520
Joined: Sun Sep 11, 2016 2:17 pm

Re: Cannot Move Mouse in Windows??

Post by Mijikai »

PB does not provide input handling for Windows.
See feature request: viewtopic.php?t=85694
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Cannot Move Mouse in Windows??

Post by Randy Walker »

I stated the problem and gave a solution (trick) as a workaround so how did this get evaluated into a "coding question"?

I also stated MouseLocate requires special handling.

BTW . . . mouse.pb does not show how to move the mouse around on the desktop.
Randy Walker wrote: Sun Nov 17, 2024 12:01 am
INSTEAD, DO THIS:

Code: Select all

SetCursorPos_(100,100)
Delay(1000)
SetCursorPos_(200,200)
Delay(1000)
SetCursorPos_(300,300)
NOTE: MouseLocate requires InitMouse which also requires a special window be opened first.


// Moved from "Tricks 'n' Tips" to "Coding Questions" (Kiffi)
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: Cannot Move Mouse in Windows??

Post by RASHAD »

Hi Randy
Run Mouse.pb then click the middle mouse button
Egypt my love
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Cannot Move Mouse in Windows??

Post by Randy Walker »

mk-soft wrote: Sun Nov 17, 2024 12:53 am
carry out the mouse queries with WindowMouseX(), WindowMouseY() and EventType().
Keyword there is "queries", because those can only be used "To get the absolute x position of the mouse on the desktop" AND CANNOT be used to assign location of the mouse. So, as indicated in my OP the user must rely on the SetCursorPos_() alternative to MouseLocate.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Cannot Move Mouse in Windows??

Post by Randy Walker »

RASHAD wrote: Sun Nov 17, 2024 1:45 am Hi Randy
Run Mouse.pb then click the middle mouse button
That closes the app as per code:

Code: Select all

MessageRequester("Information", "This will test the fast mouse access..."+ #LF$ +
                                "Press any mouse button to quit!", 0)
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
AZJIO
Addict
Addict
Posts: 2225
Joined: Sun May 14, 2017 1:48 am

Re: Cannot Move Mouse in Windows??

Post by AZJIO »

I wanted to suggest DesktopMouseX() as an alternative to WindowMouseX(), but the author mentions SetCursorPos, so the recommendation is not appropriate.
Last edited by AZJIO on Sun Nov 17, 2024 2:18 am, edited 3 times in total.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: Cannot Move Mouse in Windows??

Post by RASHAD »

Are you sleepy or getting old ? :)
If MouseButton(#PB_MouseButton_Middle)
MouseLocate(ScreenWidth()/2, ScreenHeight()/2)
EndIf
Egypt my love
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Cannot Move Mouse in Windows??

Post by Randy Walker »

AZJIO wrote: Sun Nov 17, 2024 2:04 am

Code: Select all

Debug DesktopMouseX()
Debug DesktopMouseY()
Exactly How does that move the mouse?????!!!!!!
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
DarkDragon
Addict
Addict
Posts: 2347
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: Cannot Move Mouse in Windows??

Post by DarkDragon »

Omg I've never seen more people talking their way around the main topic :lol: . Happy Sunday.

As some already mentioned the MouseLocate function is intended for Games, so it shouldn't have been mentioned and instead create a Trick&Tips "how to set cursor position on windows" without mentioning a function obviously not intended for it. This way it probably wouldn't seem like a coding question.

Image

All these functions are for games.
bye,
Daniel
User avatar
mk-soft
Always Here
Always Here
Posts: 6320
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Cannot Move Mouse in Windows??

Post by mk-soft »

That's right 8)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
AZJIO
Addict
Addict
Posts: 2225
Joined: Sun May 14, 2017 1:48 am

Re: Cannot Move Mouse in Windows??

Post by AZJIO »

DarkDragon wrote: Sun Nov 17, 2024 9:17 am Omg I've never seen more people talking their way around the main topic :lol: . Happy Sunday.
I wanted to delete literally after 2 seconds, but a new message appeared and I had to write "del". But since the author decided to comment on the deleted message, I had to return the state of things, that is, the author himself develops the flood, not allowing it to be deleted.
DarkDragon wrote: Sun Nov 17, 2024 9:17 am and instead create a Trick&Tips
And what's the point of rewriting the entire WinAPI here, are people really not able to add an underscore between the name of the WinAPI function and the opening parenthesis?
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Cannot Move Mouse in Windows??

Post by Randy Walker »

DarkDragon wrote: Sun Nov 17, 2024 9:17 am
... a function obviously not intended for ...
All these functions are for games.
Oh YES!!! Somewhere in this help page it becomes so obvious mouseLocate is only for games :mrgreen:
MouseLocate()

Syntax

MouseLocate(x, y)
Description Changes the absolute position (in pixels) of the mouse in the current screen. This is useful when using MouseX() or MouseY().

Parameters x, y The new absolute position (in pixels) of the mouse in the current screen.

Return value None.


See Also

ExamineMouse(), MouseX(), MouseY()
Supported OS

All

<- MouseDeltaY() - Mouse Index - MouseWheel() ->
I just don't see it -- Maybe NOT so obvious???
I don't even see any mention of OpenScreen() or InitMouse() either. I do see where it says:
"Changes the absolute position (in pixels) of the mouse in the current screen".

@RASHAD Yes getting old, and probably one brain surgery ahead of you.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Post Reply