Ansteuern eines ausgelesenen Traymenüs

  • Moin!

    Ich bin erst kürzlich über Autoit gestolpert und wollte damit mal ein wenig rumspielen. Ich habe mir also ein Script geschrieben, dass aus der profiles.ini des Firefox die bestehenden Profile auslesen, in ein Traymenü einbinden und bei Aufruf des entsprechenden Profileintrags im Menü ausführen soll.

    Ich bin bis zu dem Punkt des Auslesens der profiles.ini gelangt, die dann die entsprechenden Einträge im Traymenü vornimmt. Ich kann diese aber nicht ausführen, da ich nicht weiß, wie ich meine Select-Funktion scripten soll.

    Weiß hier jemand Rat? Ich kenne mich mit den Begrifflichkeiten hier nicht aus, weswegen ich bei meiner Suche nach Hilfe im Forum vielleicht daneben lag. Im Zweifel muss ich mir wohl ein rtfm gefallen lassen.

    Hier mein bisheriges Script:

    [autoit]

    $counter = 0
    Opt("TrayMenuMode",1)
    $Profile = TrayCreateMenu("Profile starten")
    ;AUTOMATISCHES AUSLESEN DER PROFILE AUS profiles.ini
    Do
    $profilsuche = IniRead(@AppDataDir & "\Mozilla\Firefox\profiles.ini", "Profile" & $counter, "Name", "Fehler")
    If $profilsuche <> "Fehler" Then
    $Profilname = $profilsuche
    TrayCreateItem($Profilname, $Profile)
    $counter = $counter + 1
    Else
    EndIf
    Until $profilsuche = "Fehler"
    TrayCreateItem("")
    $exititem = TrayCreateItem("Ende")

    [/autoit][autoit][/autoit][autoit]

    TraySetState()

    [/autoit][autoit][/autoit][autoit]

    While 1
    $msg = TrayGetMsg()
    Select
    Case $msg = 0
    ContinueLoop
    ; WIE KANN ICH HIER DIE ERSTELLTEN MENÜPUNKTE DER profiles.ini ANSTEUERN?
    Case $msg = $exititem
    ExitLoop
    EndSelect
    WEnd

    [/autoit][autoit][/autoit][autoit]

    Exit

    [/autoit]

    Vielen Dank für Tipps und Infos.

  • hi huggy

    IniRead() habe ich ja schon eingebaut.

    Den Verweis auf GuiCtrlSetData vertehe ich ehrlich gesagt nicht, da ich es ja in der Systemtray lösen möchte. Ich habe die Hilfe schon rauf und runter gewälzt, jedoch keine anständige Lösung im Wust der Funktionen gefunden.
    GuiCtrlSetData bezieht sich doch nur auf ein GUI, wenn ich das richtig verstehe.

    Gibt es eine entsprechende Lösung für TrayCreateItem?

    Gruß

  • Holla - da haben wir schön aneinander vorbei geredet^^


    Ich denke du meinst TrayItemSetText ...


    aus der hilfe:


    Spoiler anzeigen

    TrayItemSetText
    --------------------------------------------------------------------------------

    Sets the itemtext of a tray menu/item control.


    TrayItemSetText ( controlID, text )


    Parameters

    controlID The control identifier (controlID) as returned by a TrayCreateItem or TrayCreateMenu function.
    text The new text of the tray menu/item control.


    Return Value

    Success: Returns 1.
    Failure: Returns 0.


    Remarks

    To change the itemtext of the default menuitems (Script Paused/Exit) use the constants $TRAY_ITEM_EXIT and $TRAY_ITEM_PAUSE as controlID.


    Related

    TrayItemGetText

    Example


    #Include <Constants.au3>
    #NoTrayIcon

    Opt("TrayAutoPause",0) ; Script will not be paused when clicking the tray icon.

    $valitem = TrayCreateItem("Val:")
    TrayCreateItem("")
    $aboutitem = TrayCreateItem("About")

    TraySetState()

    TrayItemSetText($TRAY_ITEM_EXIT,"Exit Program")
    TrayItemSetText($TRAY_ITEM_PAUSE,"Pause Program")

    While 1
    $msg = TrayGetMsg()
    Select
    Case $msg = 0
    ContinueLoop
    Case $msg = $valitem
    TrayItemSetText($valitem,"Val:" & Int(Random(1,10,1)))
    Case $msg = $aboutitem
    Msgbox(64,"About:","AutoIt3-Tray-sample")
    EndSelect
    WEnd

    Exit


    :D

    Einmal editiert, zuletzt von huggy (1. März 2007 um 07:22)

  • Zitat

    Original von huggy
    Ich denke du meinst TrayItemSetText ...

    Das könnte funktionieren. Ich habe mir TrayItemSetText gestern auch schon angeschaut, jedoch die Tragweite nicht erkannt. Jetzt muss ich mal basteln.

    Danke :klatschen:

  • okay, ich hab´s hingekriegt. Ich habe zufällig gesehen, dass ich mit arrays arbeiten kann, zumindest denke ich, dass es arrays sind. was soll´s, vor 3 tagen wusste ich noch nicht einmal, was eine variable ist. ;)

    wer sich für den fertigen schnipsel interessiert: man kann mit dem teil bis zu 10 firefox-profile aus der systemtray starten. die anzahl lässt sich aber auch entsprechend ändern.

    Spoiler anzeigen
    [autoit]

    #Include <Constants.au3>
    #Include <Array.au3>
    #Include <GUIConstants.au3>
    Dim $profil_array[10]
    Dim $Profilname[10]
    Dim $Profilbezeichnung[10]
    $counter = 0
    Opt("TrayMenuMode",1)
    $Profile = TrayCreateMenu("Profile starten")
    ;AUTOMATISCHES AUSLESEN DER PROFILE AUS profiles.ini
    Do
    $profilsuche = IniRead(@AppDataDir & "\Mozilla\Firefox\profiles.ini", "Profile" & $counter, "Name", "Fehler")
    If $profilsuche <> "Fehler" Then
    $Profilname[$counter] = $profilsuche
    $profil_array[$counter] = TrayCreateItem($Profilname[$counter], $Profile)
    $counter = $counter + 1
    Else
    EndIf
    Until $profilsuche = "Fehler"
    TrayCreateItem("")
    $exititem = TrayCreateItem("Ende")

    [/autoit] [autoit][/autoit] [autoit]

    TraySetState()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = TrayGetMsg()
    Select
    Case $msg = 0
    ContinueLoop
    Case $msg = $exititem
    ExitLoop
    Case Else
    For $i = 0 To $counter
    If $msg = $profil_array[$i] Then
    ProfilExecute()
    MsgBox(0, "", $Profilname[$i])
    Else
    EndIf
    Next
    EndSelect
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Func ProfilExecute()
    $profilexecute = Run(@ComSpec & " /c " & 'start C:\Progra~1\Mozill~1\firefox.exe -p "' & $Profilname[$i] & '"', "", @SW_HIDE)
    EndFunc

    [/autoit]