Programmatically changing Yahoo Messenger's status Comments (23) | Share Alright, I'd been looking for this stuff for a while. I couldn't find any useful resources on the internet so thought of giving it a try to find out how its actually done. Thought people like me would be interested in knowing.
Seems like we need to setup a custom message in registry and notify yahoo of this change we've made. We need to set the “HKCU\Software\Yahoo\Pager\Profiles\[current user]\Custom Msgs\5” to our new status message and send WM_COMMAND message with wParam set to 392 (write me a mail if you need to know how I figured this out) to the yahoo messenger's main window(see the code snippet below to see how current user is retrieved).
Here is how you can do it in C#(I guess you can figure out the PInvoke declarations)
private void ChangeYahooStatus (string newStatus)
{
// Get the current signed in user
//
RegistryKey keyYahooPager = Registry.CurrentUser.OpenSubKey ("Software\\Yahoo\\Pager");
string sUserName = (string)keyYahooPager.GetValue ("Yahoo! User ID");
keyYahooPager.Close();
System.Diagnostics.Debug.WriteLine ("The currently logged in user is " + sUserName);
// Now open the current user's profile and set the current status message, pass true to
// OpenSubKey to request write access
RegistryKey keyYahooCustomMessages = Registry.CurrentUser.OpenSubKey ("Software\\Yahoo\\Pager\\profiles\\"
+ sUserName + "\\Custom Msgs", true);
// Set the 5th message, seems like yahoo messenger has the functionality to move the newly set
// message up as the first one.
keyYahooCustomMessages.SetValue ("5", newStatus);
keyYahooCustomMessages.Close ();
// We are done setting the value in the registry. We now need to notify y! of this change
//
// Find the yahoo messenger window and sent it the notification
// 0x111: WM_COMMAND
// 0x188: Code 392
IntPtr hWndY = FindWindow ("YahooBuddyMain", null);
System.Diagnostics.Debug.WriteLine ("Find window got: " + hWndY.ToString());
PostMessage (hWndY, 0x111, 0x188, 0);