Sign in to follow this  
Followers 0
photonbuddy

_MouseTrap() and message boxes

5 posts in this topic

#1 ·  Posted (edited)

Hi All,

I am writing a script which uses _MouseTrap() to confine the mouse to a set region, and then trap ALT-TAB and the arrow keys using SetHotKey(). It all works very well, even pressing CTRL-ALT-DEL keeps the mouse confined where I want it.

Currently, I have the window which the mouse is locked to opening in the center of the screen, which is good, because it gives access to all the buttons if you press CTRL-ALT-DEL, but if you run the task manager, you can't do anything because the keys have been trapped.

The problem is, I am using a message box to tell the user they have entered an incorrect password. Problem is, if they click the title of the message box, they can then drag the mouse anywhere on the screen. This would not be a problem if the mouse was moved back into the trap zone when the mouse button is released, but it doesn't. The mouse becomes free. Once you click 'Ok' in the message box, the mouse becomes trapped again.

Is there a simple way around this, or is the only way to make a custom message box with no draggable title?

Edited by photonbuddy

Share this post


Link to post
Share on other sites



Hi All,

I am writing a script which uses _MouseTrap() to confine the mouse to a set region, and then trap ALT-TAB and the arrow keys using SetHotKey(). It all works very well, even pressing CTRL-ALT-DEL keeps the mouse confined where I want it.

Currently, I have the window which the mouse is locked to opening in the center of the screen, which is good, because it gives access to all the buttons if you press CTRL-ALT-DEL, but if you run the task manager, you can't do anything because the keys have been trapped.

The problem is, I am using a message box to tell the user they have entered an incorrect password. Problem is, if they click the title of the message box, they can then drag the mouse anywhere on the screen. This would not be a problem if the mouse was moved back into the trap zone when the mouse button is released, but it doesn't. The mouse becomes free. Once you click 'Ok' in the message box, the mouse becomes trapped again.

Is there a simple way around this, or is the only way to make a custom message box with no draggable title?

You could use Opt('MouseCoordMode', 2) and use only the client area of the MsgBox() if you are using it in the traditional sense (MsgBox() that is) you would have to know the width/height before hand, else if your using it in the non traditional /AutoIt3ExecuteScript type, you could use ControlGetPos() with Opt('MouseCoordMode', 2)... both options you would still use _MouseTrap().

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

The MsgBox is a blocking function. You can make a Gui or run a MsgBox from another script which prevents your script from being blocked.

Edit:

As _MouseTrap() looks like a one off DllCall, then a Gui would seem the solution to use as a MsgBox in another script may still block the Windows API operation of _MouseTrap().

Edited by MHz

Share this post


Link to post
Share on other sites

I decided to make 2 changes to help get around the problem.

Firstly, I make a GUI for the message boxes I use in the program, and then I moved the main window towards the top of the screen, so that the mouse should never be able to reach a draggable message box displayed by the system.

Share this post


Link to post
Share on other sites

I decided to make 2 changes to help get around the problem.

Firstly, I make a GUI for the message boxes I use in the program, and then I moved the main window towards the top of the screen, so that the mouse should never be able to reach a draggable message box displayed by the system.

Or just make your GUI "$WS_EX_DLGMODALFRAME" with no title bar

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0