jennico Posted November 18, 2008 Posted November 18, 2008 i'm sorry i have no idea. i guess you could send a mouseclick to the icon by _SendMessage(IconHwnd, WM_RBUTTONDOWN) but i really don't know how to get the icon handle in the native autoit trayicon. as to this udf, you will have a handle to the icon, so you could try it with _sendmessage. maybe it works. j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
jennico Posted November 18, 2008 Posted November 18, 2008 from forum search:http://www.autoitscript.com/forum/index.php?showtopic=13704http://www.autoitscript.com/forum/index.ph...st&p=342464http://www.autoitscript.com/forum/index.ph...st&p=406421lots of examples. they will do it. good luckj. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
jennico Posted November 18, 2008 Posted November 18, 2008 this does it:expandcollapse popup#NoTrayIcon #Include <GuiToolBar.au3> _SysTray_ClickItem("AIMP2", "right", 1) If @error Then MsgBox(48, "Failure", "Required item not found") ;=========# _SysTray_ClickItem #====================================================== ; ;Function Name: _SysTray_ClickItem() ;Description: Click on item in Windows system tray by any substring in the title ;Parameters: $iTitle - The title of the item in Windows system tray (you can see the title of the item when mouse cursor hovered on item). ; $iButton - [optional] The button to click, "left" or "right". Default is the left button. ; $iClick - [optional] The number of times to click the mouse. Default is 1 ; $sMove = [optional] True = Mouse will be moved, False (default) = Mouse will not be moved ; $iSpeed = [optional] Mouse movement speed ;Return Value(s): Success - Returns 1 ; Failure - Returns 0 and sets @error to 1 if required item not found ;Requirement(s): AutoIt 3.2.10.0 and above ;Autor(s): R.Gilman (a.k.a rasim); Siao (Thanks for idea) ; ;==================================================================================== Func _SysTray_ClickItem($iTitle, $iButton = "left", $iClick = 1, $sMove = False, $iSpeed = 1) Local $hToolbar, $iButCount, $aRect, $hButton, $cID, $i $hToolbar = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]") If @error Then Return SetError(1, 0, 0) EndIf $iButCount = _GUICtrlToolbar_ButtonCount($hToolbar) If $iButCount = 0 Then Return SetError(1, 0, 0) EndIf $hButton = ControlGetHandle("[Class:Shell_TrayWnd]", "", "Button2") If $hButton <> "" Then ControlClick("[Class:Shell_TrayWnd]", "", "Button2") For $i = 0 To $iButCount - 1 $cID = _GUICtrlToolbar_IndexToCommand($hToolBar, $i) If StringInStr(_GUICtrlToolbar_GetButtonText($hToolBar, $cID), $iTitle) Then _GUICtrlToolbar_ClickButton($hToolbar, $cID, $iButton, $sMove, $iClick, $iSpeed) Return 1 EndIf Next Return SetError(1, 0, 0) EndFuncfrom hereforum Searchj. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
abushcrafter Posted November 20, 2008 Posted November 20, 2008 Thanks very muchly for finding those. That last post is a great dodge for the mow. Yes I have done searches and all I found was thishttp://www.autoitscript.com/forum/index.ph...+show+tray+menuHow ever I have just scanned that thread to see wherever any one had posted a better solution than hijacking the mouse and keyboard to no oval.But it seams that there is no better way to do is for autoits tray menu funcs.So then what about the "cool menu with colour & icons script" of this thread. Is there some function in it you can use for showing the tray menu with, in this case a hotkey? [center]I click you, you click me!The Home Of abushcrafter[/center]
jennico Posted November 22, 2008 Posted November 22, 2008 the "modernmenueraw.au3" contains the functions you will need, i think. you will need the handle of the popup menu or the icon handle. one of these functions will help you. i cannot tell you exactly how, you will have to try out a lot. Func _MyHotKeyFunc() ; DllCall($hUser32Dll, "int", "SetForegroundWindow","hwnd", GUICtrlGetHandle($mt)) ; _TrayNotifyIcon($mt, 512, $xxx, 0) ; DllCall($hUser32Dll, "int", "ShowWindow", "hwnd", $xxx,"int", @SW_SHOW) EndFunc but meanwhile, this works fine and you should be satisfied with it, no ? expandcollapse popup#NoTrayIcon #Include <GuiToolBar.au3> HotKeySet("{Enter}","_Click") While 1 Sleep(1) WEnd Func _Click(); enter the title of your trayitem here ! _SysTray_ClickItem("e", "right", 1) EndFunc ;=========# _SysTray_ClickItem #====================================================== ; ;Function Name: _SysTray_ClickItem() ;Description: Click on item in Windows system tray by any substring in the title ;Parameters: $iTitle - The title of the item in Windows system tray (you can see the title of the item when mouse cursor hovered on item). ; $iButton - [optional] The button to click, "left" or "right". Default is the left button. ; $iClick - [optional] The number of times to click the mouse. Default is 1 ; $sMove = [optional] True = Mouse will be moved, False (default) = Mouse will not be moved ; $iSpeed = [optional] Mouse movement speed ;Return Value(s): Success - Returns 1 ; Failure - Returns 0 and sets @error to 1 if required item not found ;Requirement(s): AutoIt 3.2.10.0 and above ;Autor(s): R.Gilman (a.k.a rasim); Siao (Thanks for idea) ; ;==================================================================================== Func _SysTray_ClickItem($iTitle, $iButton = "left", $iClick = 1, $sMove = False, $iSpeed = 1) Local $hToolbar, $iButCount, $aRect, $hButton, $cID, $i $hToolbar = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]") If @error Then Return SetError(1, 0, 0) EndIf $iButCount = _GUICtrlToolbar_ButtonCount($hToolbar) If $iButCount = 0 Then Return SetError(1, 0, 0) EndIf $hButton = ControlGetHandle("[Class:Shell_TrayWnd]", "", "Button2") If $hButton <> "" Then ControlClick("[Class:Shell_TrayWnd]", "", "Button2") For $i = 0 To $iButCount - 1 $cID = _GUICtrlToolbar_IndexToCommand($hToolBar, $i) If StringInStr(_GUICtrlToolbar_GetButtonText($hToolBar, $cID), $iTitle) Then _GUICtrlToolbar_ClickButton($hToolbar, $cID, $iButton, $sMove, $iClick, $iSpeed) Return 1 EndIf Next Return SetError(1, 0, 0) EndFunc the script clicks right on the first icon which title contains an "e". cheers j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
jennico Posted November 22, 2008 Posted November 22, 2008 is there a possibility to change the font of the trayitems and sidebar ? from MSDN: Setting Fonts for Menu-Item Text Strings This topic contains an example from an application that uses owner-drawn menu items in a menu. The menu contains items that set the attributes of the current font, and the items are displayed using the appropriate font attribute. Here is how the menu is defined in the resource-definition file. Note that the strings for the Regular, Bold, Italic, and Underline menu items are assigned at run time, so their strings are empty in the resource-definition file. Copy Code MainMenu MENU BEGIN POPUP "&Character" BEGIN MENUITEM "", IDM_REGULAR MENUITEM SEPARATOR MENUITEM "", IDM_BOLD MENUITEM "", IDM_ITALIC MENUITEM "", IDM_ULINE END END The application's window procedure processes the messages involved in using owner-drawn menu items. The application uses the WM_CREATE message to do the following: Set the MF_OWNERDRAW flag for the menu items. Set the text strings for the menu items. Obtain handles of the fonts used to draw the items. Obtain the text and background color values for selected menu items. The text strings and font handles are stored in an array of application-defined MYITEM structures. The application-defined GetAFont function creates a font that corresponds to the specified font attribute and returns a handle to the font. The handles are destroyed during the processing of the WM_DESTROY message. During the processing of the WM_MEASUREITEM message, the example gets the width and height of a menu-item string and copies these values into the MEASUREITEMSTRUCT structure. The system uses the width and height values to calculate the size of the menu. During the processing of the WM_DRAWITEM message, the menu item's string is drawn with room left next to the string for the check-mark bitmap. If the user selects the item, the selected text and background colors are used to draw the item. Copy Code LRESULT APIENTRY MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { typedef struct _MYITEM { HFONT hfont; LPSTR psz; } MYITEM; // structure for item font and string MYITEM *pmyitem; // pointer to item's font and string static MYITEM myitem[CITEMS]; // array of MYITEMS static HMENU hmenu; // handle to main menu static COLORREF crSelText; // text color of selected item static COLORREF crSelBkgnd; // background color of selected item COLORREF crText; // text color of unselected item COLORREF crBkgnd; // background color unselected item LPMEASUREITEMSTRUCT lpmis; // pointer to item of data LPDRAWITEMSTRUCT lpdis; // pointer to item drawing data HDC hdc; // handle to screen DC SIZE size; // menu-item text extents WORD wCheckX; // check-mark width int nTextX; // width of menu item int nTextY; // height of menu item int i; // loop counter HFONT hfontOld; // handle to old font BOOL fSelected = FALSE; // menu-item selection flag size_t * pcch; HRESULT hResult; switch (uMsg) { case WM_CREATE: // Modify the Regular, Bold, Italic, and Underline // menu items to make them owner-drawn items. Associate // a MYITEM structure with each item to contain the // string for and font handle to each item. hmenu = GetMenu(hwnd); ModifyMenu(hmenu, IDM_REGULAR, MF_BYCOMMAND | MF_CHECKED | MF_OWNERDRAW, IDM_REGULAR, (LPTSTR) &myitem[REGULAR]); ModifyMenu(hmenu, IDM_BOLD, MF_BYCOMMAND | MF_OWNERDRAW, IDM_BOLD, (LPTSTR) &myitem[bOLD]); ModifyMenu(hmenu, IDM_ITALIC, MF_BYCOMMAND | MF_OWNERDRAW, IDM_ITALIC, (LPTSTR) &myitem[iTALIC]); ModifyMenu(hmenu, IDM_ULINE, MF_BYCOMMAND | MF_OWNERDRAW, IDM_ULINE, (LPTSTR) &myitem[uLINE]); // Retrieve each item's font handle and copy it into // the hfont member of each item's MYITEM structure. // Also, copy each item's string into the structures. myitem[REGULAR].hfont = GetAFont(REGULAR); myitem[REGULAR].psz = "Regular"; myitem[bOLD].hfont = GetAFont(BOLD); myitem[bOLD].psz = "Bold"; myitem[iTALIC].hfont = GetAFont(ITALIC); myitem[iTALIC].psz = "Italic"; myitem[uLINE].hfont = GetAFont(ULINE); myitem[uLINE].psz = "Underline"; // Retrieve the text and background colors of the // selected menu text. crSelText = GetSysColor(COLOR_HIGHLIGHTTEXT); crSelBkgnd = GetSysColor(COLOR_HIGHLIGHT); return 0; case WM_MEASUREITEM: // Retrieve a device context for the main window. hdc = GetDC(hwnd); // Retrieve pointers to the menu item's // MEASUREITEMSTRUCT structure and MYITEM structure. lpmis = (LPMEASUREITEMSTRUCT) lParam; pmyitem = (MYITEM *) lpmis->itemData; // Select the font associated with the item into // the main window's device context. hfontOld = SelectObject(hdc, pmyitem->hfont); // Retrieve the width and height of the item's string, // and then copy the width and height into the // MEASUREITEMSTRUCT structure's itemWidth and // itemHeight members. hResult = StringCchLength(pmyitem->psz,STRSAFE_MAX_CCH, pcch); if (FAILED(hResult)) { // Add code to fail as securely as possible. return; } GetTextExtentPoint32(hdc, pmyitem->psz, *pcch, &size); lpmis->itemWidth = size.cx; lpmis->itemHeight = size.cy; // Select the old font back into the device context, // and then release the device context. SelectObject(hdc, hfontOld); ReleaseDC(hwnd, hdc); return TRUE; break; case WM_DRAWITEM: // Get pointers to the menu item's DRAWITEMSTRUCT // structure and MYITEM structure. lpdis = (LPDRAWITEMSTRUCT) lParam; pmyitem = (MYITEM *) lpdis->itemData; // If the user has selected the item, use the selected // text and background colors to display the item. if (lpdis->itemState & ODS_SELECTED) { crText = SetTextColor(lpdis->hDC, crSelText); crBkgnd = SetBkColor(lpdis->hDC, crSelBkgnd); fSelected = TRUE; } // Remember to leave space in the menu item for the // check-mark bitmap. Retrieve the width of the bitmap // and add it to the width of the menu item. wCheckX = GetSystemMetrics(SM_CXMENUCHECK); nTextX = wCheckX + lpdis->rcItem.left; nTextY = lpdis->rcItem.top; // Select the font associated with the item into the // item's device context, and then draw the string. hfontOld = SelectObject(lpdis->hDC, pmyitem->hfont); hResult = StringCchLength(pmyitem->psz,STRSAFE_MAX_CCH, pcch); if (FAILED(hResult)) { // Add code to fail as securely as possible. return; } ExtTextOut(lpdis->hDC, nTextX, nTextY, ETO_OPAQUE, &lpdis->rcItem, pmyitem->psz, *pcch, NULL); // Select the previous font back into the device // context. SelectObject(lpdis->hDC, hfontOld); // Return the text and background colors to their // normal state (not selected). if (fSelected) { SetTextColor(lpdis->hDC, crText); SetBkColor(lpdis->hDC, crBkgnd); } return TRUE; // Process other messages. case WM_DESTROY: // Destroy the menu items' font handles. for (i = 0; i < CITEMS; i++) DeleteObject(myitem.hfont); PostQuitMessage(0); break; default: return DefWindowProc(hwnd, uMsg, wParam, lParam); } return NULL; } HFONT GetAFont(int fnFont) { static LOGFONT lf; // structure for font information // Get a handle to the ANSI fixed-pitch font, and copy // information about the font to a LOGFONT structure. GetObject(GetStockObject(ANSI_FIXED_FONT), sizeof(LOGFONT), &lf); // Set the font attributes, as appropriate. if (fnFont == BOLD) lf.lfWeight = FW_BOLD; else lf.lfWeight = FW_NORMAL; lf.lfItalic = (fnFont == ITALIC); lf.lfItalic = (fnFont == ULINE); // Create the font, and then return its handle. return CreateFont(lf.lfHeight, lf.lfWidth, lf.lfEscapement, lf.lfOrientation, lf.lfWeight, lf.lfItalic, lf.lfUnderline, lf.lfStrikeOut, lf.lfCharSet, lf.lfOutPrecision, lf.lfClipPrecision, lf.lfQuality, lf.lfPitchAndFamily, lf.lfFaceName); } can anyone help with the fonts ? thx j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
jennico Posted November 23, 2008 Posted November 23, 2008 still hanging around here on my own.... i think it is possible to do just the same (AND MORE) with simple popup guis and labels. isn't it ? in this way you are free to design anything you like and it would be easier to use.... maybe i will give it a try when i have time... j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
abushcrafter Posted November 25, 2008 Posted November 25, 2008 Don't know about the fonts? But thanks for the hint in the modernmenueraw.au3 . Yes I am for the short term satisfied with that [center]I click you, you click me!The Home Of abushcrafter[/center]
nickston Posted December 8, 2008 Posted December 8, 2008 (edited) Hi. I need some help. In my script I want to change the Tray icon. For this I do: TrayIconSetIcon(-1, 'icon.ico'). The old icon is destroyed, but the new icon from file "icon.ico" doesn't drawn. What I do not rigth? I have resolved this problem. The Icon doesn't drawn If before it the _TrayIconSetState(-1,1) has not been done. That's not good, I don't want to draw the old icon. Edited December 9, 2008 by nickston
Dougiefresh Posted December 31, 2008 Posted December 31, 2008 Thanks, Holger! I really love the ModernMenu code that you gave! But, has there been any progress on the 64-bit compatibility? Just wondering.....
nickston Posted January 19, 2009 Posted January 19, 2009 another question:i can't get the icon flashingTo activate flashing use _TrayIconSetState($ID, 4)doesn't seem to work.any idea ?j.Hi. all.The ModernMenuRaw.au3 have a bug, from which _TrayIconSetState($ID, 4) don't work.There is a set SetTimer($TRAYMSGWND, $FLASHTIMERID, $FLASHTIMEOUT, 0), but there are must be the another set SetTimer($TRAYMSGWND, $nID, $FLASHTIMEOUT, 0). There are you need change two strings.
Jango Posted March 13, 2009 Posted March 13, 2009 Hello, I'm using this great tray menu but i can't get it to work with OnEvent ? Here is the code i use: $Setup = _TrayCreateItem("Setup") TrayItemSetOnEvent(-1, "Setup") _TrayItemSetIcon(-1, $ScriptDir & "\data\set.ico", 0) TrayItemSetOnEvent is not trigerred when i click, why ?
GEOSoft Posted March 13, 2009 Posted March 13, 2009 Did you mange to read this far in the help file and actually set Opt(TrayOnEventMode)?OnEvent functions are only called when the option TrayOnEventMode is set to 1 - when in this mode TrayGetMsg is NOT used at all. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Jango Posted March 13, 2009 Posted March 13, 2009 Did you mange to read this far in the help file and actually set Opt(TrayOnEventMode)?Yes it's set to 1... in fact my tray menu worked with an old version done by jennico, now i use this nicer tray menu but my Events are not triggered Can someone confirm it works with events ? as this i can't double check my code to see if i made a mistake somewhere
ProgAndy Posted March 13, 2009 Posted March 13, 2009 I think, this UDF uses GUI-Menus, not Tray-menus. So you should use GUIOnEventMode and GUICtrlSetOnEvent. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
Jango Posted March 13, 2009 Posted March 13, 2009 I think, this UDF uses GUI-Menus, not Tray-menus. So you should use GUIOnEventMode and GUICtrlSetOnEvent.Thank you ProgAndy it works now
rajeshontheweb Posted May 10, 2009 Posted May 10, 2009 i 'm gonna start using ur UDF i didnt want to go for all fancy looking (or great looking!) tray menu yet, but due to restrictions on the innate menu handling, i am on with this must-have UDf. but one suggesiton, can u post a normal - builtin menu like system tray menu example, for a starter to understand basic stuff, without all the other stuff? Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet
ZNote Posted June 1, 2009 Posted June 1, 2009 Some Examples FOR X64. When using this UDF On x64 blank menu appears. ( Background white & characters white ) NO COLOR SETTINGS CHANGED. GIVEN EXAMPLES CANNOT BE SEEN WHEN EXECUTED. Functions are executed when clicked but not seen.
ProgAndy Posted June 1, 2009 Posted June 1, 2009 I think the DLLStucts aren't compatible to x64. You have to compile and run scripts as 32bit or fix the DLLStructs *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
ZNote Posted June 3, 2009 Posted June 3, 2009 (edited) OK. Yes you are right. 32 bit do run on 64bit , I've tried that. The above situation is also valid for _SYSTRAY UDF. In _SYSTRAY UDF, array returns nothing or same value or program crashed when using autoit x64.exe. Thanks For Replying. Edited June 3, 2009 by ZNote
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