LibFunc MessageBox Wizard

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

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

LibFunc MessageBox Wizard

Post by Rain » Tue Apr 29, 2008 2:22 pm

I wrote this script to help me create LibFunc MessageBoxes on the fly. Simply enter your message for the window title and message body and select how you want to display your message. Click "Preview" to preview your MessageBox and "Copy" to copy the code to your clipboard.

Known Issues:
Large texts may not get displayed correctly. Copy and paste the above message to the message body and click "Preview". The message gets cut off at "...copy the code to your cli`%E". I couldn't find an answer as to why this is happening. Maybe someone out there has an answer/solution.

Code: Select all

Dialog>Dialog1
   Caption=LibFunc MessageBox Wizard by Rain
   Width=445
   Height=538
   Top=0
   Left=0
   Edit=msEdit1,8,16,417,Window Title
   Label=Title,8,0,true
   Memo=msMemo1,8,64,417,97,Message Body
   Label=Text,8,48,true
   RadioGroup=msRadioGroup1,Icons,16,176,193,169,Warning%CRLF%Informational%CRLF%Critical%CRLF%Question%CRLF%None,0
   RadioGroup=msRadioGroup2,Modality,16,352,193,113,Application%CRLF%System%CRLF%Task Modal,0
   RadioGroup=msRadioGroup3,Miscellaneous,232,376,193,89,Nothing%CRLF%Top-most attribute set%CRLF%Right-justified title/text,0
   RadioGroup=msRadioGroup4,Buttons,232,176,193,193,OK%CRLF%OK-Cancel%CRLF%Yes-No%CRLF%Yes-No-Cancel%CRLF%Abort-Retry-Ignore%CRLF%Retry-Cancel%CRLF%Cancel-Retry-Continue,0
   Button=Preview,16,472,97,25,1
   Button=Copy,128,472,97,25,3
EndDialog>Dialog1

show>Dialog1

    LET>COPY_CODE=FALSE

LABEL>Loop
   WAIT>0.05
   GetDialogAction>Dialog1,RESULT
   IF>RESULT=1,Preview
   IF>RESULT=2,Exit
   IF>RESULT=3,Copy
GOTO>Loop

LABEL>Copy
    LET>COPY_CODE=TRUE

LABEL>Preview

 ResetDialogAction>Dialog1

    LET>FLAG=0

    //--> START GET FLAG


//--> START Set Icons Flag
  IF>Dialog1.msRadioGroup1.ItemIndex=0
    LET>FLAG=FLAG+48
  ENDIF

  IF>Dialog1.msRadioGroup1.ItemIndex=1
    LET>FLAG=FLAG+64
  ENDIF

  IF>Dialog1.msRadioGroup1.ItemIndex=2
    LET>FLAG=FLAG+16
  ENDIF

  IF>Dialog1.msRadioGroup1.ItemIndex=3
    LET>FLAG=FLAG+32
  ENDIF
//<-- END Set Icons Flag


//--> START Set Modality Flag
  IF>Dialog1.msRadioGroup2.ItemIndex=1
    LET>FLAG=FLAG+4096
  ENDIF

  IF>Dialog1.msRadioGroup2.ItemIndex=2
    LET>FLAG=FLAG+8192
  ENDIF
//<-- END Set  Modality Flag


//--> START Set Miscellaneous Flag
  IF>Dialog1.msRadioGroup3.ItemIndex=1
    LET>FLAG=FLAG+262144
  ENDIF

  IF>Dialog1.msRadioGroup3.ItemIndex=2
    LET>FLAG=FLAG+5244288
  ENDIF
//<-- END Set  Miscellaneous Flag


//--> START Set Buttons Flag
  IF>Dialog1.msRadioGroup4.ItemIndex=1
    LET>FLAG=FLAG+1
  ENDIF

  IF>Dialog1.msRadioGroup4.ItemIndex=2
    LET>FLAG=FLAG+4
  ENDIF

  IF>Dialog1.msRadioGroup4.ItemIndex=3
    LET>FLAG=FLAG+3
  ENDIF

  IF>Dialog1.msRadioGroup4.ItemIndex=4
    LET>FLAG=FLAG+2
  ENDIF

  IF>Dialog1.msRadioGroup4.ItemIndex=5
    LET>FLAG=FLAG+5
  ENDIF

  IF>Dialog1.msRadioGroup4.ItemIndex=6
    LET>FLAG=FLAG+6
  ENDIF
