Wednesday, February 11, 2009

Display clipboard formats

While researching an issue with how different versions of Citrix servers and Citrix clients handle copy pasting between remote and local applications I found myself in need of a little app, which would show me what data formats I have in clipboard right now.

So here goes another utility, which I can't imagine anyone will find usefull.

#define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT 0x0610
#define UNICODE
#include <windows.h>
#define IDI_MYICON 201

int main(void)
{
 wchar_t full[50000];
 wchar_t *index = full;
 wchar_t name[255];
 unsigned int format = 0;

 OpenClipboard(NULL);

 do {
  format = EnumClipboardFormats(format);
  GetClipboardFormatName(format, name, 255);
  index += wsprintf(index, L"%d : %ls\n", format, name);
 } while (format != 0);

 MessageBox(NULL, full, L"Clipboard formats", MB_OK);

 CloseClipboard();
 return 0;
}

The code quite naïvely assumes, that the output buffer won't be longer than 50 000 characters, so in case you have so many formats in clipboard, the code will overflow. :)

For convenience binary version follows clipview.zip (6.8 kB)

If you copy paste for example Excel data into clipboard and run this program, the output will look like this:

List of clipboard format IDs and descriptions

Obligatory thanks to Mark James for creating the amazing Silk icons.

Monday, February 2, 2009

Mplayer Mouse Volume Issue

Before reinstalling my Gentoo, I had this strange issue with my mouse when watching movies in MPlayer. Everytime I clicked my left mouse button, MPlayer would increase volume.

I could easily remap the functionality of mouse in MPlayer not to mess with volume, but whichever value I remapped the functionality to, it always unpaused movies and displayed the annoying volume status over the movie.

I was looking for solution for quite some time, but the problem magically disappeared after re-installation, so I quickly forgot about it. Until yesterday of course :)

Since I have new versions of pretty much everything, I concluded, it will be issue with my configuration and not a bug.

I'm using Microsoft SideWinder mouse

Microsoft SideWinder Mouse

so I decided to dig in the logs to find out, what is going on. dmesg and /var/log weren't very helpful, so I decided to look what's going on in MPlayer.

I started MPlayer in strace

$ strace mplayer movie.ogg 2>&1 | grep input
...
open("/dev/input/js0", O_RDONLY|O_NONBLOCK|O_LARGEFILE) = 3
...

MPlayer was opening some joystick for reading. But I didn't have any joystick plugged in, since I borrowed my gamepad to a friend two days ago.

Heuréka!

Looking in /sys/devices folder, I found out, that Microsoft SideWinder mouse registers itself as mouse device as well as joystick device. Before I unplugged my gamepad, MPlayer was attaching itself to my gamepad at /dev/input/js0 and since I don't have it connected anymore, mouse gets assigned to js0.

With this knowledge, the fix was extremely easy:

echo "input:js-dev=no" >> ~/.mplayer/config

And voilá. Everything works as expected.