Splashy: A SplashImage Replacement

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
lmstearn
Posts: 694
Joined: 11 Aug 2016, 02:32
Contact:

Splashy: A SplashImage Replacement

28 Jul 2021, 08:07

Welcome to Splashy!

Image

Intro:
A while back, one of our erstwhile frequent posters had the idea of providing a no-frills SplashImage replacement. In response, the script in Splashy has been extended to provide the basic SplashImage functionality, plus one or two (no thrills) extras. Essentially, Splashy displays an image that can be referred to in conjunction with a running script.

Why?
Recommended for use in a script by greeting, transition, or any other purpose to illustrate or highlight some feature or subject of topical interest.

The best way to see how Splashy works is to run the SplashyTest script below.

Features:
  • Handles multiple images.
  • Enables parent window control.
  • Handles optional image url by download.
  • Optional main (top) & sub (bottom) text labels.
  • Optional transparent background for image and text.
  • Optional window hide, activation, movable and onTop toggles.
  • Optional margins and extra border styles.
  • Optional text, its colour, and background colour.
  • Optional Font name, size, weight, and quality.
  • Optional standard font effects: quality, italic, strike, and Underline.
  • Optional embedded png type images.
  • An additional interface, SplashyTest, for testing and sandboxing.
Usage:
Place the class in the script and make the function reference like:

Code: Select all

SplashRef := Splashy.SplashImg
And call it as follows:

Code: Select all

%SplashRef%(Splashy, {comma separated Splashy parameter list}*)
To call with all (base) default parameters set, just use

Code: Select all

%SplashRef%(Splashy, {})
Or call with any number of the following parameters set, in no particular order:

Code: Select all

%SplashRef%(Splashy, {initSplash: boolValue, instance: value, parent: boolValue, imagePath: pathString

, imageUrl: urlString, bkgdColour: colourStringorVal, transCol: boolValue, vHide: boolValue

, noHWndActivate: boolValue, vOnTop: boolValue, vMovable: boolValue, vBorder: borderString

, vImgTxtSize: boolValue, vPosX: value, vPosY: value, vMgnX: value, vMgnY: value, vImgW: value, vImgH: value

, mainText: string, mainBkgdColour: colourStringorVal

, mainFontName: string, mainFontSize: value, mainFontWeight: value, mainFontColour: colourStringorVal

, mainFontQuality: value, mainFontItalic: boolValue, mainFontStrike: boolValue, mainFontUnderline: boolValue

, subText: string, subBkgdColour: colourStringorVal

, subFontName: string, subFontSize: value, subFontWeight: value, subFontColour: colourStringorVal

, subFontQuality: value, subFontItalic: boolValue, subFontStrike: boolValue, subFontUnderline: boolValue}*)

Note the asterisk "*" after the closed curly brackets. To reset and quit Splashy, reclaiming some memory,

Code: Select all

%SplashRef%(Splashy, {release: 1}*)
Parameters:
  • The spoiler lists the parameters accompanied by brief descriptions:
Spoiler

Notes:
  • Splashy parameter values are not case sensitive.
  • When release is set in the call, all other parameters in the list are ignored.
  • If a parameter is not expressed in key: value form, the script will terminate. Keys not in the above list are ignored, and values are limited to either a numerical quantity or a literal (quoted) string.
  • InitSplash is used to reset all the key: value combinations not included in the current Splashy parameter list to their (base) defaults, consequently initSplash has no effect in the first call from the originating thread. Existing windows are not destroyed.
  • InitSplash, instance, and release are the only parameters which are not saved between calls of Splashy, thus automatically reverting to default values if not set again in a following call.
  • A new "instance" of the Splashy image is created when specifying some index other than what is contained in the set of existing instances {1, 2, ..., MaxGuis := 1000}. Only one new image instance can be created with each call of Splashy, it will inherit the attributes of the last instance, along with any other updated attributes in the current Splashy parameter list. Alternatively, if a number in the preceding set {1, 2, ...} is entered, updates will be made to the corresponding numbered instance of Splashy image. If the number in the preceding set is prefixed with a minus sign, the corresponding Splashy image instance will be removed. A non-numeric or zero value defaults to 1, and larger negative values are ignored.
  • A limitation of Splashy is borders cannot be used for sizing images. All existing borders are reset and replaced with those specified in the most recent pass of vBorder.
  • Splashy sets margins by positioning the controls rather than call Gui, Margin, however there is no top margin, due to programmatical issues relocating the image in the DC.
  • If a key: value pair combination is omitted, or a value is invalid for the key, the previous non empty value for the key is used, else the key assumes (base) default values. Font strings are handled as with the AHK GUI command, other values undergo usual validation schema.
  • As with AHK, truncation occurs when the text length exceeds image width unless vImgTxtSize is used.
  • To generate an embedded png image, run ImageToInclude and copy the generated string into the PicInScript variable found in GetPicWH() function. From the generated Create_Your_png.ahk script, copy the value for the image size into the preceding VarSetCapacity statement. Finally, to launch the image, insert an asterisk "*" in the ImagePath string variable.
  • The file handling of the image is always performed in the directory where the Splashy script is called.
  • Image type precedence:
    The short:
    ImagePath overrides the imageUrl field.

    The long:
    If the imagePath is valid, the imageUrl is ignored. To use imageUrl, specify the imagePath as empty (or invalid) if it has already been set and valid. Thus, if the imagePath is invalid, the imageUrl is used, and the saved imageUrl file will assume the name constituent in the non-empty imagePath field, else it uses its own. In this way, the imagePath field can be used by the caller to track multiple url downloads.
    If both the imagePath and imageUrl fields are invalid, the default AHK wallpaper is downloaded and used for the image.
Colours:
  • Colours can be either selected from the list in the spoiler:
    Spoiler
    … or a quoted 6 digit RGB hex value (0X prefix is optional). If the value is not quoted, it must then be preceded by 0X, else any colour values beginning with a letter will be treated as blank variables, producing a black background.
  • When transCol is used, margins are automatically set to 0, and text background colours are set to the image background colour.
SplashyTest:
Image

This utility demonstrates the capabilities of Splashy. The items in the GUI of SplashyTest (based on Speedmaster's playlist)) are arranged as per the Splashy function as described above. It features:
  • A basic Font dialog for testing. The main limitations are that the font sizes in the up/down control are not saved to the Splashy gui, and the font names are retrieved from the script only, not system enumerated or checked.
  • A standard colour selection dialog for the colours in Splashy, the null value is not available.
  • A dialog for input of either a FileSelect for the ImagePath or an asterisk "*" for the embedded image.
  • Parameters like vBorder which can accept an empty value in the class when intended for removal, will (instead of the null value), either accept 0 in the SplashyTest dialog or be switched off there for the same effect.
The way the gui works is:
  1. Button which is Off: Toggle on (in some cases prompt to insert value). Value, text, font, or colour dialogs can be cancelled with no change.
  • Button which is On: Click will not de-activate the item in the gui- it simply Removes it from the function call, where the value just set remains stored in the class (lime-green).
  • Other values and strings use input boxes which do not support multiline.
  • Button with Removed value: Click will either toggle off the item, removing it from the class, or prompt for another value. If it is a value, text, font, or colour, the usual prompts appear again, along with the option of cancelling out with no change.
Issues:
  • If the calling script has GdiplusStartup already active, then comment out the lines containing that along with GdiplusShutdown and hGDIPLUS.
  • If a portion of the form is positioned or moved off the current monitor, then back on the current monitor, the portion of corresponding text may not repaint, even after a call of PaintDC. Possibly repairable.
  • With the movable option on, moving the form with text either across the edge of the parent form or screen rapidly, may cause a function like SelectObject to fail, or even Splashy/AHK to deadlock in very rare cases.
  • Text and margins may not be visible while moving Splashy in a newly set parent form, especially when moved outside the parent window borders, due to internal windows modal loops. Text is generally visible in the parent in later calls of Splashy.
  • No sizing borders intended for implementation in Splashy.
  • Specifying c for vPosX or vPosY in the first call centres Splashy as expected, but the co-ordinate values then default to last position in subsequent Splashy calls. This is "by design" (for testing), and not applicable when c is first set in later calls of Splashy.
  • Depending on CPU Hz, larger images might offer slower load times along with jerky script response. Images less then a megabyte in size should not be deterrent to Splashy's performance, however.
  • Certain commented sections of code are retained for the possible implementation of Marquee. They can be removed as per feedback.
WishList:
  • Provision for more than one embedded image, possibly referenced by something like (**, ***, ****, ...).
  • Provision for image fade/materialize.
  • Provision for image to (auto) scroll in the viewport.
  • Non rectangular borders for text & image.
  • Marquee text scrolling. Can be done, but the entire text gui creation section has to be refactored.
  • Provision for text following a specified curve.
  • Provision for animated images.
  • Provision for more "non-standard" image types. Nice, albeit more of a convenience, as there are many graphic programs that can do this already.
  • As with parent windows, owner windows with Splashy are certainly possible, and warrant inclusion in a later release.
Versions
AHK v1: Download. (The class is already in SplashyTest)
1.0 Beta:
  • Initial release
1.1 Beta Update:
  • Minor code twiddles
  • Fixed test gui buttons after release
1.2 Beta Update:
  • Multiple Splashy instances
  • Better class management
  • Further clarifications in the docs
  • Parent window option
1.3 Beta Update:
  • Introduce vImgTxtSize: size image to text
  • Removed vCentre as redundant
  • Refactor code for text controls
  • Refactor SplashyTest code
AHK v2: In the pipeline.

1.4 Beta Update:
  • Fixed Instance defaults
  • Fixed parentIn
1.5 Beta Update:
  • Fixed variable initializations
1.6 Beta Update:
  • Better GDI error handling
1.7 Beta Update:
  • Fixed paint issues in 1.6 update
Credits:
Many thanks to the AutoHotkey community! :thumbup:
Last edited by lmstearn on 05 Jun 2022, 09:56, edited 37 times in total.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
User avatar
lmstearn
Posts: 694
Joined: 11 Aug 2016, 02:32
Contact:

Re: Splashy: A SplashImage Replacement

28 Jul 2021, 08:09

1.1 Beta up.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
User avatar
lmstearn
Posts: 694
Joined: 11 Aug 2016, 02:32
Contact:

Re: Splashy: A SplashImage Replacement

03 Feb 2022, 23:23

1.2 Beta up.

1.3 Beta up.

Spoiler
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
User avatar
lmstearn
Posts: 694
Joined: 11 Aug 2016, 02:32
Contact:

Re: Splashy: A SplashImage Replacement

06 Apr 2022, 04:48

1.4 Beta up (for minor bugs)
1.5 Beta up (variable fixes thanks to #Warn All)
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
User avatar
lmstearn
Posts: 694
Joined: 11 Aug 2016, 02:32
Contact:

Re: Splashy: A SplashImage Replacement

15 May 2022, 09:33

1.6 Beta up.
The above SplashyRoadTest code might skip a bitmap render pass on in every ~1000 iterations. Sometimes it can spit a BitBlt fail, this seems to less likely occur with Try & Catch than just the standard If block.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
User avatar
lmstearn
Posts: 694
Joined: 11 Aug 2016, 02:32
Contact:

Re: Splashy: A SplashImage Replacement

05 Jun 2022, 10:07

1.7 beta up.
As the last update (not properly tested as it turned out) skipped the paint on some child window updates and in a few cases, top level forms, a tentative compromise is proposed in the code of this iteration. Let's hope it sticks. :)
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 124 guests