Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How does Cheat Engine free the mouse cursor?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
MulleDK19
Cheater
Reputation: 0

Joined: 12 Aug 2012
Posts: 25
Location: Denmark

PostPosted: Sat Oct 21, 2017 1:29 pm    Post subject: How does Cheat Engine free the mouse cursor? Reply with quote

I'm working with a bad PC port, which somehow locks the cursor to the center of the screen when the game has focus.

When CE hits a breakpoint, the cursor lock is on, so I can't use the mouse in any window, EXCEPT CE. Whenever CE takes focus, the lock is gone, until it loses focus again.

How does CE achieve this? I'd like to not have to run the game again to use other programs.
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Sat Oct 21, 2017 4:18 pm    Post subject: Reply with quote

MulleDK19 wrote:
How does CE achieve this? I'd like to not have to run the game again to use other programs.

it should not affect the other programs

MulleDK19 wrote:
When CE hits a breakpoint, the cursor lock is on, so I can't use the mouse in any window, EXCEPT CE. Whenever CE takes focus, the lock is gone, until it loses focus again.


its a breakpoint as the name says, it stop the execution of a process when a condition is hit.

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
MulleDK19
Cheater
Reputation: 0

Joined: 12 Aug 2012
Posts: 25
Location: Denmark

PostPosted: Sat Oct 21, 2017 4:36 pm    Post subject: Reply with quote

OldCheatEngineUser wrote:
MulleDK19 wrote:
How does CE achieve this? I'd like to not have to run the game again to use other programs.

it should not affect the other programs

MulleDK19 wrote:
When CE hits a breakpoint, the cursor lock is on, so I can't use the mouse in any window, EXCEPT CE. Whenever CE takes focus, the lock is gone, until it loses focus again.


its a breakpoint as the name says, it stop the execution of a process when a condition is hit.


You're not making any sense, so I'm assuming you've misunderstood.

The problem is that the game locks the cursor to the center of the screen when the game has focus. When CE hits a breakpoint, the game cannot release the lock when alt+tabbing to another window, so the cursor is locked to the screen until I run the process again, so I can't move the cursor while the game is in a break state.
IMGUR . com / I4mpqsu.gifv

EXCEPT when CE has focus. CE somehow removes the cursor lock when it gains focus, and reinstates it when it loses focus. So I can still work in CE when the game is paused, but not any other window like IDA, VS, etc.

So either there's some voodoo magic going on, or CE knows the type of cursor lock the game is using and deliberately disables it while it has focus.

I'd like to know what CE does to unlock the cursor, so I can write a program to unlock the cursor for all windows not just CE's.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Sat Oct 21, 2017 5:29 pm    Post subject: Reply with quote

CE is 99% programming and 1% voodoo magic, so i have to guess it's that part
CE doesn't really do anything to the mouse cursor.

but what you describe is that the game constantly moves the mousecursor to the center of the screen (easy way to detect mouse movement)
when the game gets interrupted by a breakpoint that code doesn't run, so the mouse is released

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
MulleDK19
Cheater
Reputation: 0

Joined: 12 Aug 2012
Posts: 25
Location: Denmark

PostPosted: Sat Oct 21, 2017 6:12 pm    Post subject: Reply with quote

Dark Byte wrote:
when the game gets interrupted by a breakpoint that code doesn't run, so the mouse is released


You'd think. The problem is, the cursor is still being set to the center of the screen when it hits a breakpoint. The lock only stops when CE receives focus.

Breakpoint, cursor locked to screen.
focus CE, cursor unlocked.
unfocus CE, cursor locked.
focus CE, cursor unlocked.
unfocus CE, cursor locked.
focus VS, cursor locked.
focus IDA, cursor locked.
focus CE, cursor unlocked.
resume execution, cursor remains unlocked until game receives focus.
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Sat Oct 21, 2017 7:10 pm    Post subject: Reply with quote

i just ran a game that disable windows functions and i used a breakpoint just for experimenting purpose.

if i didnt misunderstood, then a similar thing happened to me.
maybe because the software disable windows functions?

EDIT + NOTE:
the game also force full screen mode, so yeah it could be a reason too.
one more thing is the process is paused when you are on your desktop.

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Sat Oct 21, 2017 9:59 pm    Post subject: Reply with quote

