Jump to content

is there any deskband Example?


czyt
 Share

Recommended Posts

did you mean something like this?

#NoTrayIcon
#include <GDIplus.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <Constants.au3>

#region NotifyIcon Constants
Select
    Case @OSBuild < 2195
        $tagNOTIFYICONDATAW_TEMP = "DWORD cbSize; HWND hWnd; UINT uID; UINT uFlags; UINT uCallbackMessage; ptr hIcon; WCHAR szTip[64];"
    Case Else
        $tagNOTIFYICONDATAW_TEMP = "DWORD cbSize; HWND hWnd; UINT uID; UINT uFlags; UINT uCallbackMessage; ptr hIcon; WCHAR szTip[128];" & _
                "DWORD dwState; DWORD dwStateMask; WCHAR szInfo[256]; UINT  uTimeout; WCHAR szInfoTitle[64]; DWORD dwInfoFlags;"
EndSelect

Global Const $tagNOTIFYICONDATAW = $tagNOTIFYICONDATAW_TEMP
Global Const $tagNOTIFYICONDATA = $tagNOTIFYICONDATAW

Global Const $NIN_BALLOONSHOW = $WM_USER + 2
Global Const $NIN_BALLOONHIDE = $WM_USER + 3
Global Const $NIN_BALLOONTIMEOUT = $WM_USER + 4
Global Const $NIN_BALLOONUSERCLICK = $WM_USER + 5


Global Const $NIM_ADD = 0x00000000
Global Const $NIM_MODIFY = 0x00000001
Global Const $NIM_DELETE = 0x00000002
Global Const $NIM_SETFOCUS = 0x00000003
Global Const $NIM_SETVERSION = 0x00000004

Global Const $NIF_MESSAGE = 0x00000001
Global Const $NIF_ICON = 0x00000002
Global Const $NIF_TIP = 0x00000004
Global Const $NIF_STATE = 0x00000008
Global Const $NIF_INFO = 0x00000010
Global Const $NIF_GUID = 0x00000020
Global Const $NIF_REALTIME = 0x00000040
Global Const $NIF_SHOWTIP = 0x00000080

Global Const $NIS_VISIBLE = 0x00000000
Global Const $NIS_HIDDEN = 0x00000001
Global Const $NIS_SHAREDICON = 0x00000002

Global Const $NIIF_NONE = 0x00000000
Global Const $NIIF_INFO = 0x00000001
Global Const $NIIF_WARNING = 0x00000002
Global Const $NIIF_ERROR = 0x00000003
Global Const $NIIF_USER = 0x00000004
Global Const $NIIF_NOSOUND = 0x00000010
Global Const $NIIF_LARGE_ICON = 0x00000010
Global Const $NIIF_RESPECT_QUIET_TIME = 0x00000080
Global Const $NIIF_ICON_MASK = 0x0000000F

Global Const $WM_TRAYICONPROC = $WM_USER + 100

Global Const $HWND_For_TrayNotifications = GUICreate(@ScriptName & "TrayMsgWin", 1, 1, 0, 0, 0, 0, -3)
#endregion NotifyIcon Constants

; function to add / modify / delete NotfyIcon
Func _Shell_NotifyIcon($dwMessage, ByRef $lpdata)
    ; Prog@ndy
    Local $ptr
    If IsDllStruct($lpdata) Then
        $ptr = DllStructGetPtr($lpdata)
    Else
        $ptr = Ptr($lpdata)
    EndIf
    Local $result = DllCall("shell32.dll", "int", "Shell_NotifyIconW", "dword", $dwMessage, "ptr", $ptr)
    If @error Then Return SetError(1, @error, 0)
    Return SetError($result[0] = 0, 0, $result[0])
EndFunc   ;==>_Shell_NotifyIcon

; function to create an Icon from a GDIplus-Bitmap
Func _GDIPlus_BitmapCreateHICONFromBitmap($hBitmap)
    ; Prog@ndy
    Local $result = DllCall($__g_hGDIPDll, "int", "GdipCreateHICONFromBitmap", "ptr", $hBitmap, "ptr*", 0)
    If @error Then Return SetError(1, @error, 0)
    Return SetError($result[0], 0, $result[2])
EndFunc   ;==>_GDIPlus_BitmapCreateHICONFromBitmap

; Ereignisse für die TrayIcons
GUIRegisterMsg($WM_TRAYICONPROC, "TRAYICONPROC")

; GDIPlus starten
_GDIPlus_Startup()

Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics(16, 16, $hGraphics)
_GDIPlus_GraphicsDispose($hGraphics)

$hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap)

Global $hBrushText = _GDIPlus_BrushCreateSolid(0xFF000000)
Global $BrushBackground = _GDIPlus_BrushCreateSolid(0xFF00FF00)
_GDIPlus_GraphicsFillRect($hGraphics, 0, 0, 16, 16, $BrushBackground)

Global $hFormat = _GDIPlus_StringFormatCreate()
Global $hFontFamily = _GDIPlus_FontFamilyCreate("Arial")
Global $hFont = _GDIPlus_FontCreate($hFontFamily, 10, 0)
Global $tLayout = _GDIPlus_RectFCreate()

Global $sLauftext = StringFormat("%s:%s:%s", @HOUR, @MIN, @SEC)

Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sLauftext, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx($hGraphics, $sLauftext, $hFont, $aInfo[0], $hFormat, $hBrushText)

OnAutoItExitRegister("OnAutoItExit")

$hIcon = _GDIPlus_BitmapCreateHICONFromBitmap($hBitmap) ; Icon aus Bitmap erstellen

