Jump to content

How to disable just mouse input


zemen
 Share

Recommended Posts

  • Moderators

Hi all,

Is there a way to disable just mouse input instead of disable both mouse and keyboard using BlockInput command?

thnkz

You could trap the mouse in a pixel region with _MouseTrap()

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

Here's what I've done before. I thought of using Paulie's idea, but creating a GUI would be too noticeable. I thought of using a small splash window but when you click, it disables mousetrap.. for some reason.

Function: _BlockMouseMove() Requires: #include <Misc.au3>

Func _BlockMouseMove($iFlag)
    If $iFlag <> 0 Then
        If $iFlag <> 1 Then
            Return 1;Incorrect parameters
        EndIf
    EndIf
    $iPos=MouseGetPos()
    If $iFlag = 1 Then
        _MouseTrap($iPos[0],$iPos[1]); Enable
;~      SplashTextOn("","",1,1,$iPos[0],$iPos[1],1); Doesn't work
        Return
    Else
        _MouseTrap(); Disable
;~      SplashOff()
        Return
    EndIf
EndFuncoÝ÷ ØLZ^jëh×6#include <Misc.au3>


_BlockMouseMove(1); Enable
Sleep(2000); Do your stuff
_BlockMouseMove(0);Disable
Link to comment
Share on other sites

  • Moderators

and add a little window under the mouse that will steal the clicks :)

Good point, and I knew I had done something like this before with a gui as well, found it in an oooooold #include of mine (When Gary first introduced the function):
#include <misc.au3>
$hMBHwnd = _MouseBlock()
If @error Then Exit
Sleep(5000)
_MouseBlock($hMBHwnd)

Func _MouseBlock($hWnd = 0)
    If $hWnd Then
        _MouseTrap()
        Return GUIDelete($hWnd)
    EndIf
    Local $aMPOS = MouseGetPos()
    If IsArray($aMPOS) Then
        Local $hGUI = GUICreate("", 3, 20, $aMPOS[0], $aMPOS[1]-30)
        GUISetState(@SW_HIDE)
        Return _MouseTrap(MouseGetPos(0), MouseGetPos(1))
    EndIf
    Return SetError(1, 0, 0)
EndFuncoÝ÷ ØGb´k²Ì¨¹Ê.Ûkf{    bëºÚ"µÍ[ÈÓ[ÝÙPØÚÊ   ÌÍÚÛH
BRY ÌÍÚÛ[]
Ó[ÝÙU

H
ÈÕRQ[]J   ÌÍÚÛ
JBSØØ[    ÌÍØSTÔÈH[ÝÙQÙ]ÜÊ
BRYÐ^J ÌÍØSTÔÊH[BSØØ[   ÌÍÚÕRHHÕRPÜX]J    ][ÝÉ][ÝËËÌ    ÌÍØSTÔÖÌK ÌÍØSTÔÖÌWKLÌ
BBT]
ÕRTÙ]Ý]JÕ×ÒQJH
ÈÓ[ÝÙU
[ÝÙQÙ]ÜÊ
K[ÝÙQÙ]ÜÊJJJBQ[YT]Ù]ÜK
B[[
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

^Yours is not creating the GUI, for some reason, and you can still click... Here's an update of mine, but the little square there really bothers me:

Func _BlockMouseInput($iFlag)
    Local Const $WS_EX_TOOLWINDOW           = 0x00000080; This is to avoid including <GUicontants.au3>
    Local Const $WS_EX_TOPMOST              = 0x00000008; This is to avoid including <GUicontants.au3>
    Local Const $WS_EX_WINDOWEDGE           = 0x00000100; This is to avoid including <GUicontants.au3>
    Local $hGUI
    If $iFlag <> 0 Then
        If $iFlag <> 1 Then
            Return 1;Incorrect parameters
        EndIf
    EndIf
    $iPos=MouseGetPos()
    If $iFlag = 1 Then
        $hGUI=GUICreate("", 1, 1, $iPos[0],$iPos[1], -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST))
        GUISetState(@SW_SHOW)
        _MouseTrap($iPos[0],$iPos[1]); Enable
        Return
    Else
        _MouseTrap(); Disable
        GUIDelete($hGUI)
        Return
    EndIf
EndFuncoÝ÷ ØLZ^jëh×6#include <Misc.au3>

_BlockMouseInput(1)
Sleep(2000)
_BlockMouseInput(0)
Edited by Nahuel
Link to comment
Share on other sites

  • Moderators

^Yours is not creating the GUI

It's not?

I removed the @SW_HIDE and it was fine.

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

Func _BlockMouseInput($iFlag)
    Switch $iFlag
        Case 0  ;off
            GUIDelete(WinGetHandle("BlockMouseMove"))
            _MouseTrap()
        Case 1  ;on
            $iPos=MouseGetPos()
            GUICreate("BlockMouseMove", 1, 1, $iPos[0],$iPos[1], $WS_POPUP, $WS_EX_TOPMOST)
            GUISetState()
            _MouseTrap($iPos[0],$iPos[1])
    EndSwitch
EndFunc

"be smart, drink your wine"

Link to comment
Share on other sites

Ah, cool :)

______________

My last try, added transparency. I'm finally pleased ;)

Func _BlockMouseInput($iFlag=0,$Trans=1)
    ;Use $Trans=0 if you are not using Win2000/XP
    ; This is to avoid including <GUicontants.au3>
    Local Const $WS_EX_TOOLWINDOW           = 0x00000080
    Local Const $WS_EX_TOPMOST              = 0x00000008
    ;============================================
    Local $hGUI
    If $iFlag <> 0 Then
        If $iFlag <> 1 Then
            Return 1;Incorrect parameters
        EndIf
    EndIf
    $iPos=MouseGetPos()
    If $iFlag = 1 Then
        $hGUI=GUICreate("", 1, 1, $iPos[0],$iPos[1], -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST))
        GUISetState(@SW_SHOW)
        If $Trans Then
            WinSetTrans($hGUI,"",10)
        EndIf
        _MouseTrap($iPos[0],$iPos[1]); Enable
        Return
    Else
        _MouseTrap(); Disable
        GUIDelete($hGUI)
        Return
    EndIf
