Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Splash Me v1.0


  • Please log in to reply
24 replies to this topic
jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
Introduction
A text-only splash window definitely has its place. Splash windows are usually much larger and more readable that a Tooltip window and are less annoying (IMHO) than a Traytip window with the constant pop and bloop sound when the window is created. Yes, I know how to turn the sound off. Of course, if misused and/or overused, a splash window can also prove to be annoying and/or distracting.

I like to display an informational splash window when initiating a computer operation that takes more than a couple of seconds to complete. For example, a "Starting Firefox..." splash keeps me from asking, "Did it work??" or "Is anything happening??" I also like to generate a splash window to display information related to a request. For example, I display a splash window with the current artist, track title, and track time when a request to skip, play, or pause a Winamp track is submitted.

The problem with using the SplashImage command to splash information is 1) you have to size it and 2) you have to remember to shut it down. OK, these aren't real problems but I just wanted to Splash-'N-Go so I generated a list of requirements for a text-only splash window:
[*:ml9o3don]Automatic window sizing (width and height).

[*:ml9o3don]Splash window destruction determined by a developer-defined or default minimum time. Keep the splash window open long enough for the user to read and absorb the information.

[*:ml9o3don]Allow splash processing to be interrupted/overridden. A request for a new splash window should always have priority over a splash window that is awaiting destruction.

[*:ml9o3don]Allow the splash window to be preserved. This is the ability to override the request to destroy the splash window. This capability is useful when running a series of functions/subroutines where some or all of the routines create splash windows.

[*:ml9o3don]No interference with other requests. Sleep bad.I've created 3 functions (SplashOn, SplashOff, and PreserveSplashWindow) and 1 subroutine (SplashOff_Timer) to deal with the tasks of managing a simple information splash window.


Screenshots
Here are a few examples of what the splash windows might look like. Note that the width of the splash window is automatically adjusted...
Posted Image

Posted Image

Posted Image

Posted Image