//<-- END Set  Buttons Flag


   //<---- END GET FLAG


//<-- START  Replace Comma in Title and Message Body
    LET>MEMO_C_O_M_M_A=,
    LET>EDIT_C_O_M_M_A=,
  StringReplace>Dialog1.msMemo1,%MEMO_C_O_M_M_A%,;,Dialog1.msMemo1
  StringReplace>Dialog1.msEdit1,%EDIT_C_O_M_M_A%,;,Dialog1.Dialog1.msEdit1
//<-- END  Replace Comma in Title and Message Body


//<-- START  Copy Code to Clipboard
    IF>COPY_CODE=TRUE
  PutClipBoard>LibFunc>user32,MessageBoxA,r,0,%Dialog1.msMemo1%,%Dialog1.msEdit1%,%FLAG%
    LET>COPY_CODE=FALSE
GOTO>Loop
  ENDIF
//<-- END  Copy Code to Clipboard


//<-- START  Preview MessageBox
  LibFunc>user32,MessageBoxA,r,0,Dialog1.msMemo1,Dialog1.msEdit1,%FLAG%
//<-- END Preview MessageBox

GOTO>Loop

LABEL>Exit
Enjoy
Last edited by Rain on Tue Apr 29, 2008 3:54 pm, edited 1 time in total.

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

Post by JRL » Tue Apr 29, 2008 3:14 pm

Wow! Very nice, well laid out and easy to understand.

Thank you for sharing.
Dick

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

Re: LibFunc MessageBox Wizard

Post by jpuziano » Wed Apr 30, 2008 3:44 am

Hi Rain,

Thanks for sharing this, very nicely done.
Rain wrote:Known Issues:
Large texts may not get displayed correctly. Copy and paste the above message to the message body and click "Preview". The message gets cut off at "...copy the code to your cli`%E". I couldn't find an answer as to why this is happening. Maybe someone out there has an answer/solution.
I pasted three copies of your opening paragraph in as the message text and it was all displayed. How long does the message text have to be before it gets cut off?
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 Apr 30, 2008 3:12 pm

You welcome Dick and Jpuziano

>I pasted three copies of your opening paragraph in as the message text and it was all displayed.
>How long does the message text have to be before it gets cut off?

That's strange. I normally get the "error" right away.

Try the text below. It gets cut off at the highlighted part on my system.

A question-mark icon appears in the message box. The question-mark message icon is no longer recommended because it does not clearly represent a specific type of message and because the phrasing of a message as a question could apply to any message type. In addition, users can confuse the message symbol question mark with Help information. Therefore, do not use this question mark message symbol in your message boxes. The system continues to support its inclusion only for backward compatibility.

This is an updated version of the script.
I've added an option to set default buttons, a copy complete message box and a check box to include the message result options. Thank you Dick for your improvement suggestions.

Code: Select all

Dialog>Dialog1
   Caption=LibFunc MessageBox Wizard by Rain
   Width=445
   Height=558
   Top=0
   Left=0
   Edit=msEdit1,8,16,417,Window Title
   Label=Title,8,0,true
   Memo=msMemo1,8,64,417,97,Message Body
   Label=Text,8,48,true
   RadioGroup=msRadioGroup1,Icons,16,176,201,169,Warning%CRLF%Informational%CRLF%Critical%CRLF%Question%CRLF%None,4
   RadioGroup=msRadioGroup2,Modality,16,352,97,113,Application%CRLF%System%CRLF%Task Modal,0
   RadioGroup=msRadioGroup3,Miscellaneous,232,376,193,89,Nothing%CRLF%Top-most attribute set%CRLF%Right-justified title/text,0
   RadioGroup=msRadioGroup4,Buttons,232,176,193,193,OK%CRLF%OK-Cancel%CRLF%Yes-No%CRLF%Yes-No-Cancel%CRLF%Abort-Retry-Ignore%CRLF%Retry-Cancel%CRLF%Cancel-Try Again-Continue,0
   Button=Preview,16,472,97,25,1
   Button=Copy,128,472,97,25,3
   CheckBox=msCheckBox1,Include Message Result Options,240,472,177,True
   RadioGroup=msRadioGroup5,Default Button,120,352,97,113,,-1
   ListBox=msListBox1,128,368,81,89,First Button
   Font=Tahoma,8
