Sign in to follow this  
Followers 0
Skrip

Move OUT of area.

6 posts in this topic

#1 ·  Posted (edited)

How do you set an area for the mouse to not be allowed to go in?

Like over a certain part of a window. How do you do that?

Kinda like the opposite of _MouseTrap()

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites



How do you set an area for the mouse to not be allowed to go in?

Like over a certain part of a window. How do you do that?

Maybe Modify _MouseTrap?????? Im not sure.......

Share this post


Link to post
Share on other sites

I thought of that. But I have no idea how the DLL works. I just tried messing with it, and it is not working so well.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Nope, you can't do it with the dll unless there is a specific function in the WINAPI that does it. In the case of _MouseTrap(), there is just that, a specific WINAPI function that traps a mouse in a certain location. I don't know of a function that prevents a cursor from going to a certain location, but I made a function myself that repels a cursor. The function must be called constantly as only prevents the cursor from going into the specific area when it is run.

Global $GUI = GUICreate("Can't Touch This",200,100,200,200)
GUISetState()
AdlibEnable("CallMouseRepel",10)

While 1
     sleep(1000)
WEnd


Func CallMouseRepel()
    $coords = WinGetPos($GUI)
    _MouseRepel($coords[0], $coords[1], $coords[0] + $coords[2], $coords[1] + $coords[3])
EndFunc

;===============================================================================
;
; Description:    _MouseRepel
; Parameter(s):   $i_left - Left coord
;                 $i_top - Top coord
;                 $i_right - Right coord
;                 $i_bottom - Bottom coord
; User CallTip:   _MouseRepel([$i_left = 0[, $i_top = 0[, $i_right = 0[, $i_bottom = 0]]]]) Repel the Mouse Cursor to specified coords.
; Author(s):      The Kandie Man
; Note(s):        This function must be called constantly to prevent the mouse cursor from entering the area.
;                 It is therefore recommended that you call this function from another function that is called by AdlibEnable every 1 to 50ms.
;
;===============================================================================

Func _MouseRepel($i_left = 0, $i_top = 0, $i_right = 0, $i_bottom = 0)
    Local $a_MousePos = MouseGetPos()
    Local $i_XCordinate = -1, $i_YCordinate = -1
    If $a_MousePos[0] >= $i_left And $a_MousePos[0] <= $i_right Then
        If ($a_MousePos[0] - $i_left) < ($i_right - $a_MousePos[0]) Then
            $i_XCordinate = $i_left - 1
        Else
            $i_XCordinate = $i_right + 1
        EndIf
    EndIf
    If $a_MousePos[1] >= $i_top And $a_MousePos[1] <= $i_bottom  Then
        If ($a_MousePos[1] - $i_top) < ($i_bottom - $a_MousePos[1]) Then
            $i_YCordinate = $i_top - 1
        Else
            $i_YCordinate = $i_bottom + 1
        EndIf
    EndIf
    If $i_XCordinate <> -1 And $i_YCordinate <> -1 Then
        If Abs($i_XCordinate - $a_MousePos[0]) > Abs($i_YCordinate - $a_MousePos[1]) Then
            MouseMove($a_MousePos[0],$i_YCordinate,1)
        Elseif Abs($i_XCordinate - $a_MousePos[0]) < Abs($i_YCordinate - $a_MousePos[1]) Then
            MouseMove($i_XCordinate,$a_MousePos[1],1)
        Else
            MouseMove($i_XCordinate,$i_YCordinate,1)
        EndIf
    EndIf
EndFunc

I hope this is what you are looking for.

- The Kandie Man ;-)

EDIT: Fixed a minor error and cleaned up the code.

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites

Thank you! It will work great! The only thing I can think of that would be better, is the opposite of the mouse trap. But this will work great. Thanks.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

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