$ICON_ID = 333

$NOTIFYICONDATAW = DllStructCreate($tagNOTIFYICONDATAW) ; Daten für das Icon
DllStructSetData($NOTIFYICONDATAW, 1, DllStructGetSize($NOTIFYICONDATAW))
DllStructSetData($NOTIFYICONDATAW, "hWnd", $HWND_For_TrayNotifications)
DllStructSetData($NOTIFYICONDATAW, "uID", $ICON_ID) ; ID für das Icon
DllStructSetData($NOTIFYICONDATAW, "uFlags", BitOR($NIF_ICON, $NIF_TIP, $NIF_MESSAGE)) ; welche Eigenschaften sollen gesetzt werden
DllStructSetData($NOTIFYICONDATAW, "hIcon", $hIcon) ; Icon-Handle setzen
DllStructSetData($NOTIFYICONDATAW, "szTip", $sLauftext) ; Tooltip setzen
DllStructSetData($NOTIFYICONDATAW, "uCallbackMessage", $WM_TRAYICONPROC) ; die WindowMessage zum Empfangen von Ereignissen festelgen

_Shell_NotifyIcon($NIM_ADD, $NOTIFYICONDATAW) ; Das Icon erzeugen

_WinAPI_DestroyIcon($hIcon) ; Das Icon wieder löschen. Das TrayIcon hat eine Kopie davon erhalten.
DllStructSetData($NOTIFYICONDATAW, "uFlags", BitOR($NIF_ICON, $NIF_TIP)) ; Die gleiche Struktur wird später auch verwendet, aber nur, um
; das Icon und den tooltip zu ändern.

AdlibRegister("_Marquee", 50)

While 1
    Sleep(23000)
WEnd

Func OnAutoItExit()
    AdlibUnRegister()
    ; Aufräumen
    _Shell_NotifyIcon($NIM_DELETE, $NOTIFYICONDATAW) ; das TrayIcon löschen
    ; GDIPlus freigeben
    _GDIPlus_BrushDispose($BrushBackground)
    _GDIPlus_BrushDispose($hBrushText)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFontFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
EndFunc   ;==>OnAutoItExit

Func _Marquee()
    Local Static $x = 0, $Text = $sLauftext
    $x -= 1
    _GDIPlus_GraphicsFillRect($hGraphics, 0, 0, 16, 16, $BrushBackground)

    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $Text, $hFont, $tLayout, $hFormat)
    If $x <= -DllStructGetData($aInfo[0], 3) + 4 Then
        $x = 16
        $Text = $sLauftext
        DllStructSetData($NOTIFYICONDATAW, "szTip", $Text)
    EndIf
    DllStructSetData($aInfo[0], 1, $x)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $Text, $hFont, $aInfo[0], $hFormat, $hBrushText)

    ; Das Icon erzeugen
    $hIcon = _GDIPlus_BitmapCreateHICONFromBitmap($hBitmap)
    ; Das Icon setzen
    DllStructSetData($NOTIFYICONDATAW, "hIcon", $hIcon)
    ; Das TrayIcon erhält eine Kopie.
    _Shell_NotifyIcon($NIM_MODIFY, $NOTIFYICONDATAW)
    ; Das Icon löschen
    _WinAPI_DestroyIcon($hIcon)
EndFunc   ;==>_Marquee

Func TRAYICONPROC($hwnd, $uMsg, $wParam, $lParam)
    ; Ereignisse für das TrayIcon
    Local $uTrayMsg = _WinAPI_LoWord($lParam)
    Local $nID = _WinAPI_HiWord($lParam)
    Switch $uTrayMsg
        Case $NIN_BALLOONSHOW
            ConsoleWrite("Balloon show" & @CRLF)
        Case $NIN_BALLOONHIDE
            ConsoleWrite("Balloon hide" & @CRLF)
        Case $NIN_BALLOONTIMEOUT
            ConsoleWrite("Balloon timeout" & @CRLF)
        Case $NIN_BALLOONUSERCLICK
            ConsoleWrite("Balloon userclick" & @CRLF)
        Case $WM_LBUTTONUP
            ConsoleWrite("left mousebutton Up" & @CRLF)
        Case $WM_RBUTTONUP
            ConsoleWrite("right mousebutton Up" & @CRLF)
        Case $WM_LBUTTONDOWN
            ConsoleWrite("left mousebutton Down, set new value" & @CRLF)
            $sLauftext = StringFormat("%s:%s:%s", @HOUR, @MIN, @SEC)
        Case $WM_RBUTTONDOWN
            ConsoleWrite("right mousebutton Down" & @CRLF)
        Case $WM_CONTEXTMENU
            ConsoleWrite("Context Menu" & @CRLF)
        Case $WM_LBUTTONDBLCLK
            ConsoleWrite("left mousebutton doubleclick" & @CRLF)
            Exit
    EndSwitch
    Return _WinAPI_DefWindowProc($hwnd, $uMsg, $wParam, $lParam)
EndFunc   ;==>TRAYICONPROC

origin: @funkey https://autoit.de/index.php/Thread/33025-Anzeige-in-Symbolleiste/?pageNo=2

just updated to new AutoIt stable. ($__g_hGDIPDll in line 76 was $ghGDIPDLL)

 

or did you mean something like this:

 

Edited by AutoBert
Link to comment
Share on other sites

  • 10 months later...

I do not know how that is done, I was just asking for clarification in my previous post.

If you are looking for the specific program in the screenshot, it's called NetWorx, but it is no longer free :(

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

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