Jump to content
Sign in to follow this  

Mousetrap problem?

Recommended Posts


I am having a small problem that is bugging me, I need to either create a msgbox that cant be moved or get mousetrap working better.

The problem I have is when my GUI appears if the mouse moves off the window the program I am running at the same time makes the mouse cursor disappear and it is near impossible to find it again, so by limiting the mouse movement to my GUI that cures that problem, then if a msgbox pops up I keep it within the GUI so you can react to it without loosing the mouse cursor. The other problem this gets me over is if you click outside the GUI window the other program jumps to the front and you lose the GUI and everything else behind, nothing I have tried can make the GUI stay on top of the other program once the other program takes over it's not easy to get back to my GUI.

The problem I have with it is when you have a msgbox come up if you grab the box and move it about mousetrap allows full movement, when you put the msgbox down you can still move the mouse all over, when you hit OK mousetrap kicks back in??

I have added some code to explain better..



#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 365, 303, 457, 300)
$Button1 = GUICtrlCreateButton("Save", 104, 192, 153, 41, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("Press the Save button and follow the instructions!", 8, 40, 352, 24)
GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif")
#EndRegion ### END Koda GUI section ###

    Local $coords[4]

While 1
    $coords = WinGetPos($Form1)
    _MouseTrap($coords[0], $coords[1]+6, $coords[0] + $coords[2], $coords[1] + $coords[3]) ;added the +6 to limit the mouse reaching the very top of the box

    $msg_1 = GUIGetMsg()


                    Case $msg_1 = $Button1
                        MsgBox(262144, "Save Pressed", "1. Mouse movement is still only within the box behind (FORM 1)"&@CRLF&"2. Now grab this message box and you can move it anywhere!"&@CRLF&"3. Once you move this box put it down and you can still move the mouse anywhere"&@CRLF&"4. When you press OK mousetrap works again???")

                    Case $msg_1 = $gui_event_close


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