mjolnirmarkiv Posted November 12, 2014 Posted November 12, 2014 (edited) Hi there! Experienceing problems creating custom item in the context menu. Wondering if anyone could help? Here's very rough example, on "F1" it creates menu bar control "New Item" and displays it (just to check if it works at all). On context menu display it creates "New Item" context menu control (it does indeed, $outlook.ActiveExplorer.CommandBars("Context Menu").Controls collection returns new control among others) but doesn't not display it in actual context menu. So that'd be the problem right now -- I'm obviously missing smth here and trying to figure out how to display newly created item in the context menu. expandcollapse popupHotKeySet ("{F1}", "CreateMenuBarItem") Global $outlook = ObjGet ("", "Outlook.Application") If not IsObj ($outlook) Then Exit MsgBox (48, "Error", "Launch Outlook first!") Global $outlook_event = ObjEvent ($outlook, "Outlook") While 1 Sleep (10) WEnd $outlook_event.Stop $outlook_event = "" Func OutlookItemContextMenuDisplay ($p_command_bar, $p_selection) ;MsoControlType constants: http://msdn.microsoft.com/en-us/library/office/aa170976.aspx OutlookCommandBarAddItem ($p_command_bar, 1, "New Item", "NewItem") Switch @error Case 0 ToolTip ("No errors!") Case 1 ToolTip ("Specified command bar does not exists!") Case 2 ToolTip ("Not allowed item type has been specified!") Case 3 ToolTip ("Specified control already exists!") Case 4 ToolTip ("Failed to create new control!") EndSwitch EndFunc Func OutlookCommandBarAddItem ($p_command_bar, $p_item_type, $p_item_caption, $p_item_tag, $p_item_faceid = 0, $p_item_visible = true, $p_item_id = 1, $p_item_param = "", $p_item_before = 1, $p_item_temp = false) ;Check if command bar object exists If not IsObj ($p_command_bar) Then Return SetError (1, 0, 0) ;Check if item type is within allowed values If $p_item_type < 1 or ($p_item_type > 5 and $p_item_type <> 10) Then Return SetError (2, 0, 0) ;Check if specified item already exists in the command bar ;See: http://msdn.microsoft.com/en-us/library/microsoft.office.core.commandbar.findcontrol.aspx If IsObj ($p_command_bar.FindControl($p_item_type, $p_item_id, $p_item_tag)) Then Return SetError (3, 0, 0) ;See: http://msdn.microsoft.com/en-us/library/microsoft.office.core.commandbarcontrols.add.aspx Local $new_item = $p_command_bar.Controls.Add($p_item_type, $p_item_id, $p_item_param, $p_item_before, $p_item_temp) If not IsObj ($new_item) Then Return SetError (4, 0, 0) $new_item.Caption = $p_item_caption $new_item.Tag = $p_item_tag $new_item.FaceId = $p_item_faceid $new_item.Visible = $p_item_visible Return $new_item EndFunc Func CreateMenuBarItem () Local $menu_bar = $outlook.ActiveExplorer.CommandBars("Menu Bar") OutlookCommandBarAddItem ($menu_bar, 1, "New Item", "NewItem") EndFunc Thanks in advance for the help! P.S.: Just FYI, I have used this as template: http://office.microsoft.com/en-us/outlook-help/HV080800048.aspx Edited November 12, 2014 by mjolnirmarkiv
mjolnirmarkiv Posted November 14, 2014 Author Posted November 14, 2014 Still trying to figure out the problem here when I have a minute to spare, won't mind a little help. Because I have no idea how Outlooks creates it's context menu in any given situtation before it shows it to the user. Thought that command bar returned by "ItemContextMenuDisplay" would do the trick, but regardless of how many custom controls I create there -- it won't show them.
water Posted November 14, 2014 Posted November 14, 2014 Which version of AutoIt and Outlook do you run? My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
mjolnirmarkiv Posted November 15, 2014 Author Posted November 15, 2014 (edited) On 11/14/2014 at 5:19 PM, water said: Which version of AutoIt and Outlook do you run? Hi water, That'd be AutoIt 3.3.12.0 and Outlook 2010. Edited November 15, 2014 by mjolnirmarkiv
water Posted November 15, 2014 Posted November 15, 2014 I have the same environment here. And I get the same result: It doesn't work. What exactly do you want to do? Right click on an item in the explorer and have the "New Item" entry be displayed in the context menu? My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
mjolnirmarkiv Posted November 15, 2014 Author Posted November 15, 2014 On 11/15/2014 at 9:17 AM, water said: I have the same environment here. And I get the same result: It doesn't work. What exactly do you want to do? Right click on an item in the explorer and have the "New Item" entry be displayed in the context menu? Yep, exactly. And then do whatever on that item click, should not be a problem I hope.
water Posted November 15, 2014 Posted November 15, 2014 Seems it gets much more complex in Outlook 2010. My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Solution water Posted November 15, 2014 Solution Posted November 15, 2014 Maybe this article sheds some light on the subject. Extending the User Interface in Outlook 2010 My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
mjolnirmarkiv Posted November 15, 2014 Author Posted November 15, 2014 On 11/15/2014 at 9:42 AM, water said: Maybe this article sheds some light on the subject. Extending the User Interface in Outlook 2010 Thank you, water! I'll look into it.
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