Dialog box redefinition

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
JRL
Automation Wizard
Posts: 3531
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Dialog box redefinition

Post by JRL » Wed Apr 20, 2005 7:03 pm

Why will this not work? (Abbreviated for clarity)

Let>x=0
Label>start
Let>x=x+1
Dialog>dialog%x%
//dialog stuff
EndDialog>dialog%x%

show>dialog%x%

Label>Actionloop
GetDialogAction>dialog%x%,r
//result stuff
If>r=5,start
If>r=6,end
Goto>Actionloop

Label>end

When I try this I get the message:
Error - ENDDLG For DLG dialog%x% Not Found!

The dialog has an end. There are no trailing spaces. All works just fine for one shot if I use "dialog1" as my dialog name. I was hoping to be able to repeat and use preassigned variables as parameters to define my dialog. Otherwise, as you know, once a dialog is defined within a script it is unalterable. Changing the value of a variable used to define parameters within the dialog will not alter the displayed dialog box in subsequent "shows". If the dialog name could include an incremented variable, then each subsequent "show" could be a distinct and therefore updated dialog box.

Hope this makes sense.

Thank you for a great product and spectacular support,
Dick.

User avatar
JRL
Automation Wizard
Posts: 3531
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Apr 25, 2005 5:07 am

Edit-1 Sept. 3,2005
A better example of what I'm trying to convey:


DeleteFile>c:\~dialog~.scp
Let>Wide=500
Let>High=300
Let>Xloc=200
Let>Yloc=100
Dialog>Dialog1
Caption=Repeating redefining dialog
Top=%Yloc%
Width=%Wide%
Left=%Xloc%
Height=%High%
Label=Width of window,104,40
Label=Height of window,104,120
Label=X location of window,280,40
Label=Y location of window,280,120
Button=OK,16,8,75,25,5
Button=Cancel,16,48,75,25,2
Edit=Edit1,104,8,121,%Wide%
Edit=Edit2,104,88,121,%High%
Edit=Edit3,280,8,121,%Xloc%
Edit=Edit4,280,88,121,%Yloc%
EndDialog>Dialog1

Show>Dialog1,r
CloseDialog>Dialog1
Let>Wide=Dialog1.Edit1
Let>High=Dialog1.Edit2
Let>Xloc=Dialog1.Edit3
Let>Yloc=Dialog1.Edit4
if>r=5,Process
if>r=2,exit

Label>Process
Writeln>c:\~dialog~.scp,result,Dialog>Dialog2
Writeln>c:\~dialog~.scp,result,Caption=Repeating redefining dialog
Writeln>c:\~dialog~.scp,result,Top=%Yloc%
Writeln>c:\~dialog~.scp,result,Width=%Wide%
Writeln>c:\~dialog~.scp,result,Left=%Xloc%
Writeln>c:\~dialog~.scp,result,Height=%High%
Writeln>c:\~dialog~.scp,result,Label=Width of window,104,40
Writeln>c:\~dialog~.scp,result,Label=Height of window,104,120
Writeln>c:\~dialog~.scp,result,Label=X location of window,280,40
Writeln>c:\~dialog~.scp,result,Label=Y location of window,280,120
Writeln>c:\~dialog~.scp,result,Button=OK,16,8,75,25,5
Writeln>c:\~dialog~.scp,result,Button=Cancel,16,48,75,25,2
Writeln>c:\~dialog~.scp,result,Edit=Edit1,104,8,121,%Wide%
Writeln>c:\~dialog~.scp,result,Edit=Edit2,104,88,121,%High%
Writeln>c:\~dialog~.scp,result,Edit=Edit3,280,8,121,%Xloc%
Writeln>c:\~dialog~.scp,result,Edit=Edit4,280,88,121,%Yloc%
Writeln>c:\~dialog~.scp,result,EndDialog>Dialog2
Writeln>c:\~dialog~.scp,result,show>Dialog2,r
Writeln>c:\~dialog~.scp,result,if>r=5,Process
Writeln>c:\~dialog~.scp,result,if>r=2,exit
Writeln>c:\~dialog~.scp,Goto>finish
Writeln>c:\~dialog~.scp,Label>Process
Writeln>c:\~dialog~.scp,Let>NWide=Dialog2.Edit1
Writeln>c:\~dialog~.scp,Let>NHigh=Dialog2.Edit2
Writeln>c:\~dialog~.scp,Let>NXloc=Dialog2.Edit3
Writeln>c:\~dialog~.scp,Let>NYloc=Dialog2.Edit4
Writeln>c:\~dialog~.scp,Let>MACRO_RESULT=%r%;%NWide%;%NHigh%;%NXloc%;%NYloc%
Writeln>c:\~dialog~.scp,Goto>finish
Writeln>c:\~dialog~.scp,Label>exit
Writeln>c:\~dialog~.scp,Let>MACRO_RESULT=2
Writeln>c:\~dialog~.scp,Label>finish
Macro>c:\~dialog~.scp
DeleteFile>c:\~dialog~.scp
if>%MACRO_RESULT%=2,exit