EndFunc

Examples:

If you are using Win2000/XP/Vista:

#include <Misc.au3>

_BlockMouseInput(1)
Sleep(2000)
_BlockMouseInput()

Else:

#include <Misc.au3>

_BlockMouseInput(1,0)
Sleep(2000)
_BlockMouseInput()
Edited by Nahuel
Link to comment
Share on other sites

m8s, that's all good but my prob is another...

the script clicks for me in a game window. I have to leave mouse click free to do that job... that's why I cant steal click in a small window under the mouse.

Trap the pointer in the game window is unuseless as well couse what I need is just to disable mouse input so my click and drag script works well even if my little dumb sister move the mouse :)

I could use BlockInput command if I find a way to leave hotkey press activated...

I just need ESC and PAUSE keys free to be pressed when BlockInput is on... any hint?

(tnkz a lot ;))

Edited by zemen
Link to comment
Share on other sites

  • Moderators

m8s, that's all good but my prob is another...

the script clicks for me in a game window. I have to leave mouse click free to do that job... that's why I cant steal click in a small window under the mouse.

Trap the pointer in the game window is unuseless as well couse what I need is just to disable mouse input so my click and drag script works well even if my little dumb sister move the mouse ;)

I could use BlockInput command if I find a way to leave hotkey press activated...

I just need ESC and PAUSE keys free to be pressed when BlockInput is on... any hint?

(tnkz a lot :P)

See what happens when people don't explain themselves properly? ... You get people to take time out of their schedules for nothing :) ...

So, let me get this right - You want to block the mouse, but not. (Unplug the mouse)

You want to block the all the keys, but two. (HotKeySet(), but that's only going to work on 64 of them the easy way)

There's my effort... GL

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

See what happens when people don't explain themselves properly? ... You get people to take time out of their schedules for nothing ;) ...

So, let me get this right - You want to block the mouse, but not. (Unplug the mouse)

You want to block the all the keys, but two. (HotKeySet(), but that's only going to work on 64 of them the easy way)

There's my effort... GL

I'm sorry m8... really! it's couse my bad eng....

So there is no way to get an exeption on BlockInput command and let activated 2 keys nor a command to get out just the mouse isnt it?

anyway, unplugging the mouse... a very nice idea, not a 'correct' solution... probably not working under a XP based PC with a ps2 mouse but...it' always a nice idea :P

thnkz 4 your time :)

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