Sign in to follow this  
Followers 0
bobbo

Need GUI to function while msgbox is open

10 posts in this topic

My script performs a task on data you give it, then it asks you to correct it if need be before taking the next step.

Ex:

input------->"Fri"------->edit box becomes------->"Friday"

script will prompt "Click yes when everything is correct"

So if I put in "Fri" and the script replied "Sun" I could go and change it to "Friday" and click "Yes" before it continued to the next step.

The problem is that while that prompt is up, none of the other buttons or functions work in the main GUI window... is there any way around this?

The idea is for the user to confirm that the computer is right before it moves on, If I click "No" at the prompt, the script will open up a reference file for me and ask again if I can correct it, or if we should just skip this one and move on to the next entry.

Any ideas?

BTW this script is using Opt("GUIOnEventMode", 1)

Thanks in advance!

Share this post


Link to post
Share on other sites



Please post your code.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi,

You have two ways do it as i see it, 1) Run MsgBox in another script, and 2), open a MsgBox as a child using DllCalls...

1)

Here is the only problemis that you can not return values (i think)..

Func _MsgBox($Type, $Title, $Text, $TimeOut=0)
    Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(' & $Type & ', ''' & $Title & ''', ''' &  $Text & ''', ' &  $TimeOut & ')"')
EndFuncoÝ÷ Ù½¿l    ÝêÞÊ+jzÞ¶ê罩nzÆî·*.q©ç¢Û¬zØ^N)¥ªÚë^­«­¢+ÙÕ¹}5Í  ½á±° ÀÌØí5Í    ½áQåÁ°ÀÌØí5Í  ½áQ¥Ñ±°ÀÌØí5Í    ½áQáаÀÌØíµ¥¹U$ôÀ¤(1½°ÀÌØíµIÐô±±
±° ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½Ðí5ÍÍ  ½àÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°ÀÌØíµ¥¹U$°|(ÅÕ½ÐíÍÑÈÅÕ½Ðì°ÀÌØí5Í ½áQáаÅÕ½ÐíÍÑÈÅÕ½Ðì°ÀÌØí5Í  ½áQ¥Ñ±°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí5Í    ½áQåÁ¤(IÑÕɸÀÌØíµIÑlÁt)¹Õ¹
Edited by MsCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here is an example of usage:

_MsgBox(64, "My Title", "Message", 5)

WinWait("My Title")
$Counter = 0
While WinExists("My Title")
    $Counter += 1
    ConsoleWrite("The script is not paused " & $Counter & @LF)
    Sleep(10)
WEnd

Func _MsgBox($Type, $Title, $Text, $TimeOut=0)
    Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(' & $Type & ', ''' & $Title & ''', ''' &  $Text & ''', ' &  $TimeOut & ')"')
EndFunc
Edited by MsCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Thanks again MsCreatoR! Question here is can I return value here? For example a yes or no prompt.

Say there is a text box that displays a name, and a combo list that has all the states in it.

The script will read a name into the edit box, then will match it to the state it belongs to.

The prompt would come up after each name is read in, saying "ok to continue?" and if the state is wrong, you need to be able to change the value selected in the combo list. The reason the gui script needs to be runnimg is that changing that value should call a function, for example the window title could change to "Modified entry" or something.

-Bobbo

Then you just press yes to move onto the next name. It's verification and correction basically.

Here is an example of usage:

_MsgBox(64, "My Title", "Message", 5)

WinWait("My Title")
$Counter = 0
While WinExists("My Title")
    $Counter += 1
    ConsoleWrite("The script is not paused " & $Counter & @LF)
    Sleep(10)
WEnd

Func _MsgBox($Type, $Title, $Text, $TimeOut=0)
    Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(' & $Type & ', ''' & $Title & ''', ''' &  $Text & ''', ' &  $TimeOut & ')"')
EndFunc

Share this post


Link to post
Share on other sites

The one that doesn't return a value works, but I can't get the other to work... Seems to be waiting for the "my title" window to exist. here is the code:

$val=_MsgBoxDll(64, "My Title", "Message")

WinWait("My Title")
$Counter = 0
While WinExists("My Title")
    $Counter += 1
    ConsoleWrite("return value= "& $val &" And the script is not paused " & $Counter & @LF)
    Sleep(10)
WEnd

Func _MsgBoxDll($MsgBoxType, $MsgBoxTitle, $MsgBoxText, $mainGUI=0)
    Local $mRet = DllCall("user32.dll", "int", "MessageBox", "hwnd", $mainGUI, _
        "str", $MsgBoxText, "str", $MsgBoxTitle, "int", $MsgBoxType)
    Return $mRet[0]
EndFunc

Share this post


Link to post
Share on other sites

Here is the GUI version...

$mygui=guicreate("test")
opt("GUIoneventmode",1)

$yo=GUICtrlCreateButton("Test Click Me",0,0)
guictrlsetonevent(-1,"OpenClick")
guisetstate()
dim $confirm=_msgboxdll(35,"Ready","OK to add to queue?  (Are all the fields accurate?)");adding $mygui as param does not work right

While 1
    Sleep(100)
WEnd

func openclick()
;msgbox(0,"hi","still working")
GUICtrlCreateButton("Still working!",30,30)

EndFunc

Func _MsgBoxDll($MsgBoxType, $MsgBoxTitle, $MsgBoxText, $mainGUI=0)
    Local $mRet = DllCall("user32.dll", "int", "MessageBox", "hwnd", $mainGUI, _
        "str", $MsgBoxText, "str", $MsgBoxTitle, "int", $MsgBoxType)
    Return $mRet[0]
EndFunc

Share this post


Link to post
Share on other sites

Seems to be waiting for the "my title"

No, it seems that DllCalls are stop the script completely until they return..

As workaround, you can use temp files to return values...

$TempFile = @TempDir & '\RetFile.tmp'

_MsgBox(36, "My Title", "Message", 0, $TempFile)

WinWait("My Title")
$Counter = 0
While WinExists("My Title")
    $Counter += 1
    ConsoleWrite("The script is not paused " & $Counter & @LF)
    Sleep(10)
WEnd

If FileExists($TempFile) Then
    MsgBox(0, "", "Returned Value is: " & FileRead($TempFile))
    FileDelete($TempFile)
EndIf

Func _MsgBox($Type, $Title, $Text, $TimeOut=0, $TempFile='RetFile.tmp')
    Run(@AutoItExe & ' /AutoIt3ExecuteLine "FileWrite(''' & $TempFile & ''', MsgBox(' & $Type & ', ''' & _
        $Title & ''', ''' &  $Text & ''', ' &  $TimeOut & '))"')
EndFunc

Or you can build a GUI-MsgBox, and call some main function in the main loop of that custom GUI MsgBox to do what you need while user decide.


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Thanks MsCreatoR!

This script has saved me weeks of tedious work, I really appreciate all of your help I couldn't have done it without you!

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