Image Splash

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SimPlayer
Posts: 128
Joined: 01 Apr 2016, 05:57

Image Splash

14 Dec 2017, 08:33

Hi

Just got the Image Splash working, example;

F1::SplashImage, C:\Picture.bmp, b
F2::SplashImage, Off

But, I would like to splash the image by PRESSING (and holding down) the F1 key,

and

run the SplashImage, Off command by RELEASING the F1 key.

How is this done?

thanks,
User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: Image Splash

14 Dec 2017, 08:55

Code: Select all

F1::
SplashImage, C:\Picture.bmp, b
KeyWait, F1
SplashImage, Off
return
User avatar
TheDewd
Posts: 1510
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Image Splash

14 Dec 2017, 08:55

@boiler has a good solution. Here's a more complicated solution just to show the different approaches to the same end result.

Code: Select all

#SingleInstance, Force

SplashToggle := 0

F1::
    SplashToggle := 1

    While (GetKeyState("F1", "P")) {
        If (SplashToggle) {
            SplashImage, C:\Picture.bmp, B
            SplashToggle := 0
        }
    }

    SplashImage, Off
return
User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: Image Splash

14 Dec 2017, 09:04

TheDewd: Note that the toggle is just adding unnecessary complication.

Code: Select all

F1::
	SplashImage, C:\Picture.bmp, B
    While (GetKeyState("F1", "P"))
		continue
    SplashImage, Off
return
(and using GetKeyState and a loop that just waits for a key release is easily accomplished by KeyWait)

I agree it's good to show multiple approaches, though. There are cases where you want to use a loop like you've shown, especially when you need to perform some code while waiting for the release.
SimPlayer
Posts: 128
Joined: 01 Apr 2016, 05:57

Re: Image Splash

14 Dec 2017, 11:36

Hi,
and thanks for all the great stuff!
SimPlayer

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Google [Bot], Theda and 133 guests