Jump to content

Scrolling Traytip/tooltip Helper


lte5000
 Share

Recommended Posts

Update: Added checking if BalloonTips are enabled. Thanks piccaso! :D

I wrote this function in one of my scripts, and I decided to post it here, in case anyone's interested.

What it does is automatically choose whether to display a ToolTip or TrayTip depending on your OS (TrayTip on 2000/XP, ToolTip on 9x/NT). It also has the ability to scroll in the 'Tip from left to right. It does NOT accept location parameters.

The function should be called as such to display a scrolling ToolTip/TrayTip:

Opt("WinTitleMatchMode", 4)
Tip("AutoIt", "I am a scrolling 'Tip...", 1, 20)
Sleep(2500)

The third parameter turns scrolling on or off. ( 1=ON, anything else = OFF)

The last parameter controls the scrolling speed, BIGGER number = SLOWER speed SMALLER number = FASTER speed.

Or like this to display a non-scrolling tip:

Opt("WinTitleMatchMode", 4)
Tip("AutoIt", "I am NOT a scrolling 'Tip...", "", "")
Sleep(2500)

Func Tip($header, $message, $scrolling, $speed)
        Local $header, $message, $scrolling, $parseTray, $scrollTray, $parseTool, $scrollTool, $i, $winSizes, $y, $trayEnable
        $trayEnable = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "EnableBalloonTips")
        If @error = -1 Or $trayEnable And @OSTYPE = "WIN32_NT" And @OSVersion <> "WIN_NT4" Then
               ;Non - scrolling TrayTips.
                If Not $scrolling Then
                        TrayTip($header, $message, 30, 1)
                Else
                       ;Scrolling TrayTips.
                        $parseTray = StringSplit($message, "")
                        Do
                                $i = $i + 1
                                $scrollTray = $scrollTray & $parseTray[$i]
                                TrayTip($header, $scrollTray, 30, 1)
                                Sleep($speed)
                        Until $i = $parseTray[0]
                EndIf
        Else
                $winSizes = WinGetClientSize("classname=Shell_TrayWnd")
                $y = @DesktopHeight - $winSizes[1] - 35
               ;Make the title line-up better on tooltips.
                Select
                        Case StringLen($message) - StringLen($header) > 30
                                $header = @TAB & @TAB & $header
                        Case StringLen($message) - StringLen($header) > 20
                                $header = @TAB & $header
                EndSelect
               ;Non - scrolling ToolTips.
                If Not $scrolling Then
                        ToolTip($header & @LF & $message, @DesktopWidth - (StringLen($message) * 4.5) - 100, $y)
                Else
                       ;Scrolling ToolTips.    
                        $parseTool = StringSplit($message, "")
                        Do
                                $i = $i + 1
                                $scrollTool= ($scrollTool & $parseTool[$i])
                                ToolTip($header & @LF & $scrollTool, @DesktopWidth - (StringLen($message) * 4.5) - 100, $y)
                                Sleep($speed)
                        Until $i = $parseTool[0]
                EndIf
        EndIf
EndFunc  ;==>Tip
Edited by lte5000
Link to comment
Share on other sites

Passing anything > 1 to the 3rd parameter causes a recursion error.

Edit: Larry, you're a bastard. You tidy the script no more than a minute after I read the original left justified version.

Edited by Valik
Link to comment
Share on other sites

wouldn't it be cool as hell to have the forums run tidy on anything in code tags? or make a new type called [tidycode]? anyways, pipedreams...

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

:D Or we should all use Tidy before we post.  :huh2:

The code looks fairly fine in Crimson Editor, but it does not look so fine on hiddensoft.com.  :)

K

:lol: lol, yup... I am kind of tidy compulsive, I like how it leaves me with a rolling history of the script I'm working on, though I've switched to SciTE and it does all the indents on the fly, which is hella cool... (I still tidy all the damned time, it's fun!)

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

Tidy is a cool tool, but I believe the best solution is to adopt the discipline of formatting while coding. This has benefits that aid development too .. not just maintenance :D
Link to comment
Share on other sites

Tidy is a cool tool, but I believe the best solution is to adopt the discipline of formatting while coding. This has benefits that aid development too .. not just maintenance  :D

I always use tidy after typing just incase of :huh2:
Link to comment
Share on other sites

Actually I try to be rather tidy with my coding, too. But, I hadn't really considered the fact that in HTML the tabs have no effect (correct?). :D

I've never used Tidy up to this point.

Ken

Edited by lte5000
Link to comment
Share on other sites

Actually I try to be rather tidy with my coding, too. But, I hadn't really considered the fact that in HTML the tabs have no effect (correct?). 

.. Correct :huh2: .. but spaces do, within the CODE tags supported by the forum. And if you use a cool editor (like TextPad :D ) then you can make your tabs come out as spaces anyway.

(Then you don't have to use Tidy at all)

Link to comment
Share on other sites

I use Crimson Editor, but I did try Scite last evening. I couldn't figure out how to change the default font (too small), though and the Scite helpfile seemed to be broken, so I guess I'll have to go back to Crimson (Excuses.... Excuses... :D )

TextPad, hmm...

You are welcome to download a copy for free evaluation.

:huh2:

K

Link to comment
Share on other sites

  • Developers

I use Crimson Editor, but I did try Scite last evening. I couldn't figure out how to change the default font (too small), though and the Scite helpfile seemed to be broken, so I guess I'll have to go back to Crimson (Excuses.... Excuses...  :D )

TextPad, hmm...   :huh2:

K

The Documentation can be found in the subdir doc called SciTEDoc.html.

The Scitehelp will be fixed with the next release thats coming soon... tnx for mentioning it...

The best thing is to make the changes in the User option files because this will not be overridden when you upgrade....

To change the font just Open the User Option file and add these line to it:

use.monospaced=1 -> this tell Scite to use mono space font

font.monospace=font:Courier New,size:10

and these are all the definitions for all different type of code color settings

you can customise them all if you want.

# White space

style.au3.0=fore:#000000,$(font.au3)

# Comment line

style.au3.1=fore:#009933,italics

# Comment block

style.au3.2=fore:#669900,italics

# Number

style.au3.3=fore:#AC00A9,bold,italics

# Function

style.au3.4=fore:#000090,bold,italics

# Keyword

style.au3.5=fore:#0000FF,bold

# Macro

style.au3.6=fore:#FF33FF,bold

# String

style.au3.7=fore:#9999CC,bold

# Operator

style.au3.8=fore:#FF0000,bold

# Variable

style.au3.9=fore:#AA0000,bold

# Sent keys in string

style.au3.10=fore:#FF8800,bold

# Pre-Processor

style.au3.11=fore:#F000FF,italics

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thank you for you comments, piccaso!

I updated the code above.

JdeB, Thank you for your informative post, I'll want to try out your stuff sometime.

Kendall

Edited by lte5000
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...