monarch684 Posted January 5, 2016 Share Posted January 5, 2016 I have been tasked with setting up a script that will do the following:Open Outlook Calendar - DoneAdd room calendars to viewChange view to "Day"Hide RibbonClick Next every 24 hours to be on the correct day - Maybe a separate script ran with task managerI have looked at the OutlookEX.au3 and couldn't find anything that really pertained to the calendar in Outlook. I am not necessarily looking for someone to write a script for me, just to be pointed the right direction.This script will run at login not matter who logs into this workstation. This is a dedicated workstation for the sole purpose of showing our many conference room calendars in a public viewing area. I have talked about making AutoIt set the resolution and clicking on coordinates but the powers at be do not want to be restrained to a certain resolution or having to edit the script just to change resolution.Another thought is that AutoIt may be the wrong way to go about this. Any suggestions are much appreciated. Here is what I have so far on the script; as you can see I haven't gotten very far even though I have been working on it for 2 hours now.Func StartCal() ConsoleWrite($hwnd) EndFunc ; Verify Outlook Process is Running If ProcessExists("Outlook.exe") Then ; Make Outlook the Active Window WinActivate("Microsoft Outlook") $hWnd = WinGetHandle("Microsoft Outlook") WinSetState($hwnd,"",@SW_MAXIMIZE) StartCal() Else ; Start Outlook if not running Run("C:\Program Files (x86)\Microsoft Office\Office14\Outlook.exe /select Outlook:Calendar","",@SW_MAXIMIZE) WinWaitActive("Microsoft Outlook","NUIDocumentWindow",5) $hWnd = WinGetHandle("Microsoft Outlook") StartCal() EndIf Link to comment Share on other sites More sharing options...
water Posted January 5, 2016 Share Posted January 5, 2016 This little example will display the Calendar using the OutlookEX UDF:#include <OutlookEX.au3> Global $oOL = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) Global $aFolder = _OL_FolderAccess($oOL, "", $olFolderCalendar) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the calendar. @error = " & @error) $aFolder[1].Display _OL_Close($oOL)Next step could be to define a view which then could easily be called by the script. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted January 5, 2016 Share Posted January 5, 2016 (edited) From which group do you need to display calendars? The default calendar group?How would you like to select the calenders? By number, by name? Edited January 5, 2016 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
monarch684 Posted January 5, 2016 Author Share Posted January 5, 2016 They are by name. I.E. Conf Room ABC, Conf Room DEF, Conf Room GHI Link to comment Share on other sites More sharing options...
water Posted January 5, 2016 Share Posted January 5, 2016 This example should display 3 calendars from the default navigation group. Please change array $aCalendars to your needs before running the script!expandcollapse popup#include <OutlookEX.au3> Global $aCalendars[3] = ["Conf Room ABC", "Conf Room DEF", "Conf Room GHI"] Global $oOL = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) Global $aFolder = _OL_FolderAccess($oOL, "", $olFolderCalendar) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the calendar. @error = " & @error) ; Set the calendar as current folder $oOL.ActiveExplorer.CurrentFolder = $aFolder[1] ; Select multipe calendars ; http://www.slipstick.com/developer/code-samples/select-multiple-calendars-outlook/ ; https://msdn.microsoft.com/en-us/library/ff862232%28v=office.14%29.aspx ; Global $olModuleCalendar = 1 ; A CalendarModule object that represents the Calendar navigation module. ; https://msdn.microsoft.com/en-us/library/ff862746%28v=office.14%29.aspx Global $lMyFoldersGroup = 1 ; Identifies a navigation group that, by default, contains any folders that are part of the local store. $oPane = $oOL.ActiveExplorer.NavigationPane $oModule = $oPane.Modules.GetNavigationModule($olModuleCalendar) With $oModule.NavigationGroups $oGroup = .GetDefaultNavigationGroup($lMyFoldersGroup) ; Default navigation group ; $oGroup = .Item("Name of the navigation group") EndWith For $i = 1 To $oGroup.NavigationFolders.Count $oNavFolder = $oGroup.NavigationFolders.Item($i) $sFolderName = $oNavFolder.DisplayName For $j = 0 To UBound($aCalendars, 1) - 1 If $aCalendars[$j] = $sFolderName Then $oNavFolder.IsSelected = True ; Set to True to open side by side $oNavFolder.IsSideBySide = True EndIf Next Next My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
monarch684 Posted January 5, 2016 Author Share Posted January 5, 2016 I tried the above. It did change the view to calendar but did not select the calendars. I get no errors. Should I enter the name I have for the Conf Rooms or what it has in the Outlook address book. Link to comment Share on other sites More sharing options...
water Posted January 5, 2016 Share Posted January 5, 2016 Did you modify the array? You need to enter the displayname as seen in the navigation folder.Are your calendars in the default navigation group? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
monarch684 Posted January 5, 2016 Author Share Posted January 5, 2016 Then are not in the default group. They are in a group called Rooms. Link to comment Share on other sites More sharing options...
water Posted January 5, 2016 Share Posted January 5, 2016 Then please try this version. Changed lines are marked with "; <== changed"Global $aCalendars[3] = ["Conf Room ABC", "Conf Room DEF", "Conf Room GHI"] Global $oOL = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) Global $aFolder = _OL_FolderAccess($oOL, "", $olFolderCalendar) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the calendar. @error = " & @error) ; Set the calendar as current folder $oOL.ActiveExplorer.CurrentFolder = $aFolder[1] ; Select multipe calendars ; http://www.slipstick.com/developer/code-samples/select-multiple-calendars-outlook/ ; https://msdn.microsoft.com/en-us/library/ff862232(v=office.14).aspx ; Global $olModuleCalendar = 1 ; A CalendarModule object that represents the Calendar navigation module. ; https://msdn.microsoft.com/en-us/library/ff862746(v=office.14).aspx Global $lMyFoldersGroup = 1 ; Identifies a navigation group that, by default, contains any folders that are part of the local store. $oPane = $oOL.ActiveExplorer.NavigationPane $oModule = $oPane.Modules.GetNavigationModule($olModuleCalendar) With $oModule.NavigationGroups ; $oGroup = .GetDefaultNavigationGroup($lMyFoldersGroup) ; Default navigation group <== changed $oGroup = .Item("Rooms") ; <== changed EndWith For $i = 1 To $oGroup.NavigationFolders.Count $oNavFolder = $oGroup.NavigationFolders.Item($i) $sFolderName = $oNavFolder.DisplayName For $j = 0 To UBound($aCalendars, 1) - 1 If $aCalendars[$j] = $sFolderName Then $oNavFolder.IsSelected = True ; Set to True to open side by side $oNavFolder.IsSideBySide = True EndIf Next Next My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
monarch684 Posted January 5, 2016 Author Share Posted January 5, 2016 Yay, that worked. Ok so my understanding is, for the total number of rooms we have list I need to change:$aCalendars[3] to $aCalendars[9]As we have 9 rooms and then add the names to the array? Is that correct? Assa Ram Sharma 1 Link to comment Share on other sites More sharing options...
water Posted January 5, 2016 Share Posted January 5, 2016 Correct.If you need your script to be more flexible then it would be easy to import those names from a file. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
monarch684 Posted January 5, 2016 Author Share Posted January 5, 2016 Fortunately, our building cannot accommodate any more rooms. The only this that may change, and not anytime soon, are the names. I am also looking through the msdn site at all the stuff I didn't know. Learning what each thing does. This has opened up another world to me. I am going to try and figure out the other features that I will need but may come back with questions. Very much appreciated. Link to comment Share on other sites More sharing options...
water Posted January 5, 2016 Share Posted January 5, 2016 I will add a few lines so the script will import the room names from a text file. Gives much more flexibility.I will too add some more comments what the script actually does.Changing the date to be displayed should be easy too. Hope to find a way to only display a single day as well. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted January 6, 2016 Share Posted January 6, 2016 (edited) This example should do what you want. Modify the ini file to your needs.CalendarDisplay.au3:expandcollapse popup#include <OutlookEX.au3> ; https://msdn.microsoft.com/en-us/library/ff862746%28v=office.14%29.aspx Global $olMyFoldersGroup = 1 ; Identifies a navigation group that, by default, contains any folders that are part of the local store. ; https://msdn.microsoft.com/en-us/library/bb208063%28v=office.12%29.aspx Global $olCalendarViewDay = 0 ; Displays a single day Global $sIniFile = StringLeft(@ScriptName, StringInStr(@ScriptName, ".") - 1) & ".ini" ; Read Ini-File to retrieve the tool configuration. ; More detailed documentation can be found in the Ini-File Global $sNavigationGroup = IniRead($sIniFile, "Configuration", "NavigationGroup", "Default") Global $sAllRooms = IniRead($sIniFile, "Configuration", "AllRooms", "True") Global $aRooms = IniReadSection($sIniFile, "Rooms") If @error And $sAllRooms <> "True" Then Exit MsgBox($MB_ICONERROR, "Error", 'Section "Rooms" is missing in the Ini-File and "Allrooms" is not set to "True"!') ; Open connection to Outlook Global $oOL = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) ; Access Default calendar folder and display it Global $aFolder = _OL_FolderAccess($oOL, "", $olFolderCalendar) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the calendar. @error = " & @error) $oOL.ActiveExplorer.CurrentFolder = $aFolder[1] ; Select multipe calendars ; http://www.slipstick.com/developer/code-samples/select-multiple-calendars-outlook/ $oPane = $oOL.ActiveExplorer.NavigationPane $oModule = $oPane.Modules.GetNavigationModule($olModuleCalendar) ; Select the Navigation Group to be processed With $oModule.NavigationGroups If $sNavigationGroup = "Default" Then $oGroup = .GetDefaultNavigationGroup($olMyFoldersGroup) ; Default navigation group Else $oGroup = .Item($sNavigationGroup) ; Name of Navigation Group from Ini-File EndIf EndWith ; Process the calendars in the Navigation Group For $i = 1 To $oGroup.NavigationFolders.Count $oNavFolder = $oGroup.NavigationFolders.Item($i) $sFolderName = $oNavFolder.DisplayName If $sAllRooms = "True" Then $oNavFolder.IsSelected = True $oNavFolder.IsSideBySide = True Else For $j = 1 To $aRooms[0][0] If $aRooms[$j][1] = $sFolderName Then $oNavFolder.IsSelected = True $oNavFolder.IsSideBySide = True EndIf Next EndIf Next ; Set the Outlook view ; Obtain a CalendarView object reference for the current calendar view Global $oView = $oOL.ActiveExplorer.CurrentView ; Set the calendar view to show a single day $oView.CalendarViewMode = $olCalendarViewDay ; Goto a specific date $oView.GotoDate("2015-12-31") ; Save the view $oView.Save() ; Activate the Window and minimize the Ribbon AutoItSetOption("WinTitleMatchMode", 2) ; Match any substring in the title $hWnd = WinActivate("Microsoft Outlook") If $hWnd <> 0 Then If WinWaitActive($hWnd, "", 10) > 0 Then ; Wait for 10 seconds for the window to become active $aCtrlPos = ControlGetPos($hWnd, "", "[CLASS:NetUIHWND]") ; Get the position/size of the Ribbon If $aCtrlPos[3] > 100 Then Send("^{F1}") ; Size is between 60 (minimized) and 165 (maximized) EndIf EndIfCalendarDisplay.ini:; Configuration ; ============= ; NavigationGroup: ; Describes the group in the navigation bar to be processed. ; If set to "Default" then the default navigation group will be processed. ; Default: NavigationGroup=Default ; ; AllRooms: ; If set to True all rooms in the specified Navigationgroup will be processed. ; If set to True section "[Rooms]" in the Ini-File will be ignored. ; Default: AllRooms=True [Configuration] NavigationGroup=Default AllRooms=True ; Rooms ; ===== ; Describes the rooms to be processed. Enter the DisplayName of the rooms. ; This section will be ignored if AllRooms=True in section Concnfiguration. ; Example: Room1=Room ABC [Rooms] Room1=Room ABC Edited January 6, 2016 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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