Sign in to follow this  
Followers 0
XiaolinDraconis

Tray Function

2 posts in this topic

#1 ·  Posted (edited)

Clicking th tray item should adjust the transparency setting by 20% each click, I don't understand why it's not.

#include <MsgBoxConstants.au3>
#include <TrayConstants.au3>

HotKeySet("^{SPACE}", "OnTop")

$Toggle = 0
$Trans = 204

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.
Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode.

Example()

Func Example()
    TrayCreateItem("Transparency")

    TrayCreateItem("+20%")
    TrayItemSetOnEvent(-1, "up")

    TrayCreateItem("-20%")
    TrayItemSetOnEvent(-1, "down")

    TrayCreateItem("About")
    TrayItemSetOnEvent(-1, "About")

    TrayCreateItem("") ; Create a separator line.

    TrayCreateItem("Exit")
    TrayItemSetOnEvent(-1, "ExitScript")

    TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "About") ; Display the About MsgBox when the tray icon is double clicked on with the primary mouse button.

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    While 1
        Sleep(100) ; An idle loop.
    WEnd
EndFunc   ;==>Example

Func up()
    If $Trans = 255 Then
        Sleep(1000)
    Else
        $Trans += 51
    EndIf
EndFunc   ;==>up

Func down()
    If $Trans = 0 Then
        Sleep(1000)
    Else
        $Trans -= 51
    EndIf
EndFunc   ;==>down

Func About()
    ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
    MsgBox($MB_SYSTEMMODAL, "", "Press CTRL+SPACE to toggle." & @CRLF & @CRLF & _
            "Version: " & @AutoItVersion & @CRLF & _
            "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.
EndFunc   ;==>About

Func ExitScript()
    Exit
EndFunc   ;==>ExitScript

Func OnTop()
    If $Toggle = 0 Then
        $Toggle = 1
        Set()
    Else
        $Toggle = 0
        Unset()
    EndIf
EndFunc   ;==>OnTop

Func Set()
    $WinTitle = WinGetTitle("[active]")
    WinSetOnTop($WinTitle, "", 1)
    WinSetTrans($WinTitle, "", $Trans)
EndFunc   ;==>Set

Func Unset()
    $WinTitle = WinGetTitle("[active]")
    WinSetOnTop($WinTitle, "", 0)
    WinSetTrans($WinTitle, "", 255)
EndFunc   ;==>Unset
Edited by XiaolinDraconis

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

So I was sitting here waiting on an answer when I noticed some typos in the OP. After editing them, and you can see it wasn't much, I made the same changes to the source and hit Go. Low and behold it works perfectly. Now to see if I can make a GUI slider from 0 - 100% that alters it instead of clicking repeatedly. :D

'?do=embed' frameborder='0' data-embedContent>>

Edited by XiaolinDraconis

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