Jump to content

Mouse Trap


Recommended Posts

Hey everyone -

Im essentially working on an Internet Nanny program except instead of just watching the sites that are visited, with this program if you stray away from a certain website it requires a password. I was asked to make this for a previous employer after I had to wipe the HDD and reinstall windows because of porn and viruses.

I have the following section of code that essentially traps the mouse within the bounds of the Internet Explorer window (I found it on the forum somewhere, but don't remember who posted it) but it only works 1 out of every 5 times of the program starting. I was wondering if someone could provide insight as to what I was doing wrong.

All help will be greatly appreciated.

$size = WinGetPos("Internet Explorer")
_CursorClip($size[0], $size[1], $size[0] + $size[2], $size[1] + $size[3]) ;obviously used to call the function

Func _CursorRestore()
    DllCall("user32.dll", "int", "ClipCursor", "int", 0)
EndFunc  ;==>_CursorRestore

Func _CursorClip($i_x, $i_y, $i_width, $i_height)
    Local $Rect = "int;int;int;int", $left = 1, $top = 2, $right = 3, $bottom = 4, $r
    $r = DllStructCreate($Rect)
    If @error Then Return -1
    DllStructSetData($r, $left, $i_x)
    DllStructSetData($r, $top, $i_y)
    DllStructSetData($r, $right, $i_width)
    DllStructSetData($r, $bottom, $i_height)
    DllCall("user32.dll", "int", "ClipCursor", "ptr", DllStructGetPtr($r))
EndFunc  ;==>_CursorClip

If there is any easier way / better way of doing this please let me know. Also out of curiosity I was wondering if there was a way to make it so the Internet Explorer window couldn't be moved from the position that it was currently in when the WinGetPos () command was called.

Again thank you for your time and any help provided.

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Link to comment
Share on other sites

#Include <Misc.au3>
$size = WinGetPos("Internet Explorer")
_MouseTrap($size[0], $size[1], $size[0] + $size[2], $size[1] + $size[3])
While 1
    Sleep(1000) ;Some sort of loop is required... If the script closes, the effects of _MouseTrap() are lost.
WEnd

Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

I feel like an idiot. I didn't know about that function. Thank you lol

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...