Tbh this is something I've had problems with for a WHILE now. It's really annoying that there's no native way for this :(
Well first we'll have to write an empty "output" array for the OS.execute() to fill
var output = []
after which, we have to execute the powershell script to display said MessageBox
OS.execute("powershell.exe", ["-Command", "Add-Type -AssemblyName PresentationFramework;[System.Windows.MessageBox]::Show('Body', 'Title', '3','16')"], output)
let me explain with the little knowledge I have of powershell...
"-Command"
opens powershell with the intent to execute code.
"Add-Type -AssemblyName PresentationFramework;[System.Windows.MessageBox]
creates everything that's needed to actually use the messagebox.
::show
is the messagebox's argument to actually show itself...
and for the arguments within show, I recommend looking at THIS <- Click Webpage, It explains everything pretty well :D
after it has been opened, we need to actually check what the user has clicked, which is where the afformentioned "output" variable comes in.
if we check output by printing it after
print(output)
we can see that output[0] contains either Yes\r\n
, No\r\n
, or Cancel\r\n
the \r and \n are escape characters, don't worry about it, that shouldn't change anyway.
\r is Carriage return and \n is Newline.
anyway, after that we can match output[0] like so:
match output[0]:
"Yes\r\n":
print("The user has ACCEPTED the Prompt")
"No\r\n":
print("The user has DECLINED the Prompt")
"Cancel\r\n":
print("The user has CANCELED the Prompt")
and there's your itty bitty textbox :3
5 comments