1

I want to build an app to send programmatically keystrokes to Windows desktop and not to a specified windows. For example if we hit arrows keys then the icons in the desktop are selected... Is it possible?

4

2 回答 2

2

SendInput windows API would do what you want. In fact sending input to a targeted window is a more difficult task. SendInput will send the input to the virtual input queue corresponding to the windows session of the process that is calling this API. The input or keys if you will, will land on whatever desktop that is active and inside that whatever window that is in the foreground.

If the Listview control that shows the desktop icons is the foreground window then the arrow keys you would send would move the selection - otherwise it might move a cursor on a notepad (if notepad is the foreground window). Note: Window that is on top is not necessarily the fore ground window. Look at SetForegroundWindow API to know more about the meaning of a fore ground window.

于 2013-03-29T20:00:19.707 回答
0

You should be able to do this via the LVM_SETITEMPOSITION in the win API. Have a look at the following thread which covers some suggestions already on using this: How can I programmatically manipulate Windows desktop icon locations?

于 2013-03-29T19:41:01.083 回答