Jump to content

Msgbox In The Background


Recommended Posts

You may need to be more specific.

Or post some code. Are you trying to ControlFocus? Do you want to get text from a MsgBox that appeared? Most tools in Autoit can "get" a window anywhere. Msgbox or no. Some options may not be able to send data properly without a window having focus, but getting itsn't so much an issue. Show some code and we can probably help... Or describe your problem a little better, or hope someone with psychic powers comes on after me (it's possible).

"I have discovered that all human evil comes from this, man's being unable to sit still in a room. " - Blaise Pascal
Link to comment
Share on other sites

Sorry, my english is not the best :-S I understand everything but my writing really sucks.

Okay i try to be more specific.

I have create a little application which does something for me. If the work for this little application is complet successfully it displays a little msgbox

MsgBox(0,"Successfully","DONE!!!")

Now if i am working on the system and typing some text the message box is a little bit disturbing. Because i'm blocked in my writing. That's the reason i don't want that the message box is come in the front. I wan't it displayed in the tasklist but behind my active window with no focus.

Hope this is more understandable

Regards,

CoDeX2k

Link to comment
Share on other sites

Sorry, my english is not the best :-S I understand everything but my writing really sucks.

Okay i try to be more specific.

I have create a little application which does something for me. If the work for this little application is complet successfully it displays a little msgbox

MsgBox(0,"Successfully","DONE!!!")

Now if i am working on the system and typing some text the message box is a little bit disturbing. Because i'm blocked in my writing. That's the reason i don't want that the message box is come in the front. I wan't it displayed in the tasklist but behind my active window with no focus.

Hope this is more understandable

Regards,

CoDeX2k

You can have the Messagebox close after a certain time...

MsgBox ( flag, "title", "text" [, timeout] )

Timeout is in seconds.

So yours would be..

MsgBox(0,"Successfully","DONE!!!",10)

Is that what you want?

Edited by Lakes

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

AUT_RESULT AutoIt_Script::F_MsgBox(VectorVariant &vParams, Variant &vResult)
{
    if (vParams.size() == 4)
        vResult = Util_MessageBoxEx(NULL, vParams[2].szValue(), vParams[1].szValue(), (UINT)vParams[0].nValue() | MB_SETFOREGROUND, vParams[3].nValue() * 1000);
    else
        vResult = MessageBox(NULL, vParams[2].szValue(), vParams[1].szValue(), (UINT)vParams[0].nValue() | MB_SETFOREGROUND);
    return AUT_OK;

} // F_MsgBox()

If I interpret the above snippet of AutoIt source code correctly, MsgBoxes displayed by AutoIt will always be in the foreground because MB_SETFOREGROUND is included with the flags.

#)

Link to comment
Share on other sites

AUT_RESULT AutoIt_Script::F_MsgBox(VectorVariant &vParams, Variant &vResult)
{
    if (vParams.size() == 4)
        vResult = Util_MessageBoxEx(NULL, vParams[2].szValue(), vParams[1].szValue(), (UINT)vParams[0].nValue() | MB_SETFOREGROUND, vParams[3].nValue() * 1000);
    else
        vResult = MessageBox(NULL, vParams[2].szValue(), vParams[1].szValue(), (UINT)vParams[0].nValue() | MB_SETFOREGROUND);
    return AUT_OK;

} // F_MsgBox()

If I interpret the above snippet of AutoIt source code correctly, MsgBoxes displayed by AutoIt will always be in the foreground because MB_SETFOREGROUND is included with the flags.

#)

I don`t understand why anyone would want to have a hidden messagebox, really...

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

Alternately you could just use a ballon traytip to advise when your background process completed.

HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Link to comment
Share on other sites

That's what if done know =) hehe. It's the easiest way.

Thanks for helping guys.

Regards,

CoDeX2k

Here's a test for a GUI pop-up that does not steal focus (actually it does, but puts it back in milliseconds):

; Test pop-up that is not always on top
#include <GuiConstants.au3>

$GuiHandle = GUICreate("Successfully", 200, 50, 75, 75)
$Label_1 = GUICtrlCreateLabel("DONE!!!", 10, 10, 180, 30)

; Allow tester time to switch focus to a different window
Sleep(5000)

$CurrentWin = WinGetTitle("")
GUISetState()
WinActivate($CurrentWin)

While 1
    $GuiMsg = GUIGetMsg()
    If $GuiMsg = $GUI_EVENT_CLOSE Then Exit
WEnd
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Here's a test for a GUI pop-up that does not steal focus (actually it does, but puts it back in milliseconds):

; Test pop-up that is not always on top
#include <GuiConstants.au3>

$GuiHandle = GUICreate("Successfully", 200, 50, 75, 75)
$Label_1 = GUICtrlCreateLabel("DONE!!!", 10, 10, 180, 30)

; Allow tester time to switch focus to a different window
Sleep(5000)

$CurrentWin = WinGetTitle("")
GUISetState()
WinActivate($CurrentWin)

While 1
    $GuiMsg = GUIGetMsg()
    If $GuiMsg = $GUI_EVENT_CLOSE Then Exit
WEnd
It took me a whle to find this again, anyway have a look at this thread...

http://www.autoitscript.com/forum/index.ph...topic=14658&hl=

Edited by Lakes

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

This does not steal focus

$handle = GUICreate('MsgBox', 200, 70, 0, 0)
GUICtrlCreateLabel('Text here', 20, 10)
$button = GUICtrlCreateButton('OK', 70, 40, 60, 20)
GUISetState(@SW_SHOWNA)
While WinExists($handle)
    $msg = GUIGetMsg()
    If $msg = -3 Or $msg = $button Then Exit
WEnd

Edit:

Modded some more

_MsgBoxOKOnly('Title of Custom MsgBox', 'Text is added here')

Func _MsgBoxOKOnly($title, $text = '', $state = @SW_SHOWNA)
    Local $button, $handle, $msg
    Local Const $WS_DLGFRAME = 0x00400000
    $handle = GUICreate($title, 300, 95, 0, 0, $WS_DLGFRAME)
    GUICtrlCreateLabel($text, 20, 10)
    $button = GUICtrlCreateButton('OK', 110, 40, 80, 20)
    GUISetState($state)
    WinFlash($handle)
    While WinExists($handle)
        $msg = GUIGetMsg()
        If $msg = $button Then
            Return 1
        EndIf
    WEnd
EndFunc
Edited by MHz
Link to comment
Share on other sites

This does not steal focus

Edit:

Modded some more

_MsgBoxOKOnly('Title of Custom MsgBox', 'Text is added here')

Func _MsgBoxOKOnly($title, $text = '', $state = @SW_SHOWNA)
    Local $button, $handle, $msg
    Local Const $WS_DLGFRAME = 0x00400000
    $handle = GUICreate($title, 300, 95, 0, 0, $WS_DLGFRAME)
    GUICtrlCreateLabel($text, 20, 10)
    $button = GUICtrlCreateButton('OK', 110, 40, 80, 20)
    GUISetState($state)
    WinFlash($handle)
    While WinExists($handle)
        $msg = GUIGetMsg()
        If $msg = $button Then
            Return 1
        EndIf
    WEnd
EndFunc
:( Ooooh... I like yours much better! :)

"Learn something new every day." I just learned @SW_SHOWNA and WinFlash() -- I get to go home now... :think:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...