I wrote this to marshal my outlook reminders to a different workstation using pidgin's bonjour protocol driver. I need this because I frequently work on a machine other than the one with Outlook installed. This helps me to know when meetings are coming up so I don't miss them.
It's a bit brittle, but hopefully this helps someone. It suffers from the problem that the buddy list can't be brought up from the tray so it has to sit minimized on your task bar for this to work.
Thanks to Cristi® in the forums, whose code I started with to build this.
Code:
#SingleInstance Force
#NoEnv
#Persistent
; AUTHOR: David Esposito
; VERSION: 1.0.0
; DESCRIPTION
; VERSION of Pidgin this works on: 2.4.0
;
; NOTABLE KEYSTROKES
;Win- X Exit Script
;Win- Z Show \ Run Pidgin
;Win- Y - run the check independent of the timer.
;
;
; ENHANCEMENTS DESIRED
; - ability to raise buddy list from the system tray.
PidginChatWindowTitle=david-bree
; This is the title of the window that comes up when you send a
; chat in pidgin. It will change based on how you set your alias
; in pidgin and it's essential that it be right or nothing
; will be sent through.
;
ChatAlias=David-vista@bree
;This ChatAlias seems to be case sensitive. I am using it here with
; the pidgin bonjour protocol to send a message to myself at another
; machine. Since i'm only connected to Bonjour, there is no need to choose
; the account from which to send. However, for simplicity, the script
; uses the built-in lookup feature of
;
; the class number for reminder windows in outlook 2007:
OutlookWindowClass=#32770
; for testing:
; OutlookWindowClass=Notepad
CheckIntervalSeconds=60
GoSub,AutoStartArea
; works to exit everything:
#x::ExitApp
; #Mbutton::
; this works to activate the pidgin buddy list
; GroupActivate, Pidgin, r
; return
; Show Pidgin chat window:
#z::
IfWinExist ahk_class gdkWindowToplevel
{
; this works, but the window has to not be minimized to the tray:
WinActivate
}
else
{
; doesn't work if pidgin is just minimized to tray
Run "C:\Program Files\Pidgin\Pidgin.exe"
}
return
; runs the check once, then sets timer to run it every minute
#y::
GoSub,WatchForReminder
return
; #u::
; gosub,DavidJunk
; return
DavidJunk:
; gives 1280x1024
OutputDebug,%A_ScreenWidth%
OutputDebug,%A_ScreenHeight%
return
ClosePidginGui:
Gui,Destroy
return
; runs every minute triggered by timer
WatchForReminder:
BuddyWindowAvailable:=0
Gosub,CheckBuddyWindowAvailable
If(BuddyWindowAvailable=0)
return
IfWinNotExist,ahk_class %OutlookWindowClass%
return
SplashTextOn,,,Found outlook reminders
; wait for someone working there to pause and stop typing before
; continuing
; BlockInput On
Sleep 3000
WinWait,ahk_class %OutlookWindowClass%
WinActivate
GoSub,OpenAndCopySubject
; this works, but the window has to not be minimized to the tray:
GroupActivate, Pidgin, r
Send ^m
WinWait,Pidgin
SendInput %ChatAlias%
sleep 200 ; waits for auto lookup to run and then chooses
; what has been looked up.
send {Down}{Enter}{Tab}{Tab}{Enter}
; strangely, the above final "enter" gets sent to the next chat window
; too, fortunatly, this is harmless
WinWait,%PidginChatWindowTitle%,,5
if(ErrorLevel=1)
{
OutputDebug,Failed to find chat window by title: %PidginChatWindowTitle%
return
}
WinActivate
; ControlSend,GdkWindowChild3,Check reminder in outlook`n
Send Check reminder in outlook`n
SendInput Subject: %AppointmentSubject%{!}{Enter}
; for testing
; MsgBox,Is output ok?
WinMinimize,%PidginChatWindowTitle%
WinMinimize,ahk_class gdkWindowToplevel
SplashTextOff
sleep 1000
; can't close right away or message doesn't go
WinClose,%PidginChatWindowTitle%
; BlockInput Off
; minimize the buddy list:
return
CheckBuddyWindowAvailable:
BuddyWindowAvailable:=0
; do nothing if buddy list is available:
IfWinExist,ahk_class gdkWindowToplevel
{
BuddyWindowAvailable:=1
return
}
; notify of problem
Gui,Add,Text,gClosePidginGui,
(LTrim
Please open your Pidgin buddy list
(can be minimized).
This message will stop appearing when the Pidgin
buddy list is available (not just in the system tray).
)
Gui,Show
return
OpenAndCopySubject:
SendInput !o
SetTitleMatchMode,RegEx
WinWait,.*Appointment ahk_class rctrl_renwnd32,,10
SetTitleMatchMode,Fast
if(ErrorLevel=0)
{
SetTitleMatchMode,Slow
ControlGetText,AppointmentSubject,RichEdit20WPT6
SetTitleMatchMode,Fast
; select and copy subject
; SendInput !u^a^c
WinClose
; MsgBox % AppointmentSubject
}
return
; click and open buddy list:
;
; 13-mar - can't get this to work, the image doesn't seem to be found in
; the taskbar. Maybe there's a programmatic way to navigate the taskbar.
; from .NET or something.
;
CheckTrayForPidginBuddyList:
; do nothing if buddy list is available:
IfWinExist,ahk_class gdkWindowToplevel
return
; Check that pidgin buddy list is available because if it's
; not, the user should know so she can fix it. Otherwise
; no messages will be sent through.
TrayOnline=C:\Program Files\Pidgin\pixmaps\pidgin\tray\16\tray-online.png
TrayNew=C:\Program Files\Pidgin\pixmaps\pidgin\tray\16\tray-new-im.png
TrayAway=C:\Program Files\Pidgin\pixmaps\pidgin\tray\16\tray-away.png
CoordMode,Pixel,Screen
CoordMode,Mouse,Screen
; make a faster search by assuming
; tray is lower right and not higher than 100 pixels:
StartHeight:=A_ScreenHeight-100
ImageSearch,FoundX, FoundY, 100,StartHeight,A_ScreenWidth,A_ScreenHeight
,*Trans0xFFFFFF *w16 *h16 %TrayOnline%
if ErrorLevel=0
{
FoundX:=(FoundX+5)
FoundY:=(FoundY+5)
Click,Left,%FoundX%,%FoundY%,2
}
else
{
; notify of problem
Gui,Add,Text,gClosePidginGui,
(LTrim
Please open your Pidgin buddy list
(can be minimized).
This message will stop appearing when the Pidgin
buddy list is available (not just in the system tray).
)
Gui,Show
}
CoordMode,Pixel,Relative
CoordMode,Mouse,Relative
return
;; set some variables and start timer
AutoStartArea:
Menu, Tray, Icon, C:\Program Files\Pidgin\Pidgin.exe
Menu, Tray, Standard
Menu, Tray, Tip, Pidgin Script 1.0
GroupAdd, Pidgin, ahk_class gdkWindowToplevel ; Group Pidgin Windows
; when this script is auto-started, go right into timer mode:
; check every minute:
GoSub,WatchForReminder
SetTimer,WatchForReminder,% CheckIntervalSeconds*1000
; end of auto-execute section:
return