Programmatically changing Yahoo Messenger's status

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);

}

This article is part of the GWB Archives. Original Author: Uday K Verma

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.