Jump to content

GUI/Tray Menu with icons and colors


Holger
 Share

Recommended Posts

You did try what nickston proposed correct?

_TrayIconSetToolTip($nTrayIcon1, "Datornamn: " & @ComputerName & @CRLF & "IPAdress: " & @IPAddress1 & " ," & @IPAddress2 & @CRLF & "Gateway: " & "127.000.000.001")

I'd say also try one at a time the same thing with @computername, @IpAddress1, @IpAddress2

I assume the Ip addresses are IPv4 and not IPv6 aswell

all else fails try setting a loop sending strings and up the length till it breaks

I don't have windows 10 I assume that is what you are using on both of these devices

 

When you say you set the laptop to 63 do you mean the buffer size or StringLeft($sToolTip,63)?

 

Edited by Bilgus
Link to comment
Share on other sites

im going to set a fixed length and run it for a while with

Global $sNOTIFYICONDATAW    = "dword;" & _      ; Struct size
           "hwnd;" & _       ; Callback window handle
           "uint;" & _       ; Icon ID
           "uint;" & _       ; Flags
           "uint;" & _       ; Callback message ID
           "hwnd;" & _       ; Icon handle
           "WCHAR[64];" & _ ; ToolTip text
           "dword;" & _      ; Icon state
           "dword;" & _      ; Icon state mask
           "WCHAR[256];" & _ ; Balloon ToolTip text
           "uint;" & _       ; Timeout / Version -> NIM_SETVERSION values 0, 3, 4
           "WCHAR[64];" & _  ; Balloon ToolTip title text
           "dword"           ; Balloon ToolTip info flags
           if @OSVersion = "WIN_10" THEN $sNOTIFYICONDATAW &= ";BYTE[128];" & _  ; Guid
                                                          "hwnd"           ; Balloon ToolTip IconHandle

and

;**********************************************************************
; _TrayIconSetToolTip($NotificationID, $sToolTip)
;**********************************************************************
Func _TrayIconSetToolTip($nID = -1, $sToolTip = $sDefaultTT)
    If $nID = -1 Then $nID = $TRAYLASTID
    If $TRAYMSGWND = 0 Or $nID <= 0 Then Return 0

    Local $stNID    = DllStructCreate($sNOTIFYICONDATAW)
    DllStructSetData($stNID, 1, DllStructGetSize($stNID))
    DllStructSetData($stNID, 2, $TRAYMSGWND)
    DllStructSetData($stNID, 3, $nID)
    DllStructSetData($stNID, 4, $NIF_TIP)
    DllStructSetData($stNID, 7, StringLeft($sToolTip,127))
;   DllStructSetData($stNID, 7, $sToolTip)
    Return Shell_NotifyIcon($NIM_MODIFY, DllStructGetPtr($stNID))
EndFunc

Main loop

If $LatencyTest = 1 Then
                If TimerDiff($iBegin) > $InternetCheckTime Then ; Loop until 5 sec have passed
                    Local $gate = _GetGatewayIP()
                    _DebugOut("GATE: " & $gate)
                    Local $iPing = Ping($LatencyUrl, $LatencyMS)
                    If @error Then
                        If @error = 1 Then
                            _TrayIconSetIcon($nTrayIcon1, @ScriptFullPath, -5)
                            Local $tool = StringLen(@ComputerName & @CRLF & "IP: " & @IPAddress1 & @CRLF & "Gate: " & $gate & @CRLF & " error: " & @error & ", Host is offline.")
                            _DebugOut("Error1: " & $tool)
                            ;                           _TrayIconSetToolTip($nTrayIcon1, @ComputerName & @CRLF & "IP: " & @IPAddress1 & @CRLF & "Gate: " & $gate & @CRLF & " error: " & @error & ", Host is offline.")
                            _TrayIconSetToolTip($nTrayIcon1, "blablabla" & @CRLF & "IP: 127.000.000.001" & @CRLF & "Gate: bla.bla.bla.bla" & @CRLF & " error: (1) ")

                            _DebugOut("*PING: " & @error & ", Host is offline")
                        ElseIf @error = 2 Then
                            _TrayIconSetIcon($nTrayIcon1, @ScriptFullPath, -5)
                            Local $tool = StringLen(@ComputerName & @CRLF & "IP: " & @IPAddress1 & @CRLF & "Gate: " & $gate & @CRLF & " error: " & @error & ", Host is unreachable.")
                            _DebugOut("Error2: " & $tool)
                            ;_TrayIconSetToolTip($nTrayIcon1, @ComputerName & @CRLF & "IP: " & @IPAddress1 & @CRLF & "Gate: " & $gate & @CRLF & " error: " & @error & ", Host is unreachable.")
                            _TrayIconSetToolTip($nTrayIcon1, "blablabla" & @CRLF & "IP: 127.000.000.001" & @CRLF & "Gate: bla.bla.bla.bla" & @CRLF & " error:(2) ")
                            _DebugOut("*PING: " & @error & ", Host is unreachable")
                        ElseIf @error = 3 Then
                            _TrayIconSetIcon($nTrayIcon1, @ScriptFullPath, -5)
                            Local $tool = StringLen(@ComputerName & @CRLF & "IP: " & @IPAddress1 & @CRLF & "Gate: " & $gate & @CRLF & " error: " & @error & ", Bad destination")
                            _DebugOut("Error3: " & $tool)
                            ;                           _TrayIconSetToolTip($nTrayIcon1, @ComputerName & @CRLF & "IP: " & @IPAddress1 & @CRLF & "Gate: " & $gate & @CRLF & " error: " & @error & ", Bad destination")
                            _TrayIconSetToolTip($nTrayIcon1, "blablabla" & @CRLF & "IP: 127.000.000.001" & @CRLF & "Gate: bla.bla.bla.bla" & @CRLF & " error: (3) ")
                            _DebugOut("*PING: " & @error & ", Bad destination")
                        ElseIf @error = 4 Then
                            _TrayIconSetIcon($nTrayIcon1, @ScriptFullPath, -5)
                            Local $tool = StringLen(@ComputerName & @CRLF & "IP: " & @IPAddress1 & @CRLF & "Gate: " & $gate & @CRLF & " error: " & @error & ", Bad destination")
                            _DebugOut("Error4: " & $tool)
                            ;                           _TrayIconSetToolTip($nTrayIcon1, @ComputerName & @CRLF & "IP: " & @IPAddress1 & @CRLF & "Gate: " & $gate & @CRLF & " error: " & @error & ", Other errors")
                            _TrayIconSetToolTip($nTrayIcon1, "blablabla" & @CRLF & "IP: 127.000.000.001" & @CRLF & "Gate: bla.bla.bla.bla" & @CRLF & " error: (4) ")
                            _DebugOut("*PING: " & @error & ", Other errors")
                        EndIf
                    Else
                        _DebugOut("*PING: The roundtrip-time took: " & $iPing & "ms.")
                        If $iPing > "200" Then
                            _TrayIconSetIcon($nTrayIcon1, @ScriptFullPath, -6)
                        Else
                            _TrayIconSetIcon($nTrayIcon1, @ScriptFullPath, -1)
                        EndIf

                        Local $tool = StringLen(@ComputerName & @CRLF & "IP: " & @IPAddress1 & @CRLF & "Gate: " & $gate & @CRLF & "Internet: " & $iPing & " Ms.")
                        _DebugOut("Good: " & $tool)
                        ;                   _TrayIconSetToolTip($nTrayIcon1, @ComputerName & @CRLF & "IP: " & @IPAddress1 & @CRLF & "Gate: " & $gate & @CRLF & "Internet: " & $iPing & " Ms.")
                        _TrayIconSetToolTip($nTrayIcon1, "blablabla" & @CRLF & "IP: 127.000.000.001" & @CRLF & "Gate: bla.bla.bla.bla" & @CRLF & " error: (0) ")
                    EndIf
                    $iBegin = TimerInit()
                EndIf

