AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple Message, on top for a delayed time

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
icefreez



Joined: 15 May 2007
Posts: 36

PostPosted: Tue May 29, 2007 6:19 pm    Post subject: Simple Message, on top for a delayed time Reply with quote

This is a very handy script for displaying information after something happens.

This function displays a message on the screen on top of everything for five seconds. For example you want to move a lot of files and want to know when they have finished moving but don't want a stupid msgbox to pop up and pull focus.

Code:
fivesecdisp("Msg displayed over everything for five seconds.")
fivesecdisp("Them resumes next script line.")

exitapp ;exits script

fivesecdisp(text){
   Gui, +AlwaysOnTop +ToolWindow -SysMenu -Caption
   Gui, Color, ffffff ;changes background color
   Gui, Font, 000000 s20 wbold, Verdana ;changes font color, size and font
   Gui, Add, Text, x0 y0, %text% ;the text to display
   Gui, Show, NoActivate, Xn: 0, Yn: 0

   sleep, 5000
   Gui, Destroy
}


Hope you enjoy.
Back to top
View user's profile Send private message
TheIrishThug



Joined: 19 Mar 2006
Posts: 365

PostPosted: Tue May 29, 2007 9:34 pm    Post subject: Reply with quote

It is probably worth it to make the function more generic. Options to set the sleep time, color and font could be useful.

Also, I am not sure what you are trying to do with "Xn: 0, Yn: 0" on the Gui, Show line. If it is an attempt to position the Gui, it should be written as follows.
Code:
Gui, Show, NoActivate X0 Y0, <Some optional window title>
Back to top
View user's profile Send private message Visit poster's website AIM Address
Stefan



Joined: 30 Jul 2004
Posts: 72
Location: Deutschland (sorry for my english)

PostPosted: Sun Jul 15, 2007 3:53 am    Post subject: Reply with quote

Thanks icefreez, i can make use of this.

Arrrgh, this variables syntax makes me crazy an cost me always some hours.

One time %var%, other time use var without %%, another time use :=var Rolling Eyes

Here is my code for the night.
I have compiled it and use it from Total Commander menu
to show me Infos providing some help to me.

Maybe someone has an use for it too? So please reply and let me know.


v.05 So.15.07.2007
Added some baubles to avoid making bad jokes
; Timeout > 15sec => User info
; Timeout > 29sec => User info plus possibility to cancel
; Timeout > 119sec => User info plus possibility to cancel plus show start info





Just start it to see an help.

Code:

#SingleInstance force
#NoTrayIcon
;^!e::exitapp ; Ctrl+Alt+e exits script
;Little script for some nice Message Boxes. Code from icefreez. Enhanced from Stefan. v0.4
;Syntax: mb.exe TimeOut-in-seconds "Text to display" [Font-Size  "Font to use" Format-Bold-or-not]

If 1 =
1 = 30
mySec = %1%


If 2 =
{
myMsg = `nUpps, no parameters from you?`n
myMsg = %myMsg%Use %A_ScriptName% as an command line tool or use an link to %A_ScriptName% with this parameters.`n
myMsg = %myMsg%I use it in Total Commander to provide help messages. Or in HKLM\RunOnce to inform an customer. OR...`n`n
myMsg = %myMsg%Syntax:`t`t%A_ScriptName%  sec  "Message"`n
myMsg = %myMsg%Example:`t%A_SCRIPTNAME%   %1%  "My message is here"`n`n
myMsg = %myMsg%And "My message is here" will displayed over everything for %1% seconds in default font Arial in size 12.`n`n
myMsg = %myMsg%You can use ``n for line feed and ``t for tab.`n
myMsg = %myMsg%Advanced Syntax:`t%A_ScriptName%  sec  "Message"  Fontsize "Font name" b-for-bold `n`n
myMsg = %myMsg%Visit   www.AutoHotkey.com   and   www.DonationCoder.com   for more. (Stefan in 2007)`n`n
}
ELSE
myMsg = %2%


If 3 =
3 = 12
mySize = %3%


If 4 =
4 = Arial
myFont = %4%


If 5 = b
myFormat = wbold


fivesecdisp(mySec,mySize,myMSG,myFont,myFormat,v6)

exitapp ;exits script



fivesecdisp(sec,siz,text,myFont,myFormat,v6){

mySec := sec * 1000
myCloseTime =
myCloseTime += sec, seconds
FormatTime, myCloseTime, %myCloseTime%, HH:mm:ss

; Timeout > 15sec => User info
; Timeout > 29sec => User info plus possibillity to cancel
; Timeout > 119sec => User info plus possibillity to cancel plus show start info

If sec >14  ; Give the user some info if the time out is set longer then a few seconds
    {
    myInfo = Closing myself automatically in %sec% seconds at %myCloseTime%
    myY = y20
    }
ELSE
    myY = y10

If sec >29 ;Give the user the possibilty to exit the app if the time out is set too long
    {
    myInfo = Closing myself automatically in %sec% seconds at %myCloseTime%
    myY = y25
    }

If sec >119 ;Give the user the possibilty to exit the app if the time out is set too long
    {
    myInfo = Closing myself automatically in %sec% seconds at %myCloseTime%`nStartet from %A_SCRIPTFULLPATH%
    myY = y30
    }

   Gui, +AlwaysOnTop +ToolWindow -SysMenu -Caption
   Gui, Color, dddddd ;changes background color
   Gui, Font, 000000 s8 , Arial
   Gui, Add, Text, x20 y2, %myInfo%
   Gui, Font, 000000 s%siz% %myFormat%, %myFont% ;Arial ;Lucida Console ;Comic Sans MS 
   ;MS Sans Serif ;Times ;Verdana ;changes font color, size and font
   Gui, Add, Text, x20 %myY%, %text% ;the text to display
          If sec > 29
          {
            Gui, Font, 000000 s8 , Arial
            Gui, Add, Text, cBlue gLaunchExit, [x]Close
          }         
  Gui, Show, NoActivate, X0, Y0

   sleep, %mySec%
   Gui, Destroy

        LaunchExit:
           Gui, Destroy
           ExitApp
           Return
}

_________________
Stefan

This post was created with the kindly help of http://dict.leo.org/ and remember: “Allways look on the bright side of Life”


Last edited by Stefan on Sun Jul 15, 2007 3:50 pm; edited 2 times in total
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2540
Location: Australia, Qld

PostPosted: Sun Jul 15, 2007 6:10 am    Post subject: Reply with quote

TheIrishThug wrote:
It is probably worth it to make the function more generic.
Allowing the user to specify a GUI number might also be useful, if their script already contains a GUI.

help: Gui, Creating Multiple GUI Windows wrote:
Each script may have up to 99 GUI windows simultaneously. To operate upon a window number other than the default, include a number followed by a colon in front of the sub-command as in these examples:
Code:
Gui, 2:Add, Text,, Text for about-box.
Gui, 2:ShowGui
2:Default can be used to avoid the need for the "2:" prefix above.

Edit: Here's my contribution - window/background/mouse transparency (can be added to the top of the function):
Code:
; These could be parameters of the function...
    transparency = 130  ; 0-255 level of transparency (255=opaque)
    nobackground = 1    ; 0|1   make the background fully transparent?
    nomouse      = 1    ; 0|1   make the window transparent-to-mouse

    ; set Gui as "working window" for WinSet
    Gui, +LastFound
   
    if nomouse
        WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT
   
    ; Replace "White" with whatever the background colour is.
    if nobackground
        WinSet, TransColor, White %transparency%
    else
        WinSet, Transparent, %transparency%
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group