The working V2 code I have included, opens Outlook if it is not open or activates the Outlook window if it is already running (on the email screen). Then it resizes the Window and centers, CenterWindow(ctrwin), the Outlook Window accounting for the Task Bar area.
The use of WinText seems like a good choice which would prevent, multiple instances of Outlook being started when the running instance of Outlook is on the calendar or contacts screen.
The code below does work, but I must define the full Window Title in the variable MyEmail. It would be easier to simply say is Outlook running? Which may be harder than I think.
Bug: The current code opens a new instance of Outlook if the current instance is on the calendar or contact screens.
What I would like to do is something like:
if !WinExist(MyEmail, "Outlook")
Which I think should say is does a Window with "Outlook" in its title exist? I can't seem to get this to work.
I attempted
if !WinExist(Instr(MyEmail, "Outlook")) without success.
By using WinText it seems that I could eliminate the MyEmail variable entirely.
Thanks, CraigM
Code: Select all
^o:: ; ^ Ctrl o
{
;Check to see if Outlook is running or start it and wait for it to load,
;then resize if and center it afterwhich increase the size of the text
;in the preview reading pane.
MyEmail := "Inbox - [email protected] - Outlook"
if !WinExist(MyEmail)
{
Run "C:\Program Files\Microsoft Office\root\Office16\Outlook.exe"
WinWaitActive MyEmail ;, "Outlook"
}
Else
{
If Instr(MyEmail, "Outlook") ;Make sure it is Outlook
{
WinActivate ;Use the window found by WinExist.
}
}
WinWaitActive MyEmail
WinMove , , 2830, 1750 ;Resize the Outlook window before centering it
CenterWindow(MyEmail) ;Center the Outlook Window
;Move the Outlook cursor and magnify the reading pane.
WinGetPos &X, &Y, &WinWidth, &WinHeight, MyEmail
MouseClick "Left", WinWidth - 251, WinHeight - 41, 7 ;Ensure the the reading pane is at normal zoom
MouseClick "Left", WinWidth - 250, WinHeight - 41, 3 ;Zoom in three clicks
}
; End of ^o - open and center the Outlook window
;CenterWindow (ctrwin) Centers the passed window on the screen,
;less the area taken up by the Task Bar
CenterWindow(ctrwin)
{
MonitorGetWorkArea , &WLeft, &WTop, &WRight, &WBottom ;Actual Area - Task Bar
WinGetPos , , &WinWidth, &WinHeight, ctrwin
WinMove ((WRight - WinWidth)/2), ((WBottom - WinHeight)/2)
}