Archive: Winmessages keystroke


Winmessages keystroke
Is there a way to send a window a specific keystroke using winmessages?

If not, then is there a way to get an "ok" button clicked?

I have been searching and cannot find much documentation (except in the case of closing a window), my ultimate goal is to keep selecting next (and a few radio buttons) on the "search the net for newer drivers" win XP system popup when a USB cable is inserted.

Basically I can get the class name of the window using win32 spy, but I'm unsure how to use the other paramaters of the findwindow and sendmessage commands. I also am totally lost with GetDlgItem, and do not know if I even need it (I have read the documentation, and still do not get it). Can someone please explain how to do this?

Thanks


${WM_KEYDOWN} (from WinMessages.nsh) is probably what you need. However, I'm not 100% sure of the syntax--you may need to exeriment with it. This MSDN article may help.

And I'm not sure about whether you'd need to use GetDlgItem or just FindWindow. (My guess is that the Window itself is what responds to keystrokes, so you'd probably just need to use FindWindow.)

The only thing I'd caution on is the fact that by sending keystrokes a window, you assume that the window is the same all the time. There could be that one time where the dialog is slightly different (becuase of a different serive pack, optional software, etc.) If you are not careful, you could end up sending the user down a totally different path than you indended.


Thanks for your reply. I tried a bunch of differant things with it, and nothing seemed to work. I ended up just writing a C applet that I can call from NSIS that will send the specified keystrokes. And yes, the problem with this, is if for some reason the user window is differant, which leads me to my next question.

Is there any way to, knowing the name of the hardware device, check to see that it is installed? Of course I will also be testing my code with every SP of XP (since it only needs to run on XP) but it would also be nice as a just in case factor to check to make sure it's installed. If for some reason it's not installed, I'll have to prompt the user to do a manual installation. Hopefully there is a way to do this, but I again cannot find it.


This is the code you want to click Next I think:

SendMessage $HWNDPARENT ${WM_NOTIFY_OUTER_NEXT} 1 0

Haven't tried it, but it's what InstallOptions uses for Notify buttons.

-Stu


Alright, Tested my C applet, and it's pretty stable.

Definatly my problem now would be trying to detect if a device is installed. My particular device i called "USB superlink adapter". It seems like you should be able to use the system plugin to call something in windows that will tell you if this device is installed on the system...but I can't find anything like it. Any ideas?