Jump to content

System tray option create GUI


Recommended Posts

Hello!

I have this script:

#Include <OwnTab_Example.au3>

#Include <Constants.au3>

#NoTrayIcon

Opt("TrayMenuMode",1)

$getrep = TrayCreateItem("Report")

$otcset = TrayCreateItem("Settings")

TrayCreateItem("")

$about = TrayCreateItem("About...")

TraySetIcon("icon.ico")

TraySetState()

While 1

$msg = TrayGetMsg()

Select

Case $msg = 0

ContinueLoop

Case $msg = $getrep

_Report()

Case $msg = $otcset

_Setting()

Case $msg = $about

_AboutBox()

EndSelect

WEnd

Func _AboutBox()

MsgBox(0, "About", "Text....")

EndFunc

Func _Report()

MsgBox(0, "Report", "Function not implemented!")

EndFunc

Func _Setting()

MsgBox(0, "Settings...", "Function not implemented!")

EndFunc

I want to attach to function _Setting an GUI

from this post http://www.autoitscript.com/forum/index.php?showtopic=105422&st=0&p=745231&hl=funkey's%20own%20tab&fromsearch=1&#entry745231

Link to comment
Share on other sites

This is one way...

#include "OwnTab.au3"
#include <Constants.au3>
#NoTrayIcon
Opt("TrayMenuMode", 1)

#cs
Known Bugs:
        --> Bug mit $OwnTab_Style, da diese Variable zur Laufzeit abgefragt wird beim Verstecken und erneuten Anzeigen der Register.
        --> "Zittern" der alarmierten Register, wenn diese bereits angewählt wurden --> durch blinken mit der selben Farbe
#ce
Local $hGui = GUICreate("Funkey's OwnTab-UDF Example", 500, 350)
GUISetBkColor(0xbbbbbb)

$OwnTab_Style = Random(0, 1, 1) ;random style (only 2 styles available!!)

Local $aTabText[5] = ["Settings", "Register without icon", "Pic", "Status", "Tab in Tab"] ;Declare the regions for the OwnTab-control
Local $aTabIcons[5][2] = [["shell32.dll", 130],[""],["shell32.dll", 139],["shell32.dll", 90], ["shell32.dll", 43]]
Global $aCtrlTab = _OwnTab_Create($hGui, $aTabText, 10, 10, 480, 300, 30, 0xD5D5D5, 0xCFE0E7, 0xCFE0E7, $aTabIcons)

Local $aTabTip[5] = ["Tip Item 1", "Tip Item 2", "Tip Item 3", "Alarm-Register"]
_OwnTab_SetTip($aCtrlTab, $aTabTip) ;set the tooltips for the OwnTab-control

#Region Tab1
_OwnTab_Add($aCtrlTab) ;Start controls tab1
Global $Edit1 = GUICtrlCreateEdit("Edit in Tab1", 20, 55, 300, 50, 0)
Global $Button1 = GUICtrlCreateButton("Simulate an alarm", 20, 120, 300, 20)
Global $Box1 = GUICtrlCreateCheckbox("Switch on hover  -  set time -->", 20, 180)
GUICtrlSetBkColor(-1, 0xCFE0E7)
Global $Input1 = GUICtrlCreateInput("1", 200, 180, 50, 20)
GUICtrlCreateUpdown($Input1)
GUICtrlSetLimit(-1, 15, 1)
#EndRegion Tab1

#Region Tab2
_OwnTab_Add($aCtrlTab) ;Start controls tab2
Global $Edit2 = GUICtrlCreateEdit("Edit in Tab2", 20, 150, 300, 50, 0)
Global $Label2 = GUICtrlCreateLabel("Label in Tab2", 20, 220, 300, 20, 0x201)
GUICtrlSetBkColor(-1, -2) ;$GUI_BKCOLOR_TRANSPARENT
#EndRegion Tab2

#Region Tab3
_OwnTab_Add($aCtrlTab) ;Start controls tab3
Global $Labe3 = GUICtrlCreateLabel("If you see this label, you can change the picture-path in scriptline " &@ScriptLineNumber + 1 &  "!!", 40, 150, 400, 30, 0x201)
Global $Edit3 = GUICtrlCreatePic(@DocumentsCommonDir & '\Eigene Bilder\Beispielbilder\Winter.jpg', 20, 55, 460, 280)
#EndRegion Tab3

#Region Tab4
_OwnTab_Add($aCtrlTab) ;Start controls tab4
Global $Button4 = GUICtrlCreateButton("Acknowledge the alarm", 20, 120, 300, 20)
Global $Button5 = GUICtrlCreateButton("Enable tab 3", 20, 150, 300, 20)
Global $Button6 = GUICtrlCreateButton("Disable tab 3", 20, 180, 300, 20)
Global $Button7 = GUICtrlCreateButton("Hide tab 2", 20, 240, 300, 20)
Global $Button8 = GUICtrlCreateButton("Show tab 2", 20, 210, 300, 20)
#EndRegion Tab4

#Region Tab5 and "Tab in Tab"
_OwnTab_Add($aCtrlTab) ;Start controls tab5

