Sign in to follow this  
Followers 0
optiplex

DllCall, MessageBox?

6 posts in this topic

Hey

Just started with AutoIT scripting :)

Im trying to make a MsgBox using the MessageBox API ( http://msdn.microsoft.com/en-us/library/ms645505(VS.85).aspx )

Heres my code, I want to have a yes and a no button, but this code doesnt work :/

DllCall("user32.dll", "int", "MessageBoxA", "int", 0, "string", "Hey", "string", "Whats up?", "uint", "MB_YESNO")

I tried various things. I do get the messagebox, but not with the yes and no button.

I know u can easily use MsgBox(0, etc...), but I want to do it this way, so I can use the function DllCall for other APIs.

Thanks in advance :)

-optiplex

Share this post


Link to post
Share on other sites



"string" is not one of the "valid types". I'd suggest re-reading that section.

Also using the search feature of the forum could answer many of your questions:

http://www.autoitscript.com/forum/index.ph...st&p=531229


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

"string" is not one of the "valid types". I'd suggest re-reading that section.

Also using the search feature of the forum could answer many of your questions:

http://www.autoitscript.com/forum/index.ph...st&p=531229

Thanks for the reply!

Okay, I got it working, but I dont see why its not working if u use "MB_YESNO" instead of "4" :)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

AutoIt has MsgBox() so clueless ppl like you could create messagebox easily without the headaches of trying to figure out basic programming concepts such as data types and constants. I don't know why you are going against this. Now that AutoIt's MsgBox has parent hwnd parameter too, there's no reason to DllCall that API whatsoever.

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Thanks for the reply!

Okay, I got it working, but I dont see why its not working if u use "MB_YESNO" instead of "4" :)

That MB_YESNO is a constant defined in a C/C++ header file... that isn't defined in AutoIt. For more info, go on Google, and lookup "#define", and you'll see why it's not working the way you think it is.

Share this post


Link to post
Share on other sites

Thanks for the reply!

Okay, I got it working, but I dont see why its not working if u use "MB_YESNO" instead of "4" :)

Well, let's think about this.

1. You pass MB_YESNO as a string, but declare it as a unsigned integer.

2. In order to make things such as that work, you must declare them first:

ie...

Global Const $MB__YESNO = 4

$aVal = DllCall("user32.dll", "int", "MessageBox", "int", 0, "str", "Hey", "str", "Whats up?", "uint", $MB__YESNO)
MsgBox(64, "Info", "Value received from DLL MsgBox = " & $aVal[0])
Note the double underscore, because AutoIt already uses $MB_YESNO as a constant.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0