Sign in to follow this  
Followers 0
Vadersapien

Help with Detecting Mouse Movement

4 posts in this topic

I made an app which auto-"hides" the everything on after 3 seconds by fading in an image of the background...however, I need to be able to set the alpha to 0 if the mouse moves (needs to happen whether image is fading in or not)...

Here is my current code:

#include <GDIPlus.au3>
#Include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Timers.au3>

Func Fade()
    $i = 0
    While $i <= 255 And $Idle
        WinSetTrans($GUI, '', $i)
        $i += 1
        Sleep(1)
    WEnd
EndFunc


$GUI = GUICreate('', @DesktopWidth, @DesktopHeight,0, 0, $WS_POPUP, $WS_EX_TOPMOST, WinGetHandle(AutoItWinGetTitle()))
GUISetState()

WinSetTrans($GUI, '', 0)

_GDIPlus_StartUp()
$Wallpaper = _GDIPlus_ImageLoadFromFile(RegRead('HKEY_CURRENT_USER\Control Panel\Desktop', 'Wallpaper'))

$DisplayedImage = _GDIPlus_GraphicsCreateFromHWND($GUI)
_GDIPlus_GraphicsDrawImage($DisplayedImage, $Wallpaper, 0, 0)

While 1
    $msg = GUIGetMsg()
    
    If _Timer_GetIdleTime() >= 3000 Then
        $Idle = true
        Fade()
        Do 
        Until Not $Idle
    EndIf
    
    If _Timer_GetIdleTime() < 3000 Then
        $Idle = false
        WinSetTrans($GUI, '', 0)
    EndIf
    
    If $msg = $GUI_EVENT_CLOSE Then
        GUIDelete()
        _GDIPlus_GraphicsDispose($DisplayedImage)
        _GDIPlus_ImageDispose($Wallpaper)
        _GDIPlus_ShutDown()
        Exit
    EndIf
WEnd

Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.

Share this post


Link to post
Share on other sites



#include <GuiConstantsEx.au3>
#include <Icons.au3>
#Include <WindowsConstants.au3>


$GUI = GUICreate('', @DesktopWidth, @DesktopHeight,0, 0, $WS_POPUP, $WS_EX_TOPMOST, WinGetHandle(AutoItWinGetTitle()))
$Pic = GUICtrlCreatePic("", 0, 0, @DesktopWidth, @DesktopHeight)
_SetImage(GUICtrlGetHandle(-1), RegRead('HKEY_CURRENT_USER\Control Panel\Desktop', 'Wallpaper'))
WinSetTrans($GUI, '', 0)
GUISetState()

$i = 0
While 1
    If $i < 256 Then
        WinSetTrans($GUI, '', $i)
        $i += 1
    Else
        ExitLoop
    EndIf
    
    Switch GUIGetMsg()
        Case $GUI_EVENT_MOUSEMOVE
            WinSetTrans($GUI, "", 0)
            ContinueCase
        
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
    
    Sleep(10)
WEnd

GUIDelete()
Exit

Yashied's Icons.au3

Hope it's what you want.

Share this post


Link to post
Share on other sites

I made an app which auto-"hides" the everything on after 3 seconds by fading in an image of the background...however, I need to be able to set the alpha to 0 if the mouse moves (needs to happen whether image is fading in or not)...

Here is my current code:

#include <GDIPlus.au3>
#Include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Timers.au3>

Func Fade()
 $i = 0
 While $i <= 255 And $Idle
 WinSetTrans($GUI, '', $i)
 $i += 1
        Sleep(1)
 WEnd
EndFunc


$GUI = GUICreate('', @DesktopWidth, @DesktopHeight,0, 0, $WS_POPUP, $WS_EX_TOPMOST, WinGetHandle(AutoItWinGetTitle()))
GUISetState()

WinSetTrans($GUI, '', 0)

_GDIPlus_StartUp()
$Wallpaper = _GDIPlus_ImageLoadFromFile(RegRead('HKEY_CURRENT_USER\Control Panel\Desktop', 'Wallpaper'))

$DisplayedImage = _GDIPlus_GraphicsCreateFromHWND($GUI)
_GDIPlus_GraphicsDrawImage($DisplayedImage, $Wallpaper, 0, 0)

While 1
    $msg = GUIGetMsg()
    
    If _Timer_GetIdleTime() >= 3000 Then
 $Idle = true
 Fade()
        Do 
 Until Not $Idle
 EndIf
    
    If _Timer_GetIdleTime() < 3000 Then
 $Idle = false
        WinSetTrans($GUI, '', 0)
    EndIf
    
 If $msg = $GUI_EVENT_CLOSE Then
        GUIDelete()
 _GDIPlus_GraphicsDispose($DisplayedImage)
 _GDIPlus_ImageDispose($Wallpaper)
 _GDIPlus_ShutDown()
 Exit
 EndIf
WEnd

And another example.

#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Timers.au3>
#include <Misc.au3>

Local $i = 0

$GUI = GUICreate('', @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST, WinGetHandle(AutoItWinGetTitle()))
WinSetTrans($GUI, '', 0)
GUISetState()

_GDIPlus_Startup()
$Wallpaper = _GDIPlus_ImageLoadFromFile("C:\Program Files\AutoIt3\Examples\GUI\logo4.gif") ;RegRead('HKEY_CURRENT_USER\Control Panel\Desktop', 'Wallpaper'))

$DisplayedImage = _GDIPlus_GraphicsCreateFromHWND($GUI)


While 1
    $msg = GUIGetMsg()
    Select
        Case _Timer_GetIdleTime() >= 3000
            $i += 1
            WinActivate($GUI, "")
            _GDIPlus_GraphicsDrawImageRectRect($DisplayedImage, $Wallpaper, 0, 0, 169, 68, 0, 0, @DesktopWidth, @DesktopHeight / 2)
            _GDIPlus_GraphicsDrawImageRectRect($DisplayedImage, $Wallpaper, 0, 0, 169, 68, 0, @DesktopHeight / 2, @DesktopWidth, @DesktopHeight / 2)
            While 1
                $msg = GUIGetMsg()
                Select
                    Case $i < 256 And $msg <> $GUI_EVENT_MOUSEMOVE
                        WinSetTrans($GUI, '', $i)
                        $i += 1
                        ContinueLoop
                    Case $msg = $GUI_EVENT_MOUSEMOVE
                        $i = 0
                        WinSetTrans("", "", 0)
                        ExitLoop
                EndSelect
            WEnd
        Case $msg = $GUI_EVENT_CLOSE Or _IsPressed("1B") ; Esc Key
            _GDIPlus_GraphicsDispose($DisplayedImage)
            _GDIPlus_ImageDispose($Wallpaper)
            _GDIPlus_Shutdown()
            ExitLoop
    EndSelect
WEnd

Share this post


Link to post
Share on other sites

Got it working perfect...I played around with Authenticity's example...it worked much better in the end...


Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.

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