GUICtrlCreateLabel("Style Black", 30, 50, 200, 20, 0x201)
$OwnTab_Style = 0
Local $aTabText[2] = ["Tab1", "New Info"] ;Declare the regions for the OwnTab-control
Local $aTabIcons[2][2] = [["shell32.dll", 20],["shell32.dll", 40]]
Global $aCtrlTab2 = _OwnTab_Create($hGui, $aTabText, 30, 80, 200, 200, 30, 0xD5D5D5, 0x00ff00, 0x00ff00, $aTabIcons)
_OwnTab_Add($aCtrlTab2) ;Start controls tab1
Global $BtnSet = GUICtrlCreateButton("Simulate", 80, 150, 100, 20)
_OwnTab_Add($aCtrlTab2) ;Start controls tab2
Global $BtnReset = GUICtrlCreateButton("Acknowledge", 80, 170, 100, 20)
_OwnTab_End($aCtrlTab2)

GUICtrlCreateLabel("Style White", 270, 50, 200, 20, 0x201)
$OwnTab_Style = 1
Local $aTabText[2] = ["Tab1", "Tab2"] ;Declare the regions for the OwnTab-control
Local $aTabIcons[2][2] = [["shell32.dll", 10],["shell32.dll", 60]]
Global $aCtrlTab3 = _OwnTab_Create($hGui, $aTabText, 270, 80, 200, 200, 30, 0xD5D5D5, 0x00ff00, 0x00ff00, $aTabIcons)
_OwnTab_Add($aCtrlTab3) ;Start controls tab1
GUICtrlCreateLabel("Just testing...", 280, 150, 100, 20)
GUICtrlSetBkColor(-1, -2)
_OwnTab_Add($aCtrlTab3) ;Start controls tab2
GUICtrlCreateLabel("Hello from tab2", 280, 150, 100, 20)
GUICtrlSetBkColor(-1, -2)
_OwnTab_End($aCtrlTab3)
#EndRegion Tab5

_OwnTab_End($aCtrlTab) ;new: end control-definition AND inizialize the OwnTab

_OwnTab_Disable($aCtrlTab, 3) ;new: disable tabitems
_OwnTab_SetFontCol($aCtrlTab, 0xFF) ;new: set font-color

$getrep = TrayCreateItem("Report")
TrayCreateItem("")
$otcset = TrayCreateItem("Settings")
TrayCreateItem("")
$about = TrayCreateItem("About...")
;~ TraySetIcon("icon.ico")
TraySetState()
GUISetState()
_OwnTab_Hover($aCtrlTab, 0xFFFF88) ;start hover-function if you want
_OwnTab_AlarmInit()

Local $msg, $msg2

While 1
    
    $msg = GUIGetMsg()
    For $a = 1 To UBound($aCtrlTab, 1) - 1
        If $msg = $aCtrlTab[$a][0] Then
            _OwnTab_Switch($aCtrlTab, $a)
            If $a = 5 Then
                _OwnTab_Switch($aCtrlTab2, $aCtrlTab2[0][0], 1)
                _OwnTab_Switch($aCtrlTab3, $aCtrlTab3[0][0], 1)
            EndIf
        EndIf
    Next
    For $a = 1 To UBound($aCtrlTab2, 1) - 1
        If $msg = $aCtrlTab2[$a][0] Then
            _OwnTab_Switch($aCtrlTab2, $a)
        EndIf
    Next
    For $a = 1 To UBound($aCtrlTab3, 1) - 1
        If $msg = $aCtrlTab3[$a][0] Then
            _OwnTab_Switch($aCtrlTab3, $a)
        EndIf
    Next
    Switch $msg
        Case $Button1
            _OwnTab_SetAlarm($aCtrlTab, 4, 0xFF0000)
        Case $Button4
            _OwnTab_ResetAlarm($aCtrlTab, 4)
        Case $BtnSet
            _OwnTab_SetAlarm($aCtrlTab2, 2, 0x5050FF)
        Case $BtnReset
            _OwnTab_ResetAlarm($aCtrlTab2, 2)
        Case $Button5
            _OwnTab_Enable($aCtrlTab, 3)
        Case $Button6
            _OwnTab_Disable($aCtrlTab, 3)
        Case $Button7
            _OwnTab_Hide($aCtrlTab, 2)
        Case $Button8
            _OwnTab_Show($aCtrlTab, 2)
        Case $Box1
            If GUICtrlRead($Box1) = 1 Then
                _OwnTab_Hover($aCtrlTab, 0xFFFF88, GUICtrlRead($Input1))
            Else
                _OwnTab_Hover($aCtrlTab, 0xFFFF88, 0)
            EndIf
        Case $Input1
            If GUICtrlRead($Box1) = 1 Then _OwnTab_Hover($aCtrlTab, 0xFFFF88, GUICtrlRead($Input1))
        Case -3
            Exit
    EndSwitch   
    
    $msg2 = TrayGetMsg()
    Select
        Case $msg2 = 0
            ContinueLoop
        Case $msg2 = $getrep
            _Report()
        Case $msg2 = $otcset
            _Setting()
        Case $msg2 = $about
            _AboutBox()
    EndSelect
    
    Sleep(10)
WEnd

Func _AboutBox()
    MsgBox(0, "About", "Text....")
EndFunc   ;==>_AboutBox

Func _Report()
    MsgBox(0, "Report", "Function not implemented!")
EndFunc   ;==>_Report

Func _Setting()
    MsgBox(0, "Settings...", "Function not implemented!")
EndFunc   ;==>_Setting

jfcby

Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

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