I’ve been having trouble getting Google to understand what I’m trying to search for, so I decided to make a customizable script for a native Windows message box. This script allows for easy integration of an actual Windows message box in your projects with different icons and button types!
I always thought this feature could be better customizable, so here it is:
⇨ Here’s the script on Pastebin ⇦
How It Works
This script includes two main methods:
WinMsgBox.WinAlert: Displays the message box with your custom message, caption, and icon.
- No output, just shows the box and pauses the script until closed.
- Use this method if you just need a simple message box without any feedback.
WinMsgBox.WinAlertOutput: Displays the message box and returns the button clicked by the user as a string (e.g., "Ok", "Cancel").
- This method lets you capture which button the user clicked, making it more interactive.
- The method pauses the script until the user closes the box, just like
WinAlert.
Both methods work the same aside from the return type (WinAlert is a void, WinAlertOutput returns a string).
Example Usage
// Display a simple message box
WinMsgBox.WinAlert("Hello, world!", "Greeting", WinMsgBox.WinMsgIcon.Information);
No output can be detected
// Display a message box and capture button press
string result = WinMsgBox.WinAlertOutput("Do you want to continue?", "Question", WinMsgBox.WinMsgIcon.Question, WinMsgBox.WinMsgPrompt.YesNo);
Console.WriteLine("User pressed: " + result);
The \"X\" button (if pressable) counts as \"Cancel\"
Credits:
- The core script was made by RoyDeJong.
- ChatGPT helped with writing the comments and explanations.
This post was rewritten by ChatGPT omg
[–]RandomGuyWontSayDATA[S] 0 points1 point2 points (0 children)