.

 

Link to comment
Share on other sites

Update:  did a test of when it hangs.

after the 425 time of updateing the toolicontip it stopped.

the check was set to update the tip every 6 sec, no more no less..

so it must be the way it updates not the string length in it self.

 

so for 425 times it updated the tip correct, then start to run wild in cpu 20% utilisation and not responding to input other then that the Icon menu is availeble, but u cant click anything.

Checked 2 times now the magic number is 425 times done every 6 sec :)

 

Edited by lgvlgv
Link to comment
Share on other sites

Sorry, but u guys where right all along :) it was the _gateway function that coused problem.

I was sure i removed it everywhere when i did the test on a fixed string, but i found it else where in the script..

 

problem is solved, thx for all ur help and that u took time to help me.

 

 

Link to comment
Share on other sites

  • 1 year later...

Hi guys,

 

After searching a lot for solutions to have my very own system tray for Windows 10, with a Dark Theme look, I tried this UDF, and by the way it is fantastic. I tried to use it to simulate a "dark look", setting all the colors variables to a dark pattern, but the systray menus always have a gray/light border padding around the menu (and also a little bevel).

I don't want to design my own systray menu system, and since I was so close to accomplish that with this UDF, could someone point me to the part of code that adds/puts this light padding around the systray menu, so I can reprogram it? giving it a flat design and really gaining the Dark Theme Windows 10 has?

Thanks in advance!

 

And Cheers from Brazil

;)

Link to comment
Share on other sites

  • 1 month later...

Top job Holder, trying this in a project and looks good.

Found an interesting issue when used and you set the background colour of a button on a gui though;

...even without using any of the functions and by just including ModernMenu.au3 a coloured button is blanked.  It is still there and functions but not visible.  Example: (un-comment the include to see issue)

#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>
;#include <ModernMenu.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("Example", 300, 200)
    Local $idHello = GUICtrlCreateButton("Hello", 120, 170, 85, 25)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)
    GUICtrlSetBkColor($idHello, $COLOR_SKYBLUE)
    GUISetState(@SW_SHOW, $hGUI)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop
            Case $idHello
                MsgBox(0, "Still Here", "Hi there")
        EndSwitch
    WEnd
    GUIDelete($hGUI)
EndFunc   ;==>Example

Any suggestions ?

Link to comment
Share on other sites

  • 3 years later...
  • 1 year later...
  • 3 weeks later...

error when compile with Au3Stripper

 

#AutoIt3Wrapper_Run_Au3Stripper=y
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 6 -w 7
#Au3Stripper_Parameters=/sf
#Au3Stripper_Ignore_Funcs=_traynotifyicon
#Au3Stripper_Ignore_Errors_in_Funcs=_traynotifyicon,GUICtrlSetOnEvent,Call,DllCallbackRegister

 

>Running Au3Stripper (23.402.1150.1)  from:C:\Program Files (x86)\AutoIt3\SciTE\Au3Stripper cmdline:
-### StripOnly/StripFunc Error: Found Call() statement using unsolvable Func, which will/could lead to removal of Funcs that are used by this Function.
>### current Func: _traynotifyicon
r:\libs-ext\modernmenuraw.au3(571,1): Warning for line:Call($TRAYNOTIFYIDS[$nID][5], $nID, $lParam)

 

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