Create custom msgbox

Get help with using AutoHotkey and its commands and hotkeys
yabab33299
Posts: 57
Joined: 06 May 2020, 17:16

Create custom msgbox

17 May 2020, 10:05

Is there a way to create a msgbox message without pressing OK. The message will disappear by itself after a few seconds while the script itself is running.
Albireo
Posts: 1188
Joined: 16 Oct 2013, 13:53

Re: Create custom msgbox

17 May 2020, 10:33

Maybe ToolTip kan help?

or a MsgBox with timer!
Like this!

Code: Select all

MsgBox,,, Hello! :-) ,2
will disappear after 2 seconds.
User avatar
boiler
Posts: 5237
Joined: 21 Dec 2014, 02:44

Re: Create custom msgbox

17 May 2020, 10:37

Also, SplashText might be an alternative if you don't want it to have a button. You can have it disappear using either Sleep or SetTimer.
Rohwedder
Posts: 3091
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Create custom msgbox

17 May 2020, 12:05

Or you make the MsgBox gradually disappear:

Code: Select all

SetTimer, Transparent, -1000
MsgBox,,, Hello! :-) ,6
Transparent:
While, WinExist("ahk_class #32770 ahk_exe AutoHotkey.exe")
{
	WinSet, Transparent,% 256-A_Index*5
	Sleep, 100
}
yabab33299
Posts: 57
Joined: 06 May 2020, 17:16

Re: Create custom msgbox

17 May 2020, 12:28

Albireo wrote:
17 May 2020, 10:33
Maybe ToolTip kan help?

or a MsgBox with timer!
Like this!

Code: Select all

MsgBox,,, Hello! :-) ,2
will disappear after 2 seconds.
Hi there. How do I make the msgbox disappear after 30 seconds. But I don't want the next command to wait 30 seconds. I need the next command to run right after the msgbox appears while the msgbox just waits tills its 30 seconds is up.
User avatar
boiler
Posts: 5237
Joined: 21 Dec 2014, 02:44

Re: Create custom msgbox

17 May 2020, 13:32

That's a reason to use something like SplashText, ToolTip, or create a small GUI. You can display it, set a SetTimer to close it in 30 seconds, and continue with your code in the meantime.

Or you can have the rest of your code continue in another thread after a label triggered by a SetTimer that starts after the MsgBox displays, similar to Rohwedder's example where it fades the MsgBox out. Instead of fading it out, you would just have the rest of your code there. Example:

Code: Select all

SetTimer, NewThread, -1000
MsgBox,,, Hello, 30

NewThread:
; some example other stuff your code could be doing in parallel to the MsgBox
	Run, notepad.exe
	WinWait, ahk_exe notepad.exe
	loop, 500 {
		WinMove, ahk_exe notepad.exe,, A_Index, A_Index
		Sleep, 100
	}
return

Esc::ExitApp
Albireo
Posts: 1188
Joined: 16 Oct 2013, 13:53

Re: Create custom msgbox

17 May 2020, 13:43

in your case I should use set timer / SplashText or TootTip (not MsgBox)
User avatar
boiler
Posts: 5237
Joined: 21 Dec 2014, 02:44

Re: Create custom msgbox

17 May 2020, 13:46

Albireo wrote:
17 May 2020, 13:43
in your case I should use set timer / SplashText or TootTip (not MsgBox)
A MsgBox could be used in a separate thread like the script posted in my prior post. (added it a few minutes later, so perhaps you missed it)
Albireo
Posts: 1188
Joined: 16 Oct 2013, 13:53

Re: Create custom msgbox

17 May 2020, 13:54

boiler wrote:
17 May 2020, 13:46
Albireo wrote:
17 May 2020, 13:43
in your case I should use set timer / SplashText or TootTip (not MsgBox)
A MsgBox could be used in a separate thread like the script posted in my prior post. (added it a few minutes later, so perhaps you missed it)
(excuse me) thank you!
garry
Posts: 2282
Joined: 22 Dec 2013, 12:50

Re: Create custom msgbox

17 May 2020, 14:05

maybe set timer off if continue in Label A1

Code: Select all

SetTimer,A1,100
;gosub,a1
msgbox, 262208,CLOSE in 6 SECONDS ,Hello! :-)`n I CLOSE in 6 seconds ,6
exitapp
A1:
settimer,A1,off
run,charmap
return
yabab33299
Posts: 57
Joined: 06 May 2020, 17:16

Re: Create custom msgbox

27 May 2020, 14:08

boiler wrote:
17 May 2020, 13:32
That's a reason to use something like SplashText, ToolTip, or create a small GUI. You can display it, set a SetTimer to close it in 30 seconds, and continue with your code in the meantime.

Or you can have the rest of your code continue in another thread after a label triggered by a SetTimer that starts after the MsgBox displays, similar to Rohwedder's example where it fades the MsgBox out. Instead of fading it out, you would just have the rest of your code there. Example:

Code: Select all

SetTimer, NewThread, -1000
MsgBox,,, Hello, 30

NewThread:
; some example other stuff your code could be doing in parallel to the MsgBox
	Run, notepad.exe
	WinWait, ahk_exe notepad.exe
	loop, 500 {
		WinMove, ahk_exe notepad.exe,, A_Index, A_Index
		Sleep, 100
	}
return

Esc::ExitApp

HI THERE. Regarding your script, I modified your script a bit to just open a few programs, but after 10 seconds, when the MsgBox closes, the programs open again, so now I can double of each. How do I stop that?


SetTimer, NewThread, -1000
MsgBox,,, Hello, 10

NewThread:

Run, notepad.exe
Run, mspaint.exe
}
return
yabab33299
Posts: 57
Joined: 06 May 2020, 17:16

Re: Create custom msgbox

27 May 2020, 14:15

garry wrote:
17 May 2020, 14:05
maybe set timer off if continue in Label A1

Code: Select all

SetTimer,A1,100
;gosub,a1
msgbox, 262208,CLOSE in 6 SECONDS ,Hello! :-)`n I CLOSE in 6 seconds ,6
exitapp
A1:
settimer,A1,off
run,charmap
return
hi there. May I ask what does your 262208, mean?
garry
Posts: 2282
Joined: 22 Dec 2013, 12:50

Re: Create custom msgbox

27 May 2020, 15:05

see in ahk help , msgbox options :
%a_programfiles%\AutoHotkey\AutoHotkey.chm
OK=0, FIRST=0, INFO=64, Alwaysontop=262144 >>> Total=262208
I like to use 'alwaysontop' and here 'Info' and only OK-Button
I used the script from user 'Thalon' , >> MessageBox-Creator
https://autohotkey.com/board/topic/10623-messagebox-creator/page-2#entry93652
User avatar
boiler
Posts: 5237
Joined: 21 Dec 2014, 02:44

Re: Create custom msgbox

27 May 2020, 16:05

yabab33299 wrote:
27 May 2020, 14:08
HI THERE. Regarding your script, I modified your script a bit to just open a few programs, but after 10 seconds, when the MsgBox closes, the programs open again, so now I can double of each. How do I stop that?


SetTimer, NewThread, -1000
MsgBox,,, Hello, 10

NewThread:

Run, notepad.exe
Run, mspaint.exe
}
return
Add a return as shown here:

Code: Select all

SetTimer, NewThread, -1000
MsgBox,,, Hello, 10
return ; end of auto-execute section

NewThread:
	Run, notepad.exe
	Run, mspaint.exe
return

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Bing [Bot], boiler, Google [Bot], Ian, loek6000, popwojciu and 334 guests