Jump to content

Recommended Posts

Posted (edited)

I have a script that displays prayers on screen.  I am trying to keep it minimal.  I want the script to exit if at anytime the user clicks on the "x" in the extendedmsgbox.  What am I missing?  Thanks in advance for any thoughts / suggestions / comments.

 

#Region options, includes, & variables
Opt('MustDeclareVars', 1)
#include "ExtMsgBox.au3"
Global $hm = 0, $d = 0, $AppTitle = "Praying", $Amen = "Amen.", $Continue = "continue...", $x = 0

Global Const $Prayer1 = "Prayer1 prayer prayer."
Global Const $Prayer2 = "Prayer2 prayer prayer." & @CRLF & @CRLF & "The second paragraph of prayer 2."
Global Const $Prayer3 = "Prayer3 prayer prayer." & @CRLF & @CRLF & "The second paragraph of prayer 3."
Global Const $Prayer4 = "Prayer4 prayer prayer." & @CRLF & @CRLF & "The second paragraph of prayer 4."
Global Const $Prayer5 = "Prayer5 prayer prayer." & @CRLF & @CRLF & "The second paragraph of prayer 5."
Global Const $Prayer6 = "Prayer6 prayer prayer." & @CRLF & @CRLF & "The second paragraph of prayer 6."
Global Const $Prayer7 = "Prayer7 prayer prayer." & @CRLF & @CRLF & "The second paragraph of prayer 7."
Global Const $Prayer8 = "Prayer8 prayer prayer." & @CRLF & @CRLF & "The second paragraph of prayer 8."
#EndRegion options, includes, & variables

;To do next - create a menu system that asks what prayers your would like to prayer and then act on the selection

;set the baseline, not needed yet, but will remind me to use it if I change EMB settings later in the code
_ExtMsgBoxSet(Default)
; Increase font size and max width (I think)
_ExtMsgBoxSet(-1, -1, -1, -1, 22, -1, 1000)

Say($AppTitle, $Prayer1, $Amen)
While $x <> 0
    Daily()
WEnd
Say($AppTitle, $Prayer1, $Amen)

Func Daily()
    TheMorning()
    TheLitany()
    Say("Prayer for our intentions", $Prayer8, $Amen)
EndFunc

Func TheMorning()
    Say($AppTitle, $Prayer2, $Amen)
    Say($AppTitle, $Prayer3, $Continue)
    Say($AppTitle, $Prayer4, $Amen)
EndFunc

Func TheLitany()
    Say($AppTitle, $Prayer2, $Amen)
    Say($AppTitle, $Prayer5, $Continue)
    Say($AppTitle, $Prayer6, $Continue)
    Say($AppTitle, $Prayer7, $Amen)
EndFunc

Func Say($Text, $Prayer, $Button)
;~  $x = MsgBox($MB_SYSTEMMODAL, $Text, $Prayer)
    $x = _ExtMsgBox(0, $Button, $Text, $Prayer)
EndFunc

 

StringSize.au3

ExtMsgBox.au3

Edited by helmar
added requested files
Posted

Zelda ..... Really? The code ExtMsgBox.au3 is available on the AutoIt Wiki. It's an excellent UDF posted by Melba23 .

Helmar, are you using the latest version? I recently had to update the version I have been using for years. The latest version is 22 Mar 2018.

Who lied and told you life would EVER be fair?

Posted
10 minutes ago, benched42 said:

Helmar, are you using the latest version? I recently had to update the version I have been using for years. The latest version is 22 Mar 2018.

Yes, that is the version I am using.

Posted

I believe that you might need to insert a value for the $Button variable, since you choose to explicitly define all variables.

Who lied and told you life would EVER be fair?

Posted
1 minute ago, benched42 said:

I believe that you might need to insert a value for the $Button variable, since you choose to explicitly define all variables.

By 'declaring' $Button in the Say() function initialization, I thought I didn't need to put it up top.  Are you saying give it a default value if I forget to pass that parm?

Why is $x not being evaluated by the While/WEnd?

  • Developers
Posted

Try using this Func Say:

Func Say($Text, $Prayer, $Button)
;~  $x = MsgBox($MB_SYSTEMMODAL, $Text, $Prayer)
    $x = _ExtMsgBox(0, $Button, $Text, $Prayer)
    if not $x then Exit
EndFunc

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

  • Moderators
Posted

helmar,

You get a return value of 0 if the _ExtMsgBox [X] is pressed (as explained in the function header within the UDF itself), so just look for that:

Func Say($Text, $Prayer, $Button)
    If _ExtMsgBox(0, $Button, $Text, $Prayer) = 0 Then
        Exit
    EndIf
EndFunc

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Developers
Posted
9 minutes ago, benched42 said:

I believe that you might need to insert a value for the $Button variable, since you choose to explicitly define all variables.

 

34 minutes ago, benched42 said:

Zelda  benched42 ..... Really?

;)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Thank you Melba23 and Jos, you helped me get that resolved.  I opted to remove $x completely and read the result of the EMB inline.

Jos, I understand what you were saying in that one comment, however it did cause me to look at optional variables in defining a function (which I had never done before).  Instead of declaring up top $Amen (which is the norm), I am now declaring it in the function declaration

Func Say($Text, $Prayer, $Button = "Amen")

and sending $Continue for those exceptions when the text is very verbose for one screen or the like.  Reduces code size and makes adding prayers easier.

  • Developers
Posted
46 minutes ago, helmar said:

Jos, I understand what you were saying

My second post was for @benched42 and solely about the initial remark made towards @Zedna:) 
I namely agree with zedna that posted issues should be runable without any searching for extra's first....  that's all.

JOs 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
1 hour ago, Jos said:

posted issues should be runable without any searching for extra's first

I thought about that, made a (poor) call that it would be in high use  - my error.  I almost commented out the calls to the UDF, and just used the native MsgBox in the posting, but that would have changed the question / answer (I think).

Posted (edited)

Question:  what are some of the nuances with touch screen / tablets / orientation and EMB?  I "think" if I move the EMB set statement into the Say() function, I should be addressing if someone starts the script from a normal desktop, and then switches to tablet or portrait etc.

Func Say($Text, $Prayer, $Button = "Amen")
    _ExtMsgBoxSet(Default) ;set the baseline
    _ExtMsgBoxSet(-1, -1, -1, -1, 22, -1, @DesktopWidth-25)
    If _ExtMsgBox(0, $Button, $Text, $Prayer) = 0 Then
        Exit
    EndIf
EndFunc

 

Edited by helmar
broader audience

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...