AutoHotkey Community

It is currently May 25th, 2012, 11:25 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: May 29th, 2007, 6:19 pm 
Offline

Joined: May 15th, 2007, 8:59 pm
Posts: 169
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2007, 9:34 pm 
Offline

Joined: March 19th, 2006, 5:52 am
Posts: 419
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>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 15th, 2007, 3:53 am 
Offline

Joined: July 30th, 2004, 11:30 pm
Posts: 74
Location: Deutschland (sorry for my english)
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 :roll:

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
}

_________________
Image 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 July 15th, 2007, 3:50 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 15th, 2007, 6:10 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
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%


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: JamixZol and 27 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group