Separate>MACRO_RESULT,;,var
Let>Wide=var_2
Let>High=var_3
Let>Xloc=var_4
Let>Yloc=var_5
Goto>Process
Label>exit



Hope this is helpful,
Dick



Following is the original post... Less understandable?

Here is a functional but not very useful version of what I'm talking about. If you should happen to have a file called "~dialog~.scp" located in the root of your C drive don't run this script as it will delete that specific file.

The first dialog box is a non-modal box that will define the size and location of a second modal dialog box that will appear when "OK" is picked. In this example the second box has no function except to be moved and resized. Close it by picking the X or pressing ALT + F4.
(ALT + F4 will be prefered way if the X or Y coordinates specified make the dialog box "appear" off screen.)


DeleteFile>c:\~dialog~.scp
Let>Wide=300
Let>High=100
Let>Xloc=200
Let>Yloc=100
Dialog>Dialog1
Caption=Repeating redefining dialog setup
Top=200
Width=500
Left=300
Height=180
Label=Width of window,104,40
Label=Height of window,104,120
Label=X location of window,280,40
Label=Y location of window,280,120
Button=OK,16,8,75,25,5
Button=Cancel,16,48,75,25,6
Edit=Edit1,104,8,121,%Wide%
Edit=Edit2,104,88,121,%High%
Edit=Edit3,280,8,121,%Xloc%
Edit=Edit4,280,88,121,%Yloc%
EndDialog>Dialog1
Label>start
Show>Dialog1
Label>ActionLoop
GetDialogAction>Dialog1,r
if>r=5,Process
if>r=6,Close
if>r=2,exit
Goto>ActionLoop
Goto>start
SRT>Process
Writeln>c:\~dialog~.scp,result,Dialog>Dialog2


Writeln>c:\~dialog~.scp,result,Caption=Repeating redefining dialog
Writeln>c:\~dialog~.scp,result,Top=%Dialog1.Edit4%
Writeln>c:\~dialog~.scp,result,Width=%Dialog1.Edit1%
Writeln>c:\~dialog~.scp,result,Left=%Dialog1.Edit3%
Writeln>c:\~dialog~.scp,result,Height=%Dialog1.Edit2%
Writeln>c:\~dialog~.scp,result,EndDialog>Dialog2
Writeln>c:\~dialog~.scp,result,show>Dialog2,re
Macro>c:\~dialog~.scp
DeleteFile>c:\~dialog~.scp
ResetDialogAction>Dialog1
END>Process
SRT>Close
CloseDialog>Dialog1
Let>r=2
END>Close
Label>exit

I would like to point out that this script will work as a compiled exe even on computers that do not have Macro Scheduler installed.

Hope that someday someone else finds this useful. Also hope that it isn't common knowledge and I'm the only person using Macro Scheduler who didn't already know this could be done. :)

Later,
Dick

=============================================
Following is a crude keyboard dialog. Usage is:
Start the dialog script then set focus to the window you want to type into then start picking the keys with your mouse or your touchscreen monitor.

Some of the keys do not yet work like the shift keys, alt keys, etc. I have stopped working on this since I no longer have a need for it but I thought someone might someday have a use for it.