If you are looking for API that would be causing the cursor locking:
- ClipCursor
- SetCursorPos

If the mouse is being hidden:
- ShowCursor

During debugging times you could hook these API and prevent them from being called properly if they are what is being used to lock the cursor as you are describing. Various rendering engines also have their own cursor handling stuff within them, such as the older versions of Direct3D up to D3D9. (OGL and so on each have their own as well.)

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
MulleDK19
Cheater
Reputation: 0

Joined: 12 Aug 2012
Posts: 25
Location: Denmark

PostPosted: Mon Oct 23, 2017 7:52 pm    Post subject: Reply with quote

atom0s wrote:
If you are looking for API that would be causing the cursor locking:
- ClipCursor
- SetCursorPos

If the mouse is being hidden:
- ShowCursor

During debugging times you could hook these API and prevent them from being called properly if they are what is being used to lock the cursor as you are describing. Various rendering engines also have their own cursor handling stuff within them, such as the older versions of Direct3D up to D3D9. (OGL and so on each have their own as well.)


I know what the game does. The question is how CE prevents the cursor from being set.


I did some experimentation. Calling SetCursorPos in a custom app in a loop, sets the mouse, but when CE gains focus, the mouse can no longer be moved by the app. CE is doing something that prevents SetCursorPos on the OS level when it has focus.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Mon Oct 23, 2017 10:28 pm    Post subject: Reply with quote

MulleDK19 wrote:
I did some experimentation. Calling SetCursorPos in a custom app in a loop, sets the mouse, but when CE gains focus, the mouse can no longer be moved by the app. CE is doing something that prevents SetCursorPos on the OS level when it has focus.

Could not replicate:
Code:
int main(int argc, char** argv)
{
    std::cout << "Freezing cursor position.\nHold Ctrl to quit." << std::endl;

    POINT p;
    if (!GetCursorPos(&p))
        return 1;

    while (!(GetAsyncKeyState(0x11) >> 15))
    {
        SetCursorPos(p.x, p.y);
        Sleep(2000);
    }

    return 0;
}

You could look through CE's source if you want to, but if the person who wrote the code couldn't think of anything, you probably won't find anything.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
MulleDK19
Cheater
Reputation: 0

Joined: 12 Aug 2012
Posts: 25
Location: Denmark

PostPosted: Tue Oct 24, 2017 12:19 am    Post subject: Reply with quote

ParkourPenguin wrote:
MulleDK19 wrote:
I did some experimentation. Calling SetCursorPos in a custom app in a loop, sets the mouse, but when CE gains focus, the mouse can no longer be moved by the app. CE is doing something that prevents SetCursorPos on the OS level when it has focus.

Could not replicate:
Code:
int main(int argc, char** argv)
{
    std::cout << "Freezing cursor position.\nHold Ctrl to quit." << std::endl;

    POINT p;
    if (!GetCursorPos(&p))
        return 1;

    while (!(GetAsyncKeyState(0x11) >> 15))
    {
        SetCursorPos(p.x, p.y);
        Sleep(2000);
    }

    return 0;
}

You could look through CE's source if you want to, but if the person who wrote the code couldn't think of anything, you probably won't find anything.


I just used the exact code you posted (well not exact, made it set to 10,10, and 200ms). Same thing, SetCursorPos does nothing when CE has focus. v6.7

https://i.imgur.com/GWIT76t.gifv
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Tue Oct 24, 2017 8:36 am    Post subject: Reply with quote

I do get that behaviour when CE is run as administrator and the process calling SetCursorPos is not. Try running the other software as administrator.
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
MulleDK19
Cheater
Reputation: 0

Joined: 12 Aug 2012
Posts: 25
Location: Denmark

PostPosted: Tue Oct 24, 2017 3:56 pm    Post subject: Reply with quote

ParkourPenguin wrote:
I do get that behaviour when CE is run as administrator and the process calling SetCursorPos is not. Try running the other software as administrator.


Well, mystery solved; thanks.

Well that sucks. Now I either have to patch SetCursorPos every time the game hits a breakpoint, or run all my programs as admin.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites