At my office, we needed a way to communicate, but have the option of the message waiting until the user has logged on. I wrote this script which uses a shared network drive. Simply pop it in and run it. The script will take care of registering your computer in a Users.ini file, prompting you to provide your name, and allowing you to run it on automatically on login.
When it opens it loads all entries (except yours) into a dropdown list. Upon triggering WIN+S, the send dialog opens. You can pick a person or Broadcast to send to everyone. The message then pops up on their end, triggered by a text file on the shared drive (that way, the message will be there either immediately or when the person logs in). The user then can reply or dismiss. If the message is dismissed, a traytip pops up to alert you that your message was read. You have the option of choosing the notification sound on receiving a message. Finally a log is created of all conversations.
Anyway, I will probably add a 'snooze' function to the recipient GUI to allow them to use the message as a reminder, in the near future. I hope someone will find this useful.
/* ************************************************** **** Network Messenger **** **** VERSION 1.1 **** **** Author: E. Hagood **** **** 7/9/08 **** ************************************************** ABOUT: This program is designed to act as an Instant Messenger, using only a shared network folder instead of a direct TCP/IP connection. When the program begins, it loads all the users of the network into GUI:1's Dropdown box, as provided in the NetworkMessengerUsers.ini file. The method of communication is by text file inside the shared network drive. This way, even if a person is not at a particular computer, the message will be waiting until they are. It then provides a way of replying to the message, or if OK is clicked then it returns a receipt, which is displayed as a Traytip. The user has the option of defining what sound is played, if any, when a message is received. This sound will play intermittently until the user replies or clicks OK. */ #Persistent #SingleInstance Force ;Create Menu Menu, SettingsMenu, Add, &Change Sound Alert, ChangeSound Menu, MyMenuBar, Add, &Settings, :SettingsMenu ;Create Send Gui Gui, Add, Text, vUserText x25 y15 w500 h20 , Gui, Add, DropDownList, vSendTo x136 y40 w220 h200, Gui, Add, Text, x16 y40 w100 h20 , Recipient Gui, Add, Edit, vSendMessage x16 y70 w350 h150 , Gui, Add, Button, gOK x126 y230 w110 h30 , OK Gui, Add, Button, gCancel x256 y230 w100 h30 , Cancel Gui, Add, Checkbox, vBroadcast gSetBroadcast x206 y20 w120 h20, Broadcast Message Gui, Menu, MyMenuBar ;Create Receive Gui Gui, 2:Add, Text, vUserText x25 y15 w500 h20 , Gui, 2:Add, Text, x16 y40 w100 h20 , From Gui, 2:Add, Edit, vSentMessage READONLY x16 y70 w350 h150 , Gui, 2:Add, Button, gReply x126 y230 w110 h30 , Reply Gui, 2:Add, Button, gNoReply x256 y230 w100 h30 , OK Gui, 2:Add, Text, vFrom x126 y40 w240 h20 , Gui, 2:Menu, MyMenuBar ;Set My IP Address\Computer user MyAddress = %A_IPADDRESS1% MyLoginName = %A_Username% ;If Prefs INI file doesn't exist, create one... prompt for startup. ifnotexist,%A_MyDocuments%\NetworkMessenger\NetworkMessengerPrefs.ini { msgbox, This seems to be your first time running this program.`nI will now set myself up for you. Filecreatedir,%A_MyDocuments%\NetworkMessenger\ FileAppend,, %A_MyDocuments%\NetworkMessenger\NetworkMessengerPrefs.ini msgbox, 4,,Would you like a sound to play, when you receive a message? ifmsgbox YES { if MyLoginName <> RoomUser { FileSelectFile,MediaFile,3,C:\WINDOWS\Media,Press Cancel For A System Beep.,Audio (*.wav; *.mp3) if MediaFile = { MediaFile = Beep SoundBeep, 1500, 500 sleep, 500 SoundBeep, 1500, 500 } else { SoundPlay, %MediaFile% sleep, 1000 } } else { msgbox, 4,,Would you like the default sound (Select No For A System Beep)? ifmsgbox YES { MediaFile = %A_ScriptDir%\Sounds\NOTIFY.WAV soundplay,MediaFile Sleep, 1000 } else { MediaFile = Beep SoundBeep, 1500, 500 sleep, 500 SoundBeep, 1500, 500 } } } else MediaFile = OFF msgbox, 4,,Would you like for FPG Network Messenger to startup automatically when you login? ifmsgbox YES FileCreateShortcut, %A_ScriptDir%\NetworkMessenger.exe, %A_Startup%\NetworkMessenger.lnk IniWrite, %MediaFile%, %A_MyDocuments%\NetworkMessenger\NetworkMessengerPrefs.ini, Settings, Sound } ;Get current settings IniRead, MediaFile, %A_MyDocuments%\NetworkMessenger\NetworkMessengerPrefs.ini, Settings, Sound, Beep ;Load Users From INI File boolReadingUsers = False intUserCount = 0 Loop, Read, %A_ScriptDir%\NetworkMessengerUsers.ini { if boolReadingUsers = True { StringLeft, LeftLineChar, A_LoopReadLine, 1 if LeftLineChar = [ break intUserCount += 1 UserArray%intUserCount% = %A_LoopReadLine% } if A_LoopReadLine = [Users] { boolReadingUsers = True } } ;Load Users Into Combobox MyName = Not Found Loop, %intUserCount% { StringSplit, Temp, UserArray%A_Index%, = if Temp2 <> %MyAddress% GuiControl,, SendTo, %Temp1% else MyName = %Temp1% } if MyName = Not Found { InputBox, MyName, FPG Network Messenger, This machine has not been registered yet.`nWhat would you like this machine to be called?,,,,,,,, guest IniWrite, %MyAddress%, %A_ScriptDir%\NetworkMessengerUsers.ini, Users, %MyName% } GuiControl,, Broadcast, 0 GuiControl,, SendTo, Broadcast GuiControl, Choose, SendTo, |1 GuiControl,,Usertext,User: %MyName% @ %MyAddress% GuiControl,2:,Usertext,User: %MyName% @ %MyAddress% ;Display splash to allow user to see their info SplashTextOn, 250, 150, FPG Network Messenger, Initializing...`nPress Win + S To Send A Message`nTo Anyone In The Network.`n`nUser Name: %MyLoginName%`nIP Address: %MyAddress%`nSender Name: %MyName% Sleep, 2000 SplashTextOff ;Now we will begin looking for a message file boolShowingMessage = False Loop { intMessageCount = 0 Loop, %A_ScriptDir%\%MyName%*.mgr { Sleep, 200 intMessageCount += 1 MessageList%A_Index% = %A_LoopFileFullPath% } if intMessageCount > 0 boolMessageFound = True Loop { if intMessageCount < %A_Index% break CurrentFile := MessageList%A_Index% FileRead, MessageText, %CurrentFile% StringSplit, temp, CurrentFile, - StringSplit, tempName, temp2,. GuiControl,2:,From,%tempName1% GuiControl,2:,SentMessage,%MessageText% StringLeft, strMessageLeft, MessageText, 5 if strMessageLeft = READ: { TrayTip, Network Messenger: NOTIFICATION, Your Message: %MessageText%`nHas Been Read By %tempName1%. Sleep, 12000 Traytip } else { Gui, 2:Show, x131 y91 h276 w398, Sent Message From %tempName1% WinSet, AlwaysOnTop, On, Sent Message From %tempName1% boolShowingMessage = True } if MediaFile <> Off { if MediaFile = Beep { SoundBeep, 1500, 500 sleep, 500 SoundBeep, 1500, 500 } else { SoundPlay, %MediaFile% } } Sleep, 500 FileDelete, %CurrentFile% Sleep, 500 Counter = 0 Loop { if boolShowingMessage = False { break } else { Counter += 1 if Counter > 25 { Counter = 0 if MediaFile <> Off { if MediaFile = Beep { SoundBeep, 1500, 500 sleep, 500 SoundBeep, 1500, 500 } else { SoundPlay, %MediaFile% } } } } Sleep, 500 } } Sleep, 500 } #S:: ;Display Send Dialog GuiControl,, Broadcast, 0 GuiControl,,SendMessage Guicontrol, Focus,SendMessage Gui, Show, x131 y91 h276 w398, FPG Network Messenger WinSet, AlwaysOnTop, On, FPG Network Messenger Return OK: ;To send a message GuiControlGet, SendTo GuiControlGet, SendMessage SendMessage = [%A_MM%/%A_DD%/%A_YYYY% %A_Hour%:%A_Min%:%A_Sec%] - %SendMessage% if SendTo = Broadcast { Loop, { if A_Index = %intUserCount% break GuiControl, Choose, SendTo, |%A_Index% GuiControlGet, SendTo SendFileName := FindFileName(SendTo, MyName) FileAppend, BROADCAST MESSAGE: %SendMessage%, %SendFileName%.mgr FileAppend, TO:%SendTo%-FROM:%MyName%->`n`tBROADCAST%SendMessage%`n, %A_ScriptDir%\message%A_MM%-%A_DD%-%A_YYYY%.log } } else { SendFileName := FindFileName(SendTo, MyName) FileAppend, %SendMessage%, %SendFileName%.mgr FileAppend, TO:%SendTo%-FROM:%MyName%->`n`t%SendMessage%`n, %A_ScriptDir%\message%A_MM%-%A_DD%-%A_YYYY%.log } GuiControl,, SendMessage, GuiControl,, SendTo, Gui, Hide return Cancel: Gui, Hide return Reply: ;Reply to a sent message GuiControlGet,From GuiControlGet,SentMessage Gui, 2:Hide ifwinexist, Sent Message WinSet, AlwaysOnTop, Off, Sent Message ifwinexist, FPG Network WinSet, AlwaysOnTop, Off, FPG Network InputBox, MyReply, %MyName%'s Reply, Type your reply below.`n`nTo Previous Message:`n%SentMessage%,,,,,, if ErrorLevel <> 1 { MyReply = [%A_MM%/%A_DD%/%A_YYYY% %A_Hour%:%A_Min%:%A_Sec%] - %MyReply% ;msgbox, %MyReply%`n`nPREVIOUS MESSAGE:`n%MessageText%`n%tempName1%-%MyName%.mgr SendFileName := FindFileName(From, MyName) FileAppend, %MyReply%`n`nPREVIOUS MESSAGE:`n%From%:%SentMessage%,%SendFileName%.mgr FileAppend, TO:%From%-FROM:%MyName%->`n`tREPLY: %MyReply%`n, %A_ScriptDir%\message%A_MM%-%A_DD%-%A_YYYY%.log boolShowingMessage = False } else { msgbox, No Reply Sent. Gui, 2:Show, x131 y91 h276 w398 } ifwinexist, Sent Message WinSet, AlwaysOnTop, On, Sent Message ifwinexist, FPG Network WinSet, AlwaysOnTop, On, FPG Network Return NoReply: ;If not replying, send a Read message GuiControlGet,From GuiControlGet,SentMessage SendFileName := FindFileName(From, MyName) FileAppend, READ:%SentMessage%,%SendFileName%.mgr FileAppend, TO:%From%-FROM:%MyName%->`n`tDISMISSED: %SentMessage%`n, %A_ScriptDir%\message%A_MM%-%A_DD%-%A_YYYY%.log boolShowingMessage = False Gui, 2:Hide Return ChangeSound: ifwinexist, Sent Message WinSet, AlwaysOnTop, Off, Sent Message ifwinexist, FPG Network WinSet, AlwaysOnTop, Off, FPG Network msgbox, 4,,Would you like a sound to play, when you receive a message? ifmsgbox YES { if MyLoginName <> RoomUser { FileSelectFile,MediaFile,3,C:\WINDOWS\Media,Press Cancel For A System Beep.,Audio (*.wav; *.mp3) if MediaFile = { MediaFile = Beep SoundBeep, 1500, 500 sleep, 500 SoundBeep, 1500, 500 } else { SoundPlay, %MediaFile% sleep, 1000 } } else { msgbox, 4,,Would you like the default sound (Select No For A System Beep)? ifmsgbox YES { MediaFile = %A_ScriptDir%\Sounds\NOTIFY.WAV soundplay,MediaFile Sleep, 1000 } else { MediaFile = Beep SoundBeep, 1500, 500 sleep, 500 SoundBeep, 1500, 500 } } } else MediaFile = OFF IniWrite, %MediaFile%, %A_MyDocuments%\NetworkMessenger\NetworkMessengerPrefs.ini, Settings, Sound ifwinexist, Sent Message WinSet, AlwaysOnTop, On, Sent Message ifwinexist, FPG Network WinSet, AlwaysOnTop, On, FPG Network SoundPlay, MediaFile Return SetBroadcast: ;if clicked, make DropDown reflect your choice. GuiControlGet,Broadcast if Broadcast = 1 GuiControl, Choose, SendTo, |%intUserCount% else GuiControl, Choose, SendTo, |1 Return FindFileName(To,From) { tempSendFileName = %A_ScriptDir%\%To%-%From% MessageNumber = 1 ifexist %tempSendFileName%.mgr { Loop { ifnotexist, %tempSendFileName%-%MessageNumber%.mgr break else { MessageNumber += 1 } } tempSendFileName = %tempSendFileName%-%MessageNumber% } Return tempSendFileName }
All suggestions and comments are welcome.
ehagood