Yashied Posted July 7, 2009 Share Posted July 7, 2009 (edited) In TraySetIcon() is passed the filename as a parameter. But how can I set the icon to tray with handle (HIcon)?Thanks. Edited July 7, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Authenticity Posted July 7, 2009 Share Posted July 7, 2009 expandcollapse popup#include <Constants.au3> #include <WinAPI.au3> #cs TraySetIcon('shell32.dll', -1) Sleep(1000) Exit #ce Global Const $NIM_MODIFY = 1 Global Const $NIF_MESSAGE = 1 ; The uCallbackMessage member is valid. Global Const $NIF_ICON = 2 ; The hIcon member is valid. Global Const $NIF_TIP = 4 ; The szTip member is valid. Global Const $NIF_STATE = 8 ; The dwState and dwStateMask members are valid. Global Const $NIF_INFO = 16 ; Use a balloon ToolTip instead of a standard ToolTip. ; The szInfo, uTimeout, szInfoTitle, and dwInfoFlags members Global Const $NIF_GUID = 32 ; Reserved Global Const $NIF_REALTIME = 64 ; Windows Vista (Shell32.dll version 6.0.6) and later. Global Const $NIF_SHOWTIP = 128 ; Windows Vista (Shell32.dll version 6.0.6) and later. Use the standard ToolTip Global Const $tagNOTIFYICONDATAW = _ 'dword cbSize;' & _ 'hwnd hWnd;' & _ 'uint uID;' & _ 'uint uFlags;' & _ 'uint uCallbackMessage;' & _ 'hwnd hIcon;' & _ 'wchar szTip[128];' & _ 'dword dwState;' & _ 'dword dwStateMask;' & _ 'wchar szInfo[256];' & _ 'uint uVersion;' & _ 'wchar szInfoTitle[64];' & _ 'dword dwInfoFlags;' ; & $tagGUID Global $hDll = _WinAPI_LoadLibrary('shell32.dll') Global $hIcon = _LoadIcon($hDll, "152") Global $tNID = DllStructCreate($tagNOTIFYICONDATAW), $pNID = DllStructGetPtr($tNID) Global $hWnd = WinGetHandle(AutoItWinGetTitle()) DllStructSetData($tNID, 'cbSize', DllStructGetSize($tNID)) DllStructSetData($tNID, 'hWnd', $hWnd) DllStructSetData($tNID, 'uID', 1) DllStructSetData($tNID, 'uFlags', $NIF_ICON) DllStructSetData($tNID, 'hIcon', $hIcon) _Shell_NotifyIcon($NIM_MODIFY, $pNID) Sleep(2000) _WinAPI_DestroyIcon($hIcon) _WinAPI_FreeLibrary($hDll) Exit Func _LoadIcon($hInstance, $sIconName) Local $aRet $aRet = DllCall('user32.dll', 'hwnd', 'LoadIconA', 'hwnd', $hInstance, 'uint', $sIconName) If @error Then Return SetError(1, 0, 0) Return $aRet[0] EndFunc Func _Shell_NotifyIcon($iMessage, $pdata) Local $aRet $aRet = DllCall('shell32.dll', 'int', 'Shell_NotifyIconW', 'dword', $iMessage, 'ptr', $pdata) If @error Then Return SetError(1, 0, 0) Return $aRet[0] EndFunc Link to comment Share on other sites More sharing options...
Yashied Posted July 7, 2009 Author Share Posted July 7, 2009 expandcollapse popup#include <Constants.au3> #include <WinAPI.au3> #cs TraySetIcon('shell32.dll', -1) Sleep(1000) Exit #ce Global Const $NIM_MODIFY = 1 Global Const $NIF_MESSAGE = 1 ; The uCallbackMessage member is valid. Global Const $NIF_ICON = 2 ; The hIcon member is valid. Global Const $NIF_TIP = 4 ; The szTip member is valid. Global Const $NIF_STATE = 8 ; The dwState and dwStateMask members are valid. Global Const $NIF_INFO = 16 ; Use a balloon ToolTip instead of a standard ToolTip. ; The szInfo, uTimeout, szInfoTitle, and dwInfoFlags members Global Const $NIF_GUID = 32 ; Reserved Global Const $NIF_REALTIME = 64 ; Windows Vista (Shell32.dll version 6.0.6) and later. Global Const $NIF_SHOWTIP = 128 ; Windows Vista (Shell32.dll version 6.0.6) and later. Use the standard ToolTip Global Const $tagNOTIFYICONDATAW = _ 'dword cbSize;' & _ 'hwnd hWnd;' & _ 'uint uID;' & _ 'uint uFlags;' & _ 'uint uCallbackMessage;' & _ 'hwnd hIcon;' & _ 'wchar szTip[128];' & _ 'dword dwState;' & _ 'dword dwStateMask;' & _ 'wchar szInfo[256];' & _ 'uint uVersion;' & _ 'wchar szInfoTitle[64];' & _ 'dword dwInfoFlags;' ; & $tagGUID Global $hDll = _WinAPI_LoadLibrary('shell32.dll') Global $hIcon = _LoadIcon($hDll, "152") Global $tNID = DllStructCreate($tagNOTIFYICONDATAW), $pNID = DllStructGetPtr($tNID) Global $hWnd = WinGetHandle(AutoItWinGetTitle()) DllStructSetData($tNID, 'cbSize', DllStructGetSize($tNID)) DllStructSetData($tNID, 'hWnd', $hWnd) DllStructSetData($tNID, 'uID', 1) DllStructSetData($tNID, 'uFlags', $NIF_ICON) DllStructSetData($tNID, 'hIcon', $hIcon) _Shell_NotifyIcon($NIM_MODIFY, $pNID) Sleep(2000) _WinAPI_DestroyIcon($hIcon) _WinAPI_FreeLibrary($hDll) Exit Func _LoadIcon($hInstance, $sIconName) Local $aRet $aRet = DllCall('user32.dll', 'hwnd', 'LoadIconA', 'hwnd', $hInstance, 'uint', $sIconName) If @error Then Return SetError(1, 0, 0) Return $aRet[0] EndFunc Func _Shell_NotifyIcon($iMessage, $pdata) Local $aRet $aRet = DllCall('shell32.dll', 'int', 'Shell_NotifyIconW', 'dword', $iMessage, 'ptr', $pdata) If @error Then Return SetError(1, 0, 0) Return $aRet[0] EndFuncIt`s exelent, Authenticity! I also played with Shell_NotifyIcon, but not decided how to define "uID". Thanks. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now