EndDialog>Dialog1

SetDialogObjectFont>Dialog1,msLabel1,Tahoma,8,0,13977088
SetDialogObjectFont>Dialog1,msLabel2,Tahoma,8,0,13977088
SetDialogObjectFont>Dialog1,msEdit1,Tahoma,8,1,0
SetDialogObjectFont>Dialog1,msMemo1,msMemo1,8,1,0
SetDialogObjectFont>Dialog1,msListBox1,Tahoma,8,0,0
SetDialogObjectFont>Dialog1,msRadioGroup1,Tahoma,8,0,0



SHOW>Dialog1
LET>ListBoxOptionA=FALSE
LET>ListBoxOptionB=FALSE
LET>ListBoxOptionC=FALSE
LET>COPY_CODE=FALSE

LABEL>Loop
WAIT>0.05
GetDialogAction>Dialog1,RESULT
IF>RESULT=1,Preview
IF>RESULT=2,Exit
IF>RESULT=3,Copy

  IF>ListBoxOptionA=FALSE
    IF>Dialog1.msRadioGroup4.ItemIndex=0
    LET>ListBoxOptionA=TRUE
    LET>ListBoxOptionB=FALSE
    LET>ListBoxOptionC=FALSE
	LET>Dialog1.msListBox1.ItemIndex=0
    LET>Dialog1.msListBox1.Items.Text=First Button
    ResetDialogAction>Dialog1
    endif
  ENDIF

  IF>ListBoxOptionB=FALSE
    IF>{(%Dialog1.msRadioGroup4.ItemIndex%=1)OR(%Dialog1.msRadioGroup4.ItemIndex%=2)OR(%Dialog1.msRadioGroup4.ItemIndex%=5)}
    LET>ListBoxOptionA=FALSE
    LET>ListBoxOptionB=TRUE
    LET>ListBoxOptionC=FALSE
	LET>Dialog1.msListBox1.ItemIndex=0
    LET>Dialog1.msListBox1.Items.Text=First Button%CRLF%Second Button
    ResetDialogAction>Dialog1
    endif
  ENDIF

  IF>ListBoxOptionC=FALSE
    IF>{(%Dialog1.msRadioGroup4.ItemIndex%=3)OR(%Dialog1.msRadioGroup4.ItemIndex%=4)OR(%Dialog1.msRadioGroup4.ItemIndex%=6)}
    LET>ListBoxOptionA=FALSE
    LET>ListBoxOptionB=FALSE
    LET>ListBoxOptionC=TRUE
	LET>Dialog1.msListBox1.ItemIndex=0
    LET>Dialog1.msListBox1.Items.Text=First Button%CRLF%Second Button%CRLF%Third Button
    ResetDialogAction>Dialog1
    endif
  ENDIF

GOTO>Loop

LABEL>Copy
LET>COPY_CODE=TRUE

LABEL>Preview

ResetDialogAction>Dialog1

LET>FLAG=0

//--> START GET FLAG


//--> START Set Icons Flag
IF>Dialog1.msRadioGroup1.ItemIndex=0
LET>FLAG=FLAG+48
ENDIF

IF>Dialog1.msRadioGroup1.ItemIndex=1
LET>FLAG=FLAG+64
ENDIF

IF>Dialog1.msRadioGroup1.ItemIndex=2
LET>FLAG=FLAG+16
ENDIF

IF>Dialog1.msRadioGroup1.ItemIndex=3
LET>FLAG=FLAG+32
ENDIF
//<END> START Set Modality Flag
IF>Dialog1.msRadioGroup2.ItemIndex=1
LET>FLAG=FLAG+4096
ENDIF

IF>Dialog1.msRadioGroup2.ItemIndex=2
LET>FLAG=FLAG+8192
ENDIF
//<END> START Set Miscellaneous Flag
IF>Dialog1.msRadioGroup3.ItemIndex=1
LET>FLAG=FLAG+262144
ENDIF

