Jump to content
Sign in to follow this  
narciso

Simulation of native MsgBox

Recommended Posts

narciso

Hello again,

I actually need to use MsgBox and get an answer from the user based on what they see on the screen. Unfortunately MsgBox covers some of the data crucial for the decision making process. Guessing that you cannot position MsgBox, have come up with the idea to simulate it with GUI.

1. The first problem I happened on is the size of my GUI that is different than what I want (according to AutoIt Info it is actually wider and higher?!). Of course I can fix it by putting smaller values for the GUICreate finction but it sucks...

2. Second, I would like the GUI to look identical to MsgBox, i.e. no minimize or maximize window option and a disabled cross mark for closing up the window (just like in the native MsgBox).

3. The size of buttons - any standards of heights used by MsgBox?

4. Button positioning - any possibility to automatically center both "Yes" and "No" buttons?

5. Maybe there is still a possibility of positioning a native MsgBox somehow? :) I have temporarily solved the problem by running another script that waits for the MsgBox and then moves it to optimal position on the screen but you can see it being moved and it looks bad :D

Below I am enclosing a piece of the code illustrating my problem. If someone would care to help...

Thanks in advance.

; #################### cut

$msg = MsgBox(36, "Rozliczenia fiskalne", "Czy rozliczenie fiskalne jest OK?", 180) ; my original MsgBox that I want to mimick by GUI

GUICreate("Rozliczenia fiskalne", 227, 126, -1, 385) ;

GUICtrlCreateIcon ("explorer.exe", -8, 10, 10) ; question mark icon

Opt("GUICoordMode", 2)

GUICtrlCreateLabel ("Czy rozliczenie fiskalne jest OK?", 50, 10)

Opt("GUICoordMode", 1)

$yesButton = GUICtrlCreateButton ("Tak", 29, 60, 75, 22)

GUICtrlSetState($yesButton, $GUI_FOCUS)

Opt("GUICoordMode", 2)

$noButton = GUICtrlCreateButton ("Nie", 20, -1)

GUISetState (@SW_SHOW)

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $yesButton

GUISetState (@SW_HIDE)

Run('notepad.exe') ; Will Run/Open Notepad

ExitLoop

Case $msg = $noButton

GUISetState (@SW_HIDE)

MsgBox(0, 'Testing', 'Button 2 was pressed')

ExitLoop

EndSelect

Wend

; #################### cut


Warmly,Narciso

Share this post


Link to post
Share on other sites
MHz

5. Maybe there is still a possibility of positioning a native MsgBox somehow? :) I have temporarily solved the problem by running another script that waits for the MsgBox and then moves it to optimal position on the screen but you can see it being moved and it looks bad :D

SmOke_N and GAFrost did a post in Examples forum for using the Msgbox with another script that works well. Perhaps look at it and judge for yourself if it may serve your need.

http://www.autoitscript.com/forum/index.ph...=32275&st=0

:D

Share this post


Link to post
Share on other sites
narciso

SmOke_N and GAFrost did a post in Examples forum for using the Msgbox with another script that works well. Perhaps look at it and judge for yourself if it may serve your need.

http://www.autoitscript.com/forum/index.ph...=32275&st=0

:D

Hm... actually I cannot understand a line of it. Very weird for me. The mouse cursor looks like being kept heavily busy by the script?! Still no answer to my positioning problems and all.

Thank you anyway for giving it a try :D

Still waiting for some more straight forward solution :)


Warmly,Narciso

Share this post


Link to post
Share on other sites
eltorro

Here is a simple UDF to move a MsgBox.

It is not complicated at all.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.