An opensource automation tool for Windows that automatically interacts with Windows file dialogs to set file paths and trigger file selection.
Author: Meij Racpan
Version: 1.0.0
Windows Dialog Handler is a lightweight command-line utility designed to automate interactions with standard Windows file dialogs (such as "Choose File to Upload" dialogs). It programmatically finds the dialog window, sets the file path in the edit box, and triggers the OK button to automatically select the file. This is useful for legacy projects involving UI automation such as IEDriver and windows UI automation.
- Automated Windows dialog detection and interaction
- Customizable window class and title matching
- Configurable edit box control ID targeting
- Adjustable delay before file path submission
- Support for command-line arguments with sensible defaults
- Console feedback and logging of operations
- Windows operating system
- Visual C++ runtime
- Administrator privileges may be required for some dialog interactions
- Visual Studio 2022 or later with C++ development tools
- Windows SDK 10.0 or later
- Open
WindowsDialogHandler.slnin Visual Studio - Select your desired configuration (Debug or Release) and platform (Win32 or x64)
- Build the solution (Ctrl+Shift+B)
- The executable will be generated in the build output directory
WindowsDialogHandler.exeThis will use the default values:
- Window Class:
#32770 - Window Title:
Choose File to Upload - Edit Box Control ID:
0x47C - File Path:
C:\WorkingFolder\Programming\IE2\ForUpload.txt - Delay:
500milliseconds
WindowsDialogHandler.exe <window_class> <window_title> <edit_box_id> <file_path> <delay_ms>| Argument | Description | Example |
|---|---|---|
window_class |
The class name of the dialog window | #32770 |
window_title |
The title/caption of the dialog window | "Choose File to Upload" |
edit_box_id |
The control ID of the edit box (decimal or hex) | 1148 or 0x47C |
file_path |
The full path to the file to set | "C:\Path\To\File.txt" |
delay_ms |
Delay in milliseconds before setting the file path | 500 |
WindowsDialogHandler.exe #32770 "Choose File to Upload" 1148 "C:\Users\Username\Desktop\document.pdf" 1000-
Window Detection: The tool uses Windows API
FindWindow()to locate the target dialog window based on class name and title. -
Edit Box Identification: Once the window is found, it retrieves the edit box control using
GetDlgItem()with the specified control ID. -
File Path Assignment: The file path is set in the edit box using
SendMessage()with theWM_SETTEXTmessage. -
Delay: An optional delay is applied to ensure the dialog is ready before interaction.
-
Button Click: The OK button is automatically clicked using
SendMessage()with theBM_CLICKmessage to confirm the file selection.
- Language: C++ with Windows API
- Platform: Windows (x86 and x64)
- Target Framework: Win32 Console Application
- Character Set: Unicode
- Ensure the window class and title match exactly
- Check if the dialog is already open when the tool runs
- Verify the edit box control ID is correct
- Use Spy++ (included with Visual Studio) to inspect dialog controls
- The button should use the standard
IDOKidentifier - Some custom dialogs may have different button IDs
To determine the correct parameters for your target dialog:
-
Use Spy++ (included with Visual Studio):
- Launch Spy++
- Use the crosshair tool to select your dialog
- Note the window class and title
- Expand the window to see child controls and their IDs
-
Use Windows Inspector or similar tools to inspect window properties
This project is licensed under the MIT License - see the LICENSE file for details.
The MIT License allows you to use, modify, and distribute this software freely, provided that you include the original copyright notice and license text. You are free to use this code in your personal or commercial projects.
For issues, questions, or contributions, please refer to the project repository.
Windows Dialog Handler - Opensource automation tool by Meij Racpan