Category Archives: API

Randomly change the desktop picture in C#

The example Set the Windows desktop picture in C# shows how to display an image on the desktop. This example periodically changes the desktop picture to a randomly selected image file picked from a directory. Note that recent versions of … Continue reading

Posted in API, graphics, image processing, interoperability, system | Tagged , , , , , , , , , , , , , , , | Leave a comment

Set the Windows desktop picture in C#

This example sets the Windows desktop picture much as you can manually in Windows 10. (I can’t guarantee that it will work without any changes in other versions of Windows.) Exactly how you set the desktop picture manually depends on … Continue reading

Posted in API, graphics, interoperability, system | Tagged , , , , , , , , , , , , , , , | Leave a comment

Move a window with a title that matches a pattern in C#

The example Set another application’s size and position in C# uses the FindWindow API function to find a window with a given title. Unfortunately FindWindow only finds the window if the title is an exact match. If you only know … Continue reading

Posted in API, miscellany, regular expressions, system | Tagged , , , , , , , , , , , , | Leave a comment

Tile desktop windows in rows and columns in C#

The example List desktop windows in C# shows how to list the currently running desktop windows. This example uses that technique to fill a ListBox with the titles of those desktop windows. (See the previous example to see how that … Continue reading

Posted in API, miscellany, system | Tagged , , , , , , , , , , , | Leave a comment

Set another application’s size and position in C#

When I write books, there is usually a maximum size that a screen shot can be. I wrote this program to make it easy to set an example program to exactly that size. This program uses the FindWindow API function … Continue reading

Posted in API, miscellany, system | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , | 3 Comments

Find a target window and minimize, maximize, or restore it in C#

This is the first in a series of posts that allow one application to manipulate a target window in another application. Note that this isn’t something that Microsoft really wants you to do. In general one application should not fiddle … Continue reading

Posted in API, miscellany, system | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Simulate mouse movement and clicks in C#

This program uses the mouse_event API function to simulate mouse movement and to simulate a mouse click. The program’s Paint event handler draws some circles around a target point so you can see where it is. // The mouse’s target … Continue reading

Posted in API, miscellany, user interface | Tagged , , , , , , , , , , , , | 1 Comment

Remove the Close button from a form’s system menu in C#

C# doesn’t have a built-in way to manipulate the system menu that appears when you click the upper left corner of a form, but it’s not too hard to use API functions to remove some or all of those buttons. … Continue reading

Posted in API, forms, system | Tagged , , , , , , , , , , | 2 Comments

Close Mozilla Firefox popups in C#

Some browser tools try to block advertising popups, but lately some have been sneaking through on my system so I wrote this program to close Firefox popups when they appear. Start Firefox and create the windows that you want. Then … Continue reading

Posted in API, system | Tagged , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

List desktop windows in C#

This program uses several API functions to list the windows running on the system’s desktop. To make reusing the code easier, I made the key routines static in a static class so you don’t need to instantiate the class to … Continue reading

Posted in API, system | Tagged , , , , , , , , , , | 1 Comment