The Code
;-- v1.0
;-- Important: Because this code includes a subroutine, you should
;   insert/include it AFTER the Auto-Execute section of a script.
;
;*******************
;*                 *
;*    Splash On    *
;*                 *
;*******************
;
;   Description
;   ===========
;   This function generates a borderless text Splash window and is used in
;   conjunction with the SplashOff, PreserveSplashWindow, and SplashOff_Timer
;   functions/subroutines.
;
;
;
;   Parameters
;   ==========
;
;       Name                    Description
;       ----                    -----------
;       p_MainText              Main text. [Optional]  The default is null.
;
;       p_SubText               Sub text. [Optional]  The default is null.
;
;       p_MinimumSplashTime     Minimum time (in seconds) the splash window is
;                               to be displayed. [Optional]  The default is
;                               0.85 seconds.
;
;                               If p_MinimumSplashTime contains a negative value
;                               (Ex: -3), this function will automatically call
;                               the SplashOff function using the absolute value
;                               value of this parameter as the minimum splash
;                               time.  This feature is useful when you know
;                               exactly how long you want the splash window to
;                               display.  It also removes the need for a
;                               separate call to the SplashOff function.
;
;       p_Font                  Font Name.  [Optional]  The default is null (the
;                               system default font is used).
;
;                               This font is used for both the MainText (top
;                               line(s)) and SubText (bottom line(s)).
;                               
;
;       p_Options               See the "Splash Options" section for more
;                               information.
;
;
;
;   Global Variables
;   ================
;
;       Name                    Description
;       ----                    -----------
;       $Splash_StartTime       This variable contains the time (A_TickCount)
;                               that the splash window was created.
;
;       $Splash_MinimumTime     This variable contains minimum time 
;                               (developer-defined or default) that the splash
;                               window should be displayed.
;
;
;
;   Splash Options
;   ==============
;   The p_Options parameter is used to set any SplashImage options that are not
;   set by default.  If more than one option is defined, separate each option by
;   a space.  For example:
;
;       "CWBlack CTYellow"
;
;   For a complete list of SplashImage options, see the  AutoHotkey 
;   documentation (keyword: SplashImage).
;
;
;   The following SplashImage options are automatically included by default:
;
;       Name                    Description
;       ----                    -----------
;       b2                      No title bar, dialog style border
;
;       W{Function determined}  Splash window width.  The size doesn't include
;                               border.
;
;
;   If not explicitly defined, the following SplashImage options/values are
;   included:
;
;       Name                    Description/Value
;       ----                    -----------------
;       FM10                    Font size for MainText - 10
;       FS12                    Font size for SubText - 12
;       WM600                   Font weight for MainText - 600 (Bold)
;       WS400                   Font weight for SubText - 400 (Normal)
;
;
;   In addition to the standard X/Y options, the following options are
;   available to position the Splash window on the screen:
;
;       Name                    Description/Value
;       ----                    -----------------
;       XL or XLeft             Left side of the screen.  Not necessarily the
;                               same as X0.
;
;       XM or XMiddle           Horizontally centered on the screen.  This is
;                               SplashImage default.
;
;       XR or XRight            Right side of the screen.
;
;       YT or YTop              Top of the screen.  Not necessarily the same as
;                               Y0.
;
;       YM or YMiddle           Vertically centered on the screen.  This is
;                               SplashImage default.
;
;       YB or YBottom           Bottom of the screen.
;
;
;   The preceding X/Y options are calculated based on the work area for the
;   primary monitor.  The work area excludes the taskbar and other registered
;   desktop toolbars.
;   
;
;
;   Calls To Other Functions
;   ========================
;   SplashOff
;
;
;
;   Calls To Subroutines
;   ====================
;   SplashOff_Timer
;
;
;
;   Programming Notes
;   =================
;   o   This function creates a temporary GUI window to ascertain the width of
;       the SplashImage window.  The function uses the first GUI window that is
;       available in the 71 to 99 range. If an available window cannot be found,
;       an error message is displayed.
;
;   o   So as not to interfere with any other SplashImage windows, an 
;       arbitrarily selected SplashImage window number (8) is used.  Change if
;       needed.  See the AutoHotkey documentation (keyword: SplashImage) for
;       more information.
;
;
;-------------------------------------------------------------------------------
SplashOn(p_MainText=""
        ,p_SubText=""
        ,p_MinimumSplashTime=""
        ,p_Font=""
        ,p_Options="")
    {
    global $Splash_StartTime, $Splash_MinimumTime


    ;[==============]
    ;[  Initialize  ]
    ;[==============]
    l_DetectHiddenWindows:=A_DetectHiddenWindows
    DetectHiddenWindows On

    l_MainTextFontSize=10
    l_MainTextFontWeight=600
    l_SubTextFontSize=12
    l_SubTextFontWeight=400


    ;[==============]
    ;[  Parameters  ]
    ;[==============]
    ;-- p_MinimumSplashTime
    if p_MinimumSplashTime is not Number
        p_MinimumSplashTime=0


    ;-- p_Font
    p_Font=%p_Font%  ;-- AutoTrim


    ;[=======================]
    ;[  Extract font values  ]
    ;[  from p_Options       ]
    ;[=======================]
    loop parse,p_Options,%A_Space%
        {
        if A_LoopField is Space
            continue

        ;-- MainText options
        if instr(A_LoopField,"FM")=1
            if SubStr(A_LoopField,3) is Number
                StringTrimLeft l_MainTextFontSize,A_LoopField,2

        if instr(A_LoopField,"WM")=1
            if SubStr(A_LoopField,3) is Number
                StringTrimLeft l_MainTextFontWeight,A_LoopField,2


        ;-- SubText options
        if instr(A_LoopField,"FS")=1
            if SubStr(A_LoopField,3) is Number
                StringTrimLeft l_SubTextFontSize,A_LoopField,2

        if instr(A_LoopField,"WS")=1
            if SubStr(A_LoopField,3) is Number
                StringTrimLeft l_SubTextFontWeight,A_LoopField,2
        }


    ;[=============]
    ;[  p_Options  ]
    ;[=============]
    p_Options=%p_Options%  ;-- AutoTrim
    p_Options:="b2 " . p_Options

    ;-- If not explicitly defined, load font size just in case defaults don't
    ;   match system default
    ;
    if instr(p_Options," FM")=0
        p_Options:=p_Options . " FM" . l_MainTextFontSize

    if instr(p_Options," FS")=0
        p_Options:=p_Options . " FS" . l_SubTextFontSize


    ;-- Update/Simplify X/Y options
    StringReplace p_Options,p_Options,%A_Space%XLeft,%A_Space%XL,All
    StringReplace p_Options,p_Options,%A_Space%XMiddle,,All
    StringReplace p_Options,p_Options,%A_Space%XM,,All
    StringReplace p_Options,p_Options,%A_Space%XRight,%A_Space%XR,All
    
    StringReplace p_Options,p_Options,%A_Space%YTop,%A_Space%YT,All
    StringReplace p_Options,p_Options,%A_Space%YMiddle,,All
    StringReplace p_Options,p_Options,%A_Space%YM,,All
    StringReplace p_Options,p_Options,%A_Space%YBottom,%A_Space%YB,All


    ;[=====================]
    ;[  Preliminary stuff  ]
    ;[=====================]
    ;-- 1st run?
    if $Splash_MinimumTime is Space
        {
        $Splash_MinimumTime=850  ;-- Default in milliseconds.  Adjust if desired
        $Splash_StartTime=0
        }


    ;-- Turn off the SplashOff timer
    SetTimer SplashOff_Timer,off


    ;-- Minimum splash time defined?
    if p_MinimumSplashTime
        {
        $Splash_MinimumTime:=p_MinimumSplashTime*1000
        $Splash_StartTime=0
        }


    ;-- Reset start time?
    if not $Splash_StartTime
        $Splash_StartTime:=A_TickCount


    ;[=========================]
    ;[  Find available window  ]
    ;[   (Starting with 71)    ]
    ;[=========================]
    l_GUI=71
    loop
        {
        ;-- Window available?
        gui %l_GUI%:+LastFoundExist
        IfWinNotExist
            break

        ;-- Nothing available?
        if l_GUI=99
            {
            msgbox,262160,SplashOn Error,
               (ltrim
                Unable to create SplashOn temporary GUI.  %A_Space%
                GUI windows 71 to 99 are already in use.
               )

            return
            }

        ;-- Increment window
        l_GUI++
        }


    ;[==========================]
    ;[  Determine splash width  ]
    ;[==========================]
    ;-- Build temporary window to determine maximum width
    gui %l_GUI%:Margin,0,0
    gui %l_GUI%:Font,s%l_MainTextFontSize% w%l_MainTextFontWeight%,%p_Font%
    gui %l_GUI%:Add,Text,,%p_MainText%
    gui %l_GUI%:Font,s%l_SubTextFontSize% w%l_SubTextFontWeigth%
    gui %l_GUI%:Add,Text,,%p_SubText%
    gui %l_GUI%:Show,Hide  ;-- Render but don't show


    ;-- How wide is it?
    gui %l_GUI%:+LastFound
    WinGetPos ,,,l_SplashImageWidth,,% "ahk_id " . WinExist()
    gui %l_GUI%:Destroy


    ;-- Add some breathing room
    l_SplashImageWidth:=l_SplashImageWidth+60


    ;-- Too wide?
    l_MaxSplashImageWidth:=round(A_ScreenWidth*0.95)
    if (l_SplashImageWidth>l_MaxSplashImageWidth)
        l_SplashImageWidth:=l_MaxSplashImageWidth
    

    ;[==============]
    ;[  Splash it!  ]
    ;[==============]
    l_BreakLoop:=false
    loop 2
        {
        ;-- Create working copy of p_Options
        l_Options:=p_Options


        ;-- Function-specific X/Y options?
        if (instr(p_Options,A_Space . "XL")
        or  instr(p_Options,A_Space . "XR")
        or  instr(p_Options,A_Space . "YT")
        or  instr(p_Options,A_Space . "YB"))
            {
            StringReplace l_Options,l_Options,%A_Space%XL,,All
            StringReplace l_Options,l_Options,%A_Space%XR,,All
            StringReplace l_Options,l_Options,%A_Space%YT,,All
            StringReplace l_Options,l_Options,%A_Space%YB,,All
            l_Options:=l_Options . " Hide"
            }
         else
            l_BreakLoop:=true


        ;-- Splash using working copy of p_Options
        SplashImage 8:,W%l_SplashImageWidth% %l_Options%
            ,%p_SubText%
            ,%p_MainText%
            ,SplashOnWindow
            ,%p_Font%


        ;-- Are we done yet?
        if l_BreakLoop
            break


        ;-- Collect splash window width and height
        WinGetPos ,,,l_SplashWindowWidth,l_SplashWindowHeight,SplashOnWindow


        ;-- Collect work area dimensions for primary monitor
        SysGet l_MonitorWorkArea,MonitorWorkArea


        ;-- Update X/Y positions
        StringReplace p_Options
            ,p_Options
            ,%A_Space%XL
            ,% " X" . l_MonitorWorkAreaLeft
            ,All
        
        StringReplace p_Options
            ,p_Options
            ,%A_Space%XR
            ,% " X" . l_MonitorWorkAreaRight-l_SplashWindowWidth
            ,All
        
        StringReplace p_Options
            ,p_Options
            ,%A_Space%YT
            ,% " Y" . l_MonitorWorkAreaTop
            ,All

        StringReplace p_Options
            ,p_Options
            ,%A_Space%YB
            ,% " Y" . l_MonitorWorkAreaBottom-l_SplashWindowHeight
            ,All
        }


    ;-- Minor delay to give the window a chance to render
    sleep 1


    ;[===================]
    ;[  Auto SplashOff?  ]
    ;[===================]
    if $Splash_MinimumTime<0
        {
        $Splash_MinimumTime:=abs($Splash_MinimumTime)
        SplashOff()
        }


    ;[================]
    ;[  Housekeeping  ]
    ;[================]
    DetectHiddenWindows %l_DetectHiddenWindows%


    ;-- Return to sender
    return
    }



;********************
;*                  *
;*    Splash Off    *
;*                  *
;********************
;
;
;   Description
;   ===========
;   This function performs one of the following tasks:
;
;    1) If PreserveSplashWindow is TRUE (explicitly or by default), turn off
;       the SplashOff timer.  Do nothing else.
;
;    2) If the minimum splash time has elapsed, turn off (destroy) the splash
;       window created by the SplashOn function.
;
;    3) If the minimum splash time has NOT elapsed, set a timer to turn off
;       (destroy) the splash window created by the SplashOn function.
;
;
;
;   Parameters
;   ==========
;
;       Name                    Description
;       ----                    -----------
;       p_PreserveSplashWindow  Preserve Splash Window.  [Boolean, Optional]
;                               The default is FALSE or the value it was set to
;                               last.
;
;
;
;   Calls To Other Functions
;   ========================
;   PreserveSplashWindow
;
;
;
;   Calls To Subroutines
;   ====================
;   SplashOff_Timer
;
;
;-------------------------------------------------------------------------------
SplashOff(p_PreserveSplashWindow="")
    {
    global $Splash_MinimumTime, $Splash_StartTime


    ;-- Turn off SplashOff timer
    SetTimer SplashOff_Timer,off
    

    ;-- Preserve splash?
    if PreserveSplashWindow(p_PreserveSplashWindow)
        return

    
    ;-- Compute elapsed time.  Set timer if necessary
    l_SplashTimeElapsed:=A_TickCount-$Splash_StartTime
    if (l_SplashTimeElapsed<$Splash_MinimumTime)
        {
        l_SplashOffTimer:=$Splash_MinimumTime-l_SplashTimeElapsed
        SetTimer SplashOff_Timer,%l_SplashOffTimer%
        }
      else
         ;-- Destroy splash window
         SplashImage 8:Off
    

    ;-- Reset to defaults
    $Splash_MinimumTime=850  ;-- Default in milliseconds.  Adjust if desired
    $Splash_StartTime=0
    

    ;-- Return to sender
    return
    }



;**************************
;*                        *
;*    Splash Off Timer    *
;*                        *
;**************************
SplashOff_Timer:
SetTimer SplashOff_Timer,Off
SplashImage 8:Off
return



;********************************
;*                              *
;*    Preserve Splash Window    *
;*                              *
;********************************
;
;
;   Description
;   ===========
;   This function sets and/or returns the current boolean value of 
;   s_PreserveSplashWindow.
;
;   This function is called independently to set s_PreserveSplashWindow and is
;   used by the SplashOff function to determine if the splash window should be
;   preserved or not.
;
;
;
;   Parameters
;   ==========
;
;       Name                    Description
;       ----                    -----------
;       p_PreserveSplashWindow  Determines whether the splash window is
;                               preserved or not.  [Optional]  The default is
;                               FALSE or whatever it was set to last.
;
;                               Set to TRUE to preserve the splash window.  Set
;                               to FALSE to no longer preserve the splash
;                               window.
;
;
;   Calls To Other Functions
;   ========================
;   (None)
;
;
;-------------------------------------------------------------------------------
PreserveSplashWindow(p_PreserveSplashWindow="")
    {
    static s_PreserveSplashWindow

    ;-- Parameter?
    if p_PreserveSplashWindow is not Space
        s_PreserveSplashWindow:=p_PreserveSplashWindow


    ;-- Return to sender
    if s_PreserveSplashWindow
        return true
     else
        return false
    }


Examples Of Use
Here are a few informational, non-working examples of how these routines might fit into everyday code:

;***** EXAMPLE 1 - Start Firefox
^#!f::
IfWinExist Mozilla Firefox Start Page  ;-- My FF start page. Change to fit.
    WinActivate
 else
    {
    [color=brown]SplashOn("Starting Firefox...")[/color]
    run "C:\Program Files\Mozilla Firefox\firefox.exe"
    WinWait Mozilla Firefox Start Page,,20
    [color=brown]SplashOff()[/color]
    }
return


;***** EXAMPLE 2 - Winamp: What you might see when requesting a track change
^#!PgDn::
[color=brown]SplashOn("Winamp: Next Track","Lenny Kravitz - Can't Get You Off My Mind (4:26)",3)[/color]  ;-- Display for 3 seconds
[color=brown]SplashOff()[/color]
return



;***** EXAMPLE 3 - Shutdown/Restart computer
^#!F5::

[color=brown]PreserveSplashWindow(true)[/color]

;----
; This section could include a bunch of pre-shutdown routines, some of
; which display their own splash windows.
;----

;-- Splash On
[color=brown]SplashOn("Restarting computer...")[/color]
;-- No need for a SplashOff since the computer is rebooting...

;-- Reboot computer
sleep 400
Shutdown 2
ExitApp
The following are working (but not very practical) examples of use:
SplashOn("These Are...","One - Default Everything")
Sleep 4000

SplashOn("...Just A..."
    ,"Two - Arial, Left Top"
    ,0
    ,"Arial"
    ,"FM14 FS12 XLeft YTop")
Sleep 4000

SplashOn("...Few Quick..."
    ,"Three - Courier New, Middle Top"
    ,0
    ,"Courier New"
    ,"FS16 XM YTop")
Sleep 4000

SplashOn("...Splashes As..."
    ,"Four - Lucida Console, Top Right"
    ,0
    ,"Lucida Console"
    ,"FM16 WM400 FS16 CWBlack CTYellow XR YT")
Sleep 4000

SplashOn("...An Example Of..."
    ,"Five - MS Sans Serif, Middle Bottom"
    ,0
    ,"MS Sans Serif"
    ,"FM8 FS18 CWMaroon CTAqua XMiddle YBottom")
Sleep 4000

Splashon("...What This Stuff Looks Like."
    ,"Six - Tahoma, Left Middle"
    ,0,"Tahoma"
    ,"FS16 XLeft YMiddle")
Sleep 4000

String=
   (ltrim join`s
    This is a relatively long string displayed with a large font size.  This was
    created to show how wide a window can be drawn.  Notice that the information
    automatically wraps and is centered (default feature of the SplashImage
    command).
   )
SplashOn("Seven - Times New Roman",String,0,"Times New Roman","FM10 FS28")
Sleep 12000

SplashOn("We're done!","Eight - Verdana",3,"Verdana")
sleep 4000
ExitApp

References
The following include documentation and posts that I used to research this mini-project. Thank you for your contribution.

SplashImage documentation
http://www.autohotke...ds/Progress.htm

SplashImage Maker - WYSIWYG
http://autohotkey.co...opic.php?t=2033

SplashText Sizer - WYSIWYG
http://autohotkey.co...opic.php?t=1201

Dynamic SplashText
http://autohotkey.co...topic.php?t=119


Final Thoughts
Although the defaults in the code will probably work fine for most, they reflect my requirements. Please feel free to modify them for your use.

I hope that someone finds this useful.


---------------------------------------------------------------------------
v1.0
First general release. Minor modifications. Documentation updated.


v0.2 (Alpha):
A few significant modifications:
[*:ml9o3don]Removed the p_MainTextFontSize and p_SubTextFontSize parameters. These values are now entered via the p_Options parameter. See the documentation for instructions.
[*:ml9o3don]The p_MinimumSplashTime parameter can now contain a negative value to indicate an automatic SplashOff. See the documentation for more information. [Thanks majkinetor]
[*:ml9o3don]Function specific X/Y options have been added to support positioning the splash window in the left, right, top, etc. See the documentation for more information. [Thanks majkinetor]Updated documentation.
Updated examples.


v0.1 (Alpha):
Original release.


PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Looks nice and useful, thanks.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
Nice work jballi, highly proffesional as always.
Posted Image

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
One little request - timeout after which splash is closed so there is no need for splashoff. It would be good to specify it as negative minimum, for instance:

SplashOn("main text goes here", "sub text goes here", [color=orange]-3[/color], "Courier", 16, 12,   "CWBlack CTYellow" )

means it will autoclose after 3 seconds

I also think you could add the font style, not only font face name. It can be in native format, for instance

"Courier New, s12 bold"

This will make params p_SubTextFontSize and p_MainTextFontSize obsolete, so you can get one param less. For instance, instead

SplashOn("Six - Tahoma",String,0,"Tahoma",10,26)

it would be better

SplashOn("Six - Tahoma",String,0,"Tahoma, s10", "Courier, s26")

Both sytle or font face should be optional.

Next one would be region. You can provide some basic regions, like rounded window etc.

Next one should be position. I imagine it to be in XY format where X and Y can be LMRTB (left, midle, right, top, bottom), so to pop up from tray, parameter will be RB. Middle of the screen: MM, etc.

This is pretty much needed IMO. Good splash screen should be entirely customizable.

Other then that, you should think about specifying large set of options inside single string, check out the MMenu for example. This allows only some to be set and you can leave rest to default. For instance, this is kewl

SplashText(Title, Subtitle, Options)

and I can latter say:
SplashOn(Title, SubText, "SCourier T3")

to have subtext use courier and splash automaticaly to close after 3 seconds. This way you have much shorter and cleaner looking function call. This is actually workaround for AHK not alowing named parameters.
Posted Image

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
majkinetor, Thanks for your post. I will try to respond to all of your feedback but if I miss something, let me know and I'll try to respond.

One little request - timeout after which splash is closed so there is no need for splashoff. It would be good to specify it as negative minimum... [snip]

A good idea and it should be easy to implement. I'll take a look/see.


I also think you could add the font style, not only font face name. It can be in native format, for instance

"Courier New, s12 bold"

This will make params p_SubTextFontSize and p_MainTextFontSize obsolete, so you can get one param less. For instance, instead

SplashOn("Six - Tahoma",String,0,"Tahoma",10,26)

it would be better

SplashOn("Six - Tahoma",String,0,"Tahoma, s10", "Courier, s26")

Both sytle or font face should be optional.

Font "style" (aka font weight) is a built-in feature of the SplashImage command and therefore is an available option of the SplashOn function via the p_Options parameter. See the SplashOn documentation for more information.

The p_Font, p_MainTextFontSize, p_SubTextFontSize parameters were created for a reason and yes, I am aware that they appear to be (could made to be) redundant.

One of the neat features of the SplashOn function is auto-sizing. Well, I like it! Auto-sizing the height is a built-in feature of the SplashImage command but calculating the width is accomplished by creating a temporary GUI that ascertains the width by rendering (but not showing) a window with the potential splash text. The only way this works if you have all the pieces of the puzzle. The pieces include the text, the font, the font size, and the font weight. For this function, the fastest way to get from point A to point B is to demand what you need (the text) and default and/or "make optional" the rest. For the auto-width feature, the required pieces of the puzzle were turned into optional parameters. I do like the idea of collecting this information directly from the p_Options parameter but it might require a potentially nasty parsing routine. I will put some brain power into it.


Next one should be position. I imagine it to be in XY format where X and Y can be LMRTB (left, midle, right, top, bottom), so to pop up from tray, parameter will be RB. Middle of the screen: MM, etc.

A good idea. Some of these options are already available by default or via the X/Y options supported by the SplashImage command (set in the p_Options parameter). The following are a few examples:
M (Middle). This is the default.
L or LM (Left, Middle). Add "x0" to p_Options.
LT (Left, Top). Add "x0 y0" to p_Options.
TM (Top, Middle). Add "y0" to p_Options.
And minor offsets are easy. "x10" or "x10 y10" will add a little breathing room to the window.

The rest of the options (R, and B) cannot be done without calculations (or guessing). R (Right) should be (?) a fairly straightforward calculation but B (Bottom) might require that the window be rendered in order to collect the actual window dimensions so that the bottom X/Y can be calculated. I'll give it some thought.


Next one would be region. You can provide some basic regions, like rounded window etc.

I'm not exactly sure what you're looking for here. Could you give me a more specific example?


... Good splash screen should be entirely customizable.

As I hinted to in the main post, these routines were designed to be a simple Splash-'N-Go solution. That doesn't mean that simple can't be powerful but I don't want lose sight of the main objective.

All in all, good/excellent ideas. Thanks for your feedback.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006

but calculating the width is accomplished by creating a temporary GUI that ascertains the width by rendering (but not showing) a window with the potential splash text.

I guess you can calc with this:
GetTextSize(pStr, pFont="")

It returns the width & height of the text so you can determine GUI size before you show it. You can also do this for XY as if you know the gui size and screen size....

The above function is someting I am puting together for HexView. pFont is standard AHK font expression ( style, fontface )

I'm not exactly sure what you're looking for here. Could you give me a more specific example?

Rounding window is window that have rounded corners :D Looks better. See WinSet, Region for detail about making custom shapes. It would be cool to hardcode couple of them, like rounding window, circle, elipse etc.. but I guess it may complicate another parts of the code for size calcuations etc. So, we can leave without this, but if you dont' have anything smarter do to, and want to have fun...

I do like the idea of collecting this information directly from the p_Options parameter but it might require a potentially nasty parsing routine.

Not at all. Check out the MMenu parseItemOptions and parseMenuOptions to see easy and effective parsing routine, which limitation is only to have one letter parameter names, which is in this case good as you don't have many parameters.


Thx
Posted Image

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
First post has been updated with a new version (v0.2). See the bottom of the post for an update history.

Let me know if you have any questions/problems/etc.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
Good work. Looks much better. As I see it, only add different fonts for text and sub and you can close it for good. The problem is that u used SplashImage to create your function so you can't escape its limitations.


This is something I added, check it out.

SplashImage 8:,W%l_SplashImageWidth% %l_Options%
            ,%p_SubText%
            ,%p_MainText%
            ,SplashOn_Window
            ,%p_Font%


	[color=brown]WinGetPos, , , , h, SplashOn_Window
    	WinSet, Region, 0-0 W%l_SplashImageWidth% H%h% R20-20, SplashOn_Window
	WinSet, Transparent, 180, SplashOn_Window[/color]

I wonder why did you choose to use SplashImage at all. It only limits your possibilities.
Posted Image

Grumpy
  • Guests
  • Last active:
  • Joined: --

I wonder why did you choose to use SplashImage at all. It only limits your possibilities.

Because 90% of hard work (WinAPI calls) is already made?

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005

I wonder why did you choose to use SplashImage at all. It only limits your possibilities.

Because 90% of hard work (WinAPI calls) is already made?

Grumpy is right. The SplashImage command was designed to create a splash window. It has a bunch of built-in capabilities that would take bunch of code to duplicate. I only created these routines to fill in in a few of the gaps. However, the SplashImage window is just a window and just like your example shows, you still can do stuff to it.

Thanks for your feedback.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
Yeah, wrong thought. You can change font of subtext also, using API, although SplasImage doesn't allow that.
Posted Image

SplashGuy
  • Guests
  • Last active:
  • Joined: --
This is a really nice function! Very useful and saved me a lot of work!

I have a question. How can I avoid flickering, when I call this function repeatedly?

Thanks!

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005

I have a question. How can I avoid flickering, when I call this function repeatedly?

Flickering is an unfortunate side effect of calling the SplashOn function repeatedly with the same (or similar) content. The reason: The Splash window is repeatedly destroyed and recreated in the same window area.

One workaround is to update the splash window directly after it has been initially created. Here's an example:

#NoEnv
SplashImage 8:,w300 b2,Initial SubText,Initial MainText,SplashOnWindow

Sleep 2000

loop 250
    {
    ControlSetText Static1,% "MainText: " . A_Index,SplashOnWindow
    ControlSetText Static2,% "SubText: " . A_Index,SplashOnWindow
    sleep 1
    }

return

Of course this workaround is only practical if the size of the splash text remains relatively static.

I hope this helps.

SplashGuy
  • Guests
  • Last active:
  • Joined: --
Thanks a lot, I understand now. I guess I can live with the flickering. I just hoped there was a way to avoid this with SplashOn.

SplashGuy
  • Guests
  • Last active:
  • Joined: --
I think i solved the problem - for my needs at least

In case SplashOne is called with the same parameters (and maybe only sub_text is different) and the previous splashwindow is still displayed, then I just reset the timer, without destroying and recreating the splash window. This stops the flickering. See the change below

Of course

I added after global $Splash_StartTime, $Splash_MinimumTime
the following
static old_p_MainText=""
static old_p_SubText=""
static old_p_MinimumSplashTime=""
static old_p_Font=""
static old_p_Options=""


If (old_p_MainText=p_MainText
and old_p_SubText<>p_SubText
and old_p_MinimumSplashTime=p_MinimumSplashTime
and old_p_Font=p_Font
and old_p_Options=p_Options)
{
    ;-- Restart the SplashOff timer
    if (WinExist("SplashOnWindow")<>0)
    {
        SetTimer SplashOff_Timer,%Splash_MinimumTime%
        ControlSetText Static2,%p_SubText% ,SplashOnWindow 
        old_p_SubText:=p_SubText
        return
    }
}

If (old_p_MainText=p_MainText
and old_p_SubText=p_SubText
and old_p_MinimumSplashTime=p_MinimumSplashTime
and old_p_Font=p_Font
and old_p_Options=p_Options)
{
    ;-- Restart the SplashOff timer
    SetTimer SplashOff_Timer,%Splash_MinimumTime% 
    return
}


old_p_MainText:=p_MainText
old_p_SubText:=p_SubText
old_p_MinimumSplashTime:=p_MinimumSplashTime
old_p_Font:=p_Font
old_p_Options:=p_Options