no-frills SplashImage Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
jeeswg
Posts: 4509
Joined: 19 Dec 2016, 01:58
Location: UK

no-frills SplashImage

07 Mar 2018, 22:16

I'm trying to write some code to simply display an hBitmap on the screen. I'm trying to do so without using any user-defined functions. The script works, however, there is one flaw mentioned below, if anybody can find a fix for it.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by jeeswg on 08 Mar 2018, 04:49, edited 2 times in total.
User avatar
Masonjar13
Posts: 1333
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: no-frills SplashImage  Topic is solved

07 Mar 2018, 22:31

Perhaps I don't understand, but there is no minimum window size. I have a script that uses a 1x1 window, no caption, and definitively shows as 1x1 when checked. Likewise, I have a screenshot script that allows to make floating images. I've just now tried and got a 15x15 with no distortion. Is it different for Windows 10?

Edit: more specifically, I have the windows with -dpiscale +alwaysOnTop -caption +toolWindow and a picture control. The image is an HBitmap set by the same 0x172 message.
User avatar
jeeswg
Posts: 4509
Joined: 19 Dec 2016, 01:58
Location: UK

Re: no-frills SplashImage

07 Mar 2018, 22:40

- Interesting info.
- I use Windows 7. When you run my script, it alternates between 2 sizes, are they both square, or is one of them a distorted rectangle? Thanks.

- [EDIT:] Thanks very much, using WS_EX_TOOLWINDOW := 0x80 has fixed the script, I've corrected it in the script below. I changed vWinExStyle:=0x8 to vWinExStyle:=0x88.

- [EDIT:] I got so fixated trying to change SM_CXMIN/SM_CYMIN, which I haven't found an answer to (yet?). That I didn't think to explore window styles. To change the minimum size for a individual window, involves responding to a SendMessage (WM_GETMINMAXINFO) in the recommended solutions.
- It seems vaguely familiar being able to set a window to *any* size, but I don't specifically recall resizing a window to zero manually, with the mouse.

- While SplashImage has no alternative in AutoHotkey v2, I wanted a short-enough-to-share-on-the-forum script that was two-way compatible, and that didn't use the AHK v1 Gui command (and thus that didn't make the script #Persistent).

- [EDIT:] Btw try resizing Notepad to the minimum size. You essentially get a small amount of the title bar, but you can't make it any smaller.
Last edited by jeeswg on 07 Mar 2018, 23:03, edited 1 time in total.
User avatar
jeeswg
Posts: 4509
Joined: 19 Dec 2016, 01:58
Location: UK

Re: no-frills SplashImage

07 Mar 2018, 23:01

Fixed script.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by jeeswg on 08 Mar 2018, 04:50, edited 2 times in total.
User avatar
Masonjar13
Posts: 1333
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: no-frills SplashImage

07 Mar 2018, 23:05

Unless LoadPicture() is a built-in v2 function, your above script can't be tested. I use v1.1 and don't have LoadPicture() in my stdlib. It also creates a window that still has a caption, was that on purpose?
User avatar
jeeswg
Posts: 4509
Joined: 19 Dec 2016, 01:58
Location: UK

Re: no-frills SplashImage

07 Mar 2018, 23:33

- Re. LoadPicture:
LoadPicture
https://autohotkey.com/docs/commands/LoadPicture.htm#commands/LoadPicture.htm
[v1.1.23+]
- Re. caption. I wanted the image to display at roughly the correct ratio, that was the only criterion. I'm looking at short scripts for splashing text/images, based on the fact that Progress/SplashImage(/SplashTextXXX) are due to be removed from AutoHotkey v2, and so I wanted replacement functions with basic functionality for diagnostic tests that would work in both AutoHotkey v1 and v2, and that wouldn't cause a script to become #Persistent (which the Gui command does).
User avatar
Masonjar13
Posts: 1333
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: no-frills SplashImage

07 Mar 2018, 23:44

Oh, interesting. Well in that case, the image just doesn't load for some reason. I'm just getting a plain white window. I'm not terribly understanding of why it matters if the script is persistent or not (I'd prefer it to default persistent), as any hotkey will do that anyway, and I find more consistency in simply using ExitApp. Makes sense to have a replacement ready, though.
User avatar
jeeswg
Posts: 4509
Joined: 19 Dec 2016, 01:58
Location: UK

Re: no-frills SplashImage

07 Mar 2018, 23:52

- The issue with #Persistent is this. I have various background scripts that run temporarily, briefly. They use functions from various libraries. If one of those libraries has something in it that causes persistence, then those background scripts won't close unless I rewrite them to force close themselves.
- Every so often it's a cause of dismay when I realise that none of my background scripts have closed, because persistence was somehow invoked.
User avatar
Masonjar13
Posts: 1333
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: no-frills SplashImage

08 Mar 2018, 00:15

No offence, but I'd say you should never rely on a return to do the job of an ExitApp.

Back on-topic, even using a different image, the window shows blank. Why is that? Or was that not working in the first place and you were just getting the dimensions correct?
User avatar
jeeswg
Posts: 4509
Joined: 19 Dec 2016, 01:58
Location: UK

Re: no-frills SplashImage

08 Mar 2018, 04:40

I've fixed both scripts, they needed DetectHiddenWindows, On.
User avatar
Masonjar13
Posts: 1333
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: no-frills SplashImage

08 Mar 2018, 21:03

Now that you've said it, seems really obvious :lol: But I couldn't help myself; I frilled it a little bit. Consider it a fork? Though, it should be cross-compatible still, except for maybe the SplitPath, but that's a supplementary function anyway.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
jeeswg
Posts: 4509
Joined: 19 Dec 2016, 01:58
Location: UK

Re: no-frills SplashImage

11 Apr 2018, 23:55

tl;dr: drawing image onto window works temporarily, not permanently

- I've been looking at the source code for SplashImage. (The function is called Splash() and is in script2.cpp, with further code in MainWindowProc().) I've created the script below based on it. Like SplashImage, it draws directly onto the GUI and doesn't use a Static control. However, the image disappears if you focus another window. Can this be fixed?
- This drawing technique would be a really useful general technique.
- Also, which uses less memory, drawing onto the GUI, or using a Static control? Thanks.
- [EDIT:] Note: the script as it is is great, you can draw onto Notepad, and then focus away and come back, and the image is gone, thus it's great for drawing temporarily on the screen.
- [EDIT:] I've added a hotkey which can redraw the image.
- [EDIT:] This script produces a permanent image, but unlike SplashImage, the image is not retrieved by certain printscreen techniques.
graphics: kaleidoscope/brush mirrors - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=35597

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
jeeswg
Posts: 4509
Joined: 19 Dec 2016, 01:58
Location: UK

Re: no-frills SplashImage

12 Apr 2018, 22:16

I have a fix, I'll be posting shortly, the script needs to handle WM_ERASEBKGND.
[EDIT:] Here's the fix:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Return to “Ask For Help”

Who is online

Users browsing this forum: Rohwedder and 18 guests