Recycle a dialog

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Recycle a dialog

Post by Me_again » Wed Jun 20, 2007 2:12 am

I'm trying to test a loop that re-uses a dialog (with some changes in text), but I get some errors after the first use:

error trying to create dialog: startdialog

ini file in editinifile does not exist
(interesting, there is no ini file in the script)

I'm guessing I'm missing the right dialog reset command, I've tried several without success and would appreciate some help.

This is my test code:

Let>n=0
Let>startcap=Start Here
Label>start
Dialog>startdialog
Caption=%startcap%
Left=300
Top=300
Width=440
Height=140
Label=Enter Something,7,25
Edit=something,120,22,230,
Button=OK,5,50,100,20,1
EndDialog>startdialog

Show>startdialog,result
Goto>login

Label>login
Let>n=n+1
If>startdialog.something=doggy,success
If>n=3,sorry
Let>startcap=Try Again
Goto>start

Label>success
MDL>success
Goto>finish

Label>sorry
MDL>Three tries max


Label>finish

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Wed Jun 20, 2007 11:42 am

You can't load the same dialog twice but you can change the dialog title by using "LibFunc>user32,SetWindowTextA"

I'm using a non-modal dialog in this example.

Code: Select all

Let>n=0

Dialog>startdialog
Caption=Start Here
Left=300
Top=300
Width=440
Height=140
Label=Enter Something,7,25
Edit=something,120,22,230,
Button=OK,5,50,100,20,1
EndDialog>startdialog


Show>startdialog

Label>StartLoop
wait>0.1
GetDialogAction>startdialog,result
If>result=1,login
If>result=2,2
Goto>StartLoop

Label>login
ResetDialogAction>startdialog
Let>n=n+1
If>startdialog.something=doggy,success
If>n=3,sorry

// Change dialog title
Let>startcap=Try Again (Error %n%)
Let>WIN_USEHANDLE=1
GetActiveWindow>hwnd,X,Y
LibFunc>user32,SetWindowTextA,res,hwnd,%startcap%
CloseDialog>startdialog
Show>startdialog
Goto>StartLoop

Label>success
CloseDialog>startdialog
MDL>success
Goto>2

Label>sorry
CloseDialog>startdialog
MDL>Three tries max


Label>2
I hope this helps.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Jun 20, 2007 1:01 pm

Thanks Rain, that's just what I was looking for.

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Wed Jun 20, 2007 2:30 pm

Hi Rain,

I also wanted to say thanks... just added that code to snippets as:
  • change dialog title based on user input
Take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Wed Jun 20, 2007 3:21 pm

No problem :)

I got the code from this topic http://www.mjtnet.com/forum/viewtopic.php?p=11327#11327

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts