Jump to content

Hide/Show Mouse


Recommended Posts

Hey - one last question lol for my program. How do you hide the mouse? I added this coding to my function but it doesnt seem to work:

func hideMouse()
$MyGUI = GuiCreate("",@DesktopWidth+9, @DesktopHeight+9, -9, -9, BitOR($WS_POPUP, $WS_DLGFRAME))
GuiSetBkColor(0x0)

GuiSetState()
WinSetOnTop($MyGUI, "", 1)

WinSetTrans($MyGUI, "", 1);almost transparent; opacity value of 0 doesn't hide mouse
GuiSetCursor(16)
While 1
    sleep(10)
    $mouse = GUIGetCursorInfo()
    If @error Then ContinueLoop

; Attempt to pass on mouse clicks just for fun (not required)
    If $mouse[2] Then;primary down
        winSetState($MyGui, "", @SW_HIDE)
        MouseClick("primary", $mouse[0], $mouse[1])
        winSetState($MyGui, "", @SW_SHOW)
    ElseIf $mouse[3] Then;right-click
        winSetState($MyGui, "", @SW_HIDE)
        MouseClick("secondary", $mouse[0], $mouse[1])
        winSetState($MyGui, "", @SW_SHOW)
    EndIf
Wend    
EndFunc

I also need a function to show the mouse again so help on that would also be great.

Thanks

Edited by Jamie2312
Link to comment
Share on other sites

  • Moderators

Hey - one last question lol for my program. How do you hide the mouse? I added this coding to my function but it doesnt seem to work:

func hideMouse()
$MyGUI = GuiCreate("",@DesktopWidth+9, @DesktopHeight+9, -9, -9, BitOR($WS_POPUP, $WS_DLGFRAME))
GuiSetBkColor(0x0)

GuiSetState()
WinSetOnTop($MyGUI, "", 1)

WinSetTrans($MyGUI, "", 1);almost transparent; opacity value of 0 doesn't hide mouse
GuiSetCursor(16)
While 1
    sleep(10)
    $mouse = GUIGetCursorInfo()
    If @error Then ContinueLoop

; Attempt to pass on mouse clicks just for fun (not required)
    If $mouse[2] Then;primary down
        winSetState($MyGui, "", @SW_HIDE)
        MouseClick("primary", $mouse[0], $mouse[1])
        winSetState($MyGui, "", @SW_SHOW)
    ElseIf $mouse[3] Then;right-click
        winSetState($MyGui, "", @SW_HIDE)
        MouseClick("secondary", $mouse[0], $mouse[1])
        winSetState($MyGui, "", @SW_SHOW)
    EndIf
Wend    
EndFunc

I also need a function to show the mouse again so help on that would also be great.

Thanks

I don't understand what your really trying to do. Do you want to perform clicks, but just not show the mouse? You might take a look at ClickInControl by Larry if that's the case.

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

Yeh thanks

I am trying to hide the mouse pointer from the user. Is this possible in autoit, as Clickincontrol clicks specific icons when all i want to do is hide the pointer. Could you please post the code if poss.

Thanks

Link to comment
Share on other sites

  • Moderators

I am trying to hide the mouse pointer from the user. Is this possible in autoit, as Clickincontrol clicks specific icons when all i want to do is hide the pointer. Could you please post the code if poss.

Thanks

This should hide it over your GUI:
_SetCursorState(0)

Func _SetCursorState($bValue = 1)
    DllCall('User32.dll', 'int', 'ShowCursor', 'int', $bValue)
EndFunc

Edit:

1 (True) will make it show / 0 (False) will hide it

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

  • Moderators

Is there anyway you can make the cursor disappear inside and outside your GUI? (in windows xp)

Thanks

Why don't you explain what your trying to do, maybe there is an easier way of it.

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

Sorry... I am trying to make the cursor disappear from the user on Windows. An example of this is in full screen mode on Windows media player. Is is possible to replicate this for multiple GUI's? (ie. windows, any other programs running)

Thanks - I appreciate your persistant help Smoke N

Link to comment
Share on other sites

Sorry... I am trying to make the cursor disappear from the user on Windows. An example of this is in full screen mode on Windows media player. Is is possible to replicate this for multiple GUI's? (ie. windows, any other programs running)

Thanks - I appreciate your persistant help Smoke N

I've been trying to find a solution to this for months (ok ... not solid).

I too would like to know how to create an invisible mouse pointer for use in applications other than the typical GUI. I've toyed with the idea of creating a blank mouse icon (since making it invisible doesn't seem to work) and finding a way to have windows use the empty graphic, but have not been able to get anything to work. Any of the professional autoiters out there up to the challenge? Cause I'm stumped!

Edited by Chris2137378
Link to comment
Share on other sites

if smoke would fix the dll call.... this should work

#include <GuiConstants.au3>

$win = GUICreate("MY GUI")
GUISetState()

;Run("notepad.exe")
WinWaitActive("")
$handle = WinGetHandle("")
$int = 1

While 1
    
    If WinActive($handle) Then
        
        $mouse = MouseGetPos()
        $window = WinGetPos($handle)
        
        If $int = 1 And $mouse[0] > $window[0] And $mouse[0] < ($window[0]+$window[2]) And $mouse[1] > $window[1] And $mouse[1] < $window[1] + $window[3] Then
             MsgBox(0,0,0)
             DllCall('User32.dll', 'int', 'ShowCursor', 'int', 0)
             $int = 0
        Else
              DllCall('User32.dll', 'int', 'ShowCursor', 'int', 1)
              $int = 1
        EndIf
    EndIf

    Sleep(100)

WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

if smoke would fix the dll call.... this should work

8)

I'm not smoke, but this works :) :

#include <GuiConstants.au3>
#include <Array.au3>

$win = GUICreate("MY GUI")
GUISetState()

;Run("notepad.exe")
WinWaitActive("")
$handle = WinGetHandle("")

$result = _ArrayCreate(0)

While 1
    
    If WinActive($handle) Then
        
        $mouse = MouseGetPos()
        $window = WinGetPos($handle)
        
        If $mouse[0] > $window[0] And $mouse[0] < ($window[0] + $window[2]) And $mouse[1] > $window[1] And $mouse[1] < $window[1] + $window[3] Then
            If $result[0] = 0 Then
                $result = DllCall('User32.dll', 'int', 'ShowCursor', 'int', False)
            EndIf
        Else
            If $result[0] = -1 Then
                $result = DllCall('User32.dll', 'int', 'ShowCursor', 'int', True)
            EndIf
        EndIf
    EndIf
    
    Sleep(100)
    
WEnd
Link to comment
Share on other sites

its not working with the notepad

#include <GuiConstants.au3>
#include <Array.au3>

;$win = GUICreate("MY GUI")
;GUISetState()

Run("notepad.exe")
WinWaitActive("")
$handle = WinGetHandle("")

$result = _ArrayCreate(0)

While 1
   
    If WinActive($handle) Then
       
        $mouse = MouseGetPos()
        $window = WinGetPos($handle)
       
        If $mouse[0] > $window[0] And $mouse[0] < ($window[0] + $window[2]) And $mouse[1] > $window[1] And $mouse[1] < $window[1] + $window[3] Then
            
            If $result[0] = 0 Then
                MsgBox(0,0,0)
                $result = DllCall('User32.dll', 'int', 'ShowCursor', 'int', False)
            EndIf
        Else
            If $result[0] = -1 Then
                $result = DllCall('User32.dll', 'int', 'ShowCursor', 'int', True)
            EndIf
        EndIf
    EndIf
   
    Sleep(100)
   
WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

if smoke would fix the dll call.... this should work

I only used what it offered here: http://msdn.microsoft.com/library/default....fshowcursor.asp

And considering he was so new, I used 1 and 0 instead of True and False not knowing if he had Beta yet. (Chalk that up to lazy for not wanting to write yet again.... "You need Beta for this"

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