Jump to content

non-modal message box that won't stop a VBScript


Briandr
 Share

Recommended Posts

Hi,

Could someone offer a code sample for a non-modal message box that won't stop a VBScript? The code below uses SplashTextOn. It can be set not to float above other windows and can be moved. One problem I have with the code is that it cannot be minimized. So can we do something with a message box that (1) won't float above other windows, (2) can be moved, and (3) can be minimzed to the system tray? Ideally I would like to see the msg box if minimized come back up every x number of minutes to remind the user.

;NoFlashSplashTextSource.au3 precomplie

;Complied name = splashtext.exe

AutoItSetOption("TrayIconHide", 1);1 = Hide Icon

If $cmdline[0]=1 then

; close the window

$title= $CmdLine[1]

WinClose($title)

ElseIf $CMDline[0]=2 then

$title= $CmdLine[1]

$message= $CmdLine[2]

$message = StringReplace($message, "^", @LF)

ControlSetText($title,"","Static1", $message)

ElseIf $CmdLine[0]>0 Then

$title= $CmdLine[1]

$message= $CmdLine[2]

$wide = $CmdLine[3]

$high = $CmdLine[4]

$xpos = $CmdLine[5]

$ypos = $CmdLine[6]

$opt = $CmdLine[7]

$fsize = $CmdLine[8]

$fweight = $CmdLine[9]

$message = StringReplace($message, "^", @LF)

WinClose($title)

SplashTextOn($title, $message, $wide, $high, $xpos, $ypos, $opt, "", $fsize, $fweight)

$s_title = $title

; loop till window is closed

While WinExists($title)

Sleep(50)

wend

EndIf

Can this be done with AutoIT? Thank you.

Edited by Briandr
Link to comment
Share on other sites

Could someone offer a code sample for a non-modal message box that won't stop a VBScript?

Someone else on this forum came up with this:

Func _NoHaltMsgBox($code=0, $title = "",$text = "" ,$timeout = 0)
  Run (@AutoItExe & ' /AutoIt3ExecuteLine  "MsgBox(' & $code & ', '''& $title & ''', '''& $text &''',' & $timeout & ')"')
EndFunc

It will throw up a message box that is in a different "thread" so it won't stop your program. Keep in mind that you can't read the return value.

Edited by CPinzone
Gerard J. Pinzonegpinzone AT yahoo.com
Link to comment
Share on other sites

Probably should have mentioned I know little to nothing about AutoIT. The AutoIT script I posted I found online that someone else created.

I did search the forum for ideas on how to do this with GUICreate as was suggested. Either I could not find what I was looking for or if I did it went over my head. Just want to adjust this so the user can minimize, but not close the window. It would also be nice to have the message come back up after x number of minutes.

I will keep looking searching for ideas on using GUICreate.

Link to comment
Share on other sites

Can this be done with AutoIT? Thank you.

Yes, This is just a sample with more than five parameteres BUT you can play with the rest!

#include <GUIConstantsEx.au3>
Global $actionitem
$begin = TimerInit()
$dif = 0
AutoItSetOption("TrayIconHide", 1);1 = Hide Icon
If $cmdline[0] = 1 Then
    $title = $cmdline[1]
    WinClose($title)
ElseIf $cmdline[0] = 2 Then
    $title = $cmdline[1]
    $message = $cmdline[2]
    $message = StringReplace($message, "^", @LF)
    ControlSetText($title, "", "Static1", $message)
ElseIf $cmdline[0] > 5 Then
    $title = $cmdline[1]
    $message = $cmdline[2]
    $wide = $cmdline[3]
    $high = $cmdline[4]
    $xpos = $cmdline[5]
    $ypos = $cmdline[6]
    ;$opt = $cmdline[7]
    ;$fsize = $cmdline[8]
    ;$fweight = $cmdline[9]
    $message = StringReplace($message, "^", @LF)
    $s_title = $title
    _Main()
EndIf
Func _Main()
    GUICreate($title, $wide, $high, $xpos, $ypos)
    GUICtrlCreateLabel($message, -1, -1, 65, 50)
    $actionitem = GUICtrlCreateButton("Action", 165, 5, 55, 20)
    GUISetState()
    While 1
        $dif = TimerDiff($begin)
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $actionitem
                _action()
        EndSelect
        If $dif > 5000 Then
            $begin = TimerInit()
            GUISetState(@SW_RESTORE)
        EndIf
    WEnd
    Exit
EndFunc   ;==>_Main
GUIDelete()
Func _Action()
    MsgBox(0, '', 'Just checking!', 5)
EndFunc   ;==>_Action

If you compiled the script as Progy.exe you can try at the comand prompt:

> Progy Hallo "A message" 400 400 -1 -1

Link to comment
Share on other sites

  • 1 month later...

Hi,

I was not expecting to revisit this issue almost two months later. I like the code suggested by JoHanatCent. Two things that prompted a new reply. Is there a way to code this so the user can minimize, but not close the window? As it stands right now it can be closed. I am assuming if I don't want the button that generates the test message I could just delete the function??

Thanks and happy new year!

Edited by Briandr
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...