Jump to content

Block Mouse Input


Recommended Posts

I am making a program where it is necesary that the mouse not be moved while it is running (data entry). But i need to have the keyboard so the person can Exit the program if needed and dont have to sit through the whole thing if its just a test run or somthing. So therefor BlockInput(1) wont work. IS there anyway where i can just block the input of the mouse and not of the keyboard. The mouse still needs to move so just locking it in the corner isnt going to work.

Link to comment
Share on other sites

Do you have GUIOnEventMode? If so, you can set events for the mouse clicks and have them do nothing.

Does the mouse really need to move and not click? Or can it just be stuck in a certain spot. If you're ok with just sticking it somewhere and making it not move, _MouseTrap() is a good function.

Link to comment
Share on other sites

  • Moderators

Green already has this, just thought I'd show the example.

_MouseTrap(0, 0, 0, 0)

Func _MouseTrap($i_left = 0, $i_top = 0, $i_right = 0, $i_bottom = 0)
    Local $av_ret
    If @NumParams == 0 Then
        $av_ret = DllCall("user32.dll", "int", "ClipCursor", "int", 0)
    Else
        If @NumParams == 2 Then
            $i_right = $i_left + 1
            $i_bottom = $i_top + 1
        EndIf
        Local $Rect = DllStructCreate("int;int;int;int")
        If @error Then Return 0
        DllStructSetData($Rect, 1, $i_left)
        DllStructSetData($Rect, 2, $i_top)
        DllStructSetData($Rect, 3, $i_right)
        DllStructSetData($Rect, 4, $i_bottom)
        $av_ret = DllCall("user32.dll", "int", "ClipCursor", "ptr", DllStructGetPtr($Rect))
;       DllStructDelete($Rect)
    EndIf
    Return $av_ret[0]
EndFunc
Edited by SmOke_N

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.

Link to comment
Share on other sites

I told you that that mousetrap function wouldnt move. THe mouse on the screen still has to move and click it just cant be moved by the user because it screws up the data entry. Im just trying to make sure the user doesnt move it...

Do you have GUIOnEventMode? If so, you can set events for the mouse clicks and have them do nothing.

Does the mouse really need to move and not click? Or can it just be stuck in a certain spot. If you're ok with just sticking it somewhere and making it not move, _MouseTrap() is a good function.

I dont undertstand what your saying im relatively new to autoit as it is.

Why did they put in a command to block bothj mouse and keyboard and not one for just mouse and just keyboard... hmmm oh well

Link to comment
Share on other sites

  • Moderators

Use the _MouseTrap() and use ControlClick() then.

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.

Link to comment
Share on other sites

When you use block input, it keeps the keyboard and mouse from working at all. If you use mouse trap, you only block the mouse movement. What I do not understand is why you need toe mouse to move, but not by the user. I have used blockinput to keep users from doing things, but had the mouse coordinates changed to click on a box.

How long does the script need to run?

Link to comment
Share on other sites

The script runs for about 2 minutes to fill a page. Basically theres its a price book and my script puts the dollar sign next to the price. The rows and collumns are evenly spaced so that doesnt matter its just if hte user moves the mouse from its path then it gets all messed up. So the _MouseTrap will work meaning it wont keep the mouse from moving at all but it will make it so the user cannot input? If so is there a help for or somthing for how to use the _MouseTrap command?

Link to comment
Share on other sites

  • Moderators

And Tab doesn't work to move from one input box to another? I mean, you want to make it so 'they' can't use the Mouse, but you want total control... even if that were possible, and someone knew how to do it, I doubt seriously they would post it in an open forum.

Edit:

The more I think about this... Why don't you just use _MouseTrap() to stay within the application itself? Or use ControlClick() as I've previously stated to do your clicking?

Edited by SmOke_N

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.

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...