IF>Dialog1.msRadioGroup3.ItemIndex=2
LET>FLAG=FLAG+5244288
ENDIF
//<END> START Set Buttons Flag
IF>Dialog1.msRadioGroup4.ItemIndex=1
LET>FLAG=FLAG+1
ENDIF

IF>Dialog1.msRadioGroup4.ItemIndex=2
LET>FLAG=FLAG+4
ENDIF

IF>Dialog1.msRadioGroup4.ItemIndex=3
LET>FLAG=FLAG+3
ENDIF

IF>Dialog1.msRadioGroup4.ItemIndex=4
LET>FLAG=FLAG+2
ENDIF

IF>Dialog1.msRadioGroup4.ItemIndex=5
LET>FLAG=FLAG+5
ENDIF

IF>Dialog1.msRadioGroup4.ItemIndex=6
LET>FLAG=FLAG+6
ENDIF
//<END> START Set Default Button Flag
IF>Dialog1.msListBox1.ItemIndex=1
LET>FLAG=FLAG+256
ENDIF

IF>Dialog1.msListBox1.ItemIndex=2
LET>FLAG=FLAG+512
ENDIF

//<-- END Set Default Button Flag


//<---- END GET FLAG


//<START>
LET>MEMO_C_O_M_M_A=,
LET>EDIT_C_O_M_M_A=,
StringReplace>Dialog1.msMemo1,%MEMO_C_O_M_M_A%,;,Dialog1.msMemo1
StringReplace>Dialog1.msEdit1,%EDIT_C_O_M_M_A%,;,Dialog1.Dialog1.msEdit1
//<-- END Replace Comma in Title and Message Body


//<START>
IF>COPY_CODE=TRUE
LET>MsgFunc=LibFunc>user32,MessageBoxA,r,0,%Dialog1.msMemo1%,%Dialog1.msEdit1%,%FLAG%
IF>dialog1.mscheckbox1=True,Result_Option
PutClipBoard>MsgFunc
LET>COPY_CODE=FALSE
LibFunc>user32,MessageBoxA,r,0,Click OK to Continue,Copy Complete,4160
GOTO>Loop
ENDIF
//<-- END Copy Code to Clipboard


//<START>
LibFunc>user32,MessageBoxA,r,0,%Dialog1.msMemo1%,%Dialog1.msEdit1%,%FLAG%
//<END>
GOTO>Loop

LABEL>Exit

SRT>Result_Option
Concat>MsgFunc,%CRLF%IF>r=1,Ok%CRLF%
Concat>MsgFunc,IF>r=2,Cancel%CRLF%
Concat>MsgFunc,IF>r=3,Abort%CRLF%
Concat>MsgFunc,IF>r=4,Retry%CRLF%
Concat>MsgFunc,IF>r=5,Ignore%CRLF%
Concat>MsgFunc,IF>r=6,Yes%CRLF%
Concat>MsgFunc,IF>r=7,No%CRLF%
Concat>MsgFunc,IF>r=10,Try Again%CRLF%
Concat>MsgFunc,IF>r=11,Continue%CRLF%
END>Result_Option


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

Post by JRL » Wed Apr 30, 2008 6:28 pm

Rain wrote:Try the text below. It gets cut off at the highlighted part on my system.
Running the line below as a complete script, I get to see the entire message about half the time and it cuts off in the same place as yours the other half the time.


Code: Select all

LibFunc>user32,MessageBoxA,r,0,A question-mark icon appears in the message box. The question-mark message icon is no longer recommended because it does not clearly represent a specific type of message and because the phrasing of a message as a question could apply to any message type. In addition; users can confuse the message symbol question mark with Help information. Therefore; do not use this question mark message symbol in your message boxes. The system continues to support its inclusion only for backward compatibility. ,Window Title,0

User avatar
migro
Macro Veteran
Posts: 151
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Sat Jul 04, 2009 12:23 am

Thanks Rain for this awesome script. I use it frequently to generate messageboxes for my scripts.

One question: Is it possible to generate also inputboxes with Libfunc>?
Because all my messages are in windowsstyle now, I like to get the inputboxes in the same style. :?
regards
migro

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