Page 1 of 2
Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 12:01 am
by Randy Walker
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)
Re: Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 12:53 am
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
Re: Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 1:16 am
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
Re: Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 1:33 am
by Mijikai
PB does not provide input handling for Windows.
See feature request:
viewtopic.php?t=85694
Re: Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 1:41 am
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)
Re: Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 1:45 am
by RASHAD
Hi Randy
Run Mouse.pb then click the middle mouse button
Re: Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 1:51 am
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.
Re: Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 1:59 am
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)
Re: Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 2:04 am
by AZJIO
I wanted to suggest DesktopMouseX() as an alternative to
WindowMouseX(), but the author mentions SetCursorPos, so the recommendation is not appropriate.
Re: Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 2:04 am
by RASHAD
Are you sleepy or getting old ?
If MouseButton(#PB_MouseButton_Middle)
MouseLocate(ScreenWidth()/2, ScreenHeight()/2)
EndIf
Re: Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 2:14 am
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?????!!!!!!
Re: Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 9:17 am
by DarkDragon
Omg I've never seen more people talking their way around the main topic

. 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.
All these functions are for games.
Re: Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 10:22 am
by mk-soft
That's right

Re: Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 10:38 am
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

. 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?
Re: Cannot Move Mouse in Windows??
Posted: Sun Nov 17, 2024 7:30 pm
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
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.