Let>comma=,
Dialog>Dialog1
Caption=KeyBoard
Width=874
Height=292
Top=446
Left=81
Label=selection,4,4,true
Button=9,760,88,49,25,57
Button=8,712,88,49,25,56
Button=7,664,88,49,25,55
Button=6,760,112,49,25,54
Button=5,712,112,49,25,53
Button=4,664,112,49,25,52
Button=3,760,136,49,25,51
Button=2,712,136,49,25,50
Button=1,664,136,49,25,49
Button=0,712,160,49,25,48
Button=*,760,64,49,25,42
Button=/,712,64,49,25,47
Button=-,808,64,49,25,45
Button=Enter,808,112,49,49,13
Button=+,808,88,49,25,43
Button=~,8,56,42,25,126
Button=1,50,56,42,25,49
Button=2,92,56,42,25,50
Button=3,134,56,42,25,51
Button=4,176,56,42,25,52
Button=5,218,56,42,25,53
Button=6,260,56,42,25,54
Button=7,302,56,42,25,55
Button=8,344,56,42,25,56
Button=9,386,56,42,25,57
Button=0,428,56,42,25,48
Button=-,470,56,42,25,45
Button==,512,56,42,25,61
Button=BackSpc,554,56,42,25,8
Button=Tab.,8,81,42,25,9
Button=Q,50,81,42,25,81
Button=W,92,81,42,25,87
Button=E,134,81,42,25,69
Button=R,176,81,42,25,82
Button=T,218,81,42,25,84
Button=Y,260,81,42,25,89
Button=U,302,81,42,25,85
Button=I,344,81,42,25,73
Button=O,386,81,42,25,79
Button=P,428,81,42,25,80
Button=[,470,81,42,25,91
Button=],512,81,42,25,93
Button=\,554,81,42,25,92
Button=A,8,106,42,25,65
Button=S,50,106,42,25,83
Button=D,92,106,42,25,68
Button=F,134,106,42,25,70
Button=G,176,106,42,25,71
Button=H,218,106,42,25,72
Button=J,260,106,42,25,74
Button=K,302,106,42,25,75
Button=L,344,106,42,25,76
Button=;,386,106,42,25,59
Button=',428,106,42,25,39
Button=Enter,470,106,42,25,13
Button=Home,512,106,42,25,2
Button=End,554,106,42,25,3
Button=Z,8,131,42,25,90
Button=X,50,131,42,25,88
Button=C,92,131,42,25,67
Button=V,134,131,42,25,86
Button=B,176,131,42,25,66
Button=N,218,131,42,25,78
Button=M,260,131,42,25,77
Button=%comma%,302,131,42,25,44
Button=.,344,131,42,25,46
Button=/,386,131,42,25,47
Button=Shift,428,131,42,25,901
Button=Page%CRLF%Up,470,131,42,25,902
Button=Page%CRLF%Down,512,131,42,25,903
Button=Del,554,131,42,25,904
Button=Ctrl,8,156,42,25,0
Button=WinKey,50,156,42,25,0
Button=Alt,92,156,42,25,0
Button=Space,134,156,42,25,32
Button=Space,176,156,42,25,32
Button=Space,218,156,42,25,32
Button=Space,260,156,42,25,32
Button=Alt,302,156,42,25,0
Button=WinKey,344,156,42,25,0
Button=MenuKey,386,156,42,25,0
Button=Ctrl,428,156,42,25,0
Button= ,470,156,42,25,0
Button= ,512,156,42,25,0
Button= ,554,156,42,25,0
EndDialog>Dialog1

Show>Dialog1
Let>HWND_TOPMOST=-1
Let>HWND_NOTOPMOST=-2
Let>SWP_NOSIZE=1
Let>SWP_NOMOVE=2
Let>SWP_NOACTIVATE=16
Let>SWP_SHOWWINDOW=64
LibFunc>user32,FindWindowA,dhwnd,TForm,KeyBoard
Let>Flags={%SWP_NOACTIVATE% Or %SWP_SHOWWINDOW% Or %SWP_NOMOVE% Or %SWP_NOSIZE%}
LibFunc>User32,SetWindowPos,swpr,dhwnd,HWND_TOPMOST,0,0,0,0,Flags
CloseDialog>dialog1

Let>LastTitle=Program Manager*

Show>dialog1
Label>AlphabetLoop
GetActiveWindow>WinTitle,WinX,WinY
If>%Wintitle%=KeyBoard
Let>WinTitle=%LastTitle%
Else
Let>LastTitle=%Wintitle%
EndIf
GetDialogAction>dialog1,res1
If>%res1%=2,EOF
If>%res1%%WinTitle%
Wait>0.1
Ascii>%res1%
Let>dialog1.mslabel0=res1
RDA>dialog1
EndIF
GetWindowPos>KeyBoard,keyX,keyY
MoveWindow>KeyBoard,keyX,keyY
Wait>0.01
Goto>AlphabetLoop

Label>EOF

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