Sign in to follow this  
Followers 0
dm83737

Changing the position of a Msgbox

13 posts in this topic

Is it possible to set a different position for a MsgBox to something other than the center of the screen?

The reason I ask is that I have to wait for the screen to show information and the duration of the wait is fairly random according to server load. When the information finally comes onto the screen, the MsgBox gets put under the main window which keeps it from being clicked by the user.

I am pretty new to AutoIT (about a week), and am not a very strong troubleshooter yet. But I have noticed that the main program we use does not register any information on the AutoIT Window Info program other than the Title and the Handle (see attachment), and AutoIT seems to have some issues recognizing if windows pop up within this application or not. I think I have heard that this program is built using JAVA or something to that effect, and I have looked around at the JAVA posts, but don't really understand what they are saying as

a ) I am a noob and therefore am not really sure which direction to go in, and

b ) I don't think they apply to me as this application is not a website, it is stand-alone.

But that may be fodder for another post.

So to summarize, my questions are:

1) Can you change the position (x-y coordinates) of a MsgBox?

2) How do I get AutoIT to interact with our program effectively?

post-45921-1234381500_thumb.jpg

Share this post


Link to post
Share on other sites



Sorry DaRam, but since I am a stupid new guy to this application and scripting format, what do I do with this huge bunch of script?

I tried messing with what this post says in the initial entry and AutoIT keeps return syntax errors. I have never been a big fan of "Look here [LINK]" responses as I believe more in a teaching-type method; sharing the knowledge cuts down on people like me who end up asking multiple questions. So if you or someone else who has a bit more time than DaRam could explain this out to me or point me to an in-depth explanation, I would really appreciate it.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

dm83737,

The short answer to your MsgBox question is: No.

The longer answer (and this goes some way to explaining DaRam's response) is that this question has been posed so many times on these forums that a simple search would throw up many examples of code which enable you to do this. Most of the regular posters here who offer help prefer it when someone has made a bit of an effort themselves first - i.e. looked at some code and tried to produce something that might work.

So, I suggest that is what you do. I, and no doubt many others, will be happy to help you when you have problems - but do try and code something yourself before coming back. Posting a chunk of script, even if it does not work, with a question is a pretty good way to get a positive answer - asking us to write code for you is almost guaranteed not to!

M23

P.S. By the way, the first of those links is an excellent function to move a message box! Is there something about it you do not understand?

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hi guys, I'm a newbie in Autoit too.. I was introduced to it 4 days ago and since then ive started coding my project in it..

Now the problem is, that when i tried the script mentioned in this:

I got a msgbox with the Title : de

and text: 10297

Any Clues?!

oh and yes i've got the same question as 837's

Share this post


Link to post
Share on other sites

Never say never!

#include <Constants.au3>
#include <WinAPI.au3>

Global $MsgBoxX = 20
Global $MsgBoxY = 20

Local $hProcMsgBox = DllCallbackRegister("CbtHookProcMsgBox", "int", "int;int;int")
Local $TIDMsgBox = _WinAPI_GetCurrentThreadId()
Local $hHookMsgBox = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($hProcMsgBox), 0, $TIDMsgBox)

Local $iRet = MsgBox(34, "Select example", "Please select the skin you want to try")
$MsgBoxX = 120
Local $iRet = MsgBox(34, "Select example", "Please select the skin you want to try")
$MsgBoxX = 220
Local $iRet = MsgBox(34, "Select example", "Please select the skin you want to try")

_WinAPI_UnhookWindowsHookEx($hHookMsgBox)
DllCallbackFree($hProcMsgBox)


#region Just for fun!!
;##########################################################
Func CbtHookProcMsgBox($nCode, $wParam, $lParam)
    Local $RET = 0
    If $nCode < 0 Then
        $RET = _WinAPI_CallNextHookEx($hHookMsgBox, $nCode, $wParam, $lParam)
        Return $RET
    EndIf
    Switch $nCode
        Case 5 ;5=HCBT_ACTIVATE
            _WinAPI_SetDlgItemText($wParam, 3, "1")
            _WinAPI_SetDlgItemText($wParam, 4, "2")
            _WinAPI_SetDlgItemText($wParam, 5, "3")
            _WinAPI_SetWindowPos($wParam, $HWND_TOP, $MsgBoxX, $MsgBoxY, _WinAPI_GetWindowWidth($wParam), _WinAPI_GetWindowHeight($wParam), $SWP_NOZORDER)
    EndSwitch
    Return
EndFunc   ;==>CbtHookProcMsgBox

Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString)
    Local $aRet = DllCall('user32.dll', "int", "SetDlgItemText", _
            "hwnd", $hDlg, _
            "int", $nIDDlgItem, _
            "str", $lpString)
    Return $aRet[0]
EndFunc   ;==>_WinAPI_SetDlgItemText

;##########################################################
#endregion Just for fun!!

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

just out of curiosity could you create the msgbox then use WinMove() to change its location the second its created?? it seams like it would work but i dont have a way to test it :mellow:

never mind, i forgot that msgbox() was a blocking function so that would not work :)

Edited by pieeater

[spoiler]My UDFs: Login UDF[/spoiler]

Share this post


Link to post
Share on other sites

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

dm83737, if I understand your question correctly, everyone has been pointing you in the wrong direction. You want to move a message box from another application, right? Others here are talking about moving the built-in message box in AutoIt.

Try this code:

While 1
WinWaitActive("The ADMINISTRATOR")
WinMove("The ADMINISTRATOR", "", 10, 10)
WEnd

#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

dm83737, if I understand your question correctly, everyone has been pointing you in the wrong direction. You want to move a message box from another application, right? Others here are talking about moving the built-in message box in AutoIt.

Try this code:

While 1
WinWaitActive("The ADMINISTRATOR")
WinMove("The ADMINISTRATOR", "", 10, 10)
WEnd

Suddenly the fears are gone and the clarity enlighten their hearts and minds... :mellow:

Share this post


Link to post
Share on other sites

@monoscout999: dm83737 startet this thread in 2009! I saw it after posting and editing didn't work!

And XORGate posted after about two and a half years later. And he definitly wants to reposition an own MsgBox.

Greetings :mellow:

1 person likes this

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

Oh wow, I didn't notice this was a thread resurrected from 2009. DOH!


#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

:) well you got us...

This seems to work fine

1. Look here #624872

Maybe MRCreator can throw us some light here and explain his tricks :mellow:

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