Jump to content

The AutoIt Tray


Achilles
 Share

Recommended Posts

I use a .au3 file on my desktop for trying lots of little scripts from here and there. Sometimes I end up adding more and more and eventually my desktop is crowded. This program basically lets you access one .au3 file from your tray. You can also start up the helpfile.

#NoTrayIcon
#Include <Constants.au3>
#Include <File.au3>
#include <Misc.au3>

_Singleton('AutoItTray')

Opt("TrayOnEventMode",1)
Opt("TrayAutoPause",0)
Opt("TrayMenuMode",1)

$path = @TempDir & '\AutoItTray.au3'

TrayCreateItem('Open')
    TrayItemSetState(-1, $TRAY_DEFAULT)
    TrayItemSetOnEvent(-1, '_Open')
TrayCreateItem('Run')
    TrayItemSetOnEvent(-1, '_Run')

TrayCreateItem('')

TrayCreateItem('AutoIt Help...')
    TrayItemSetOnEvent(-1, '_Helpfile')

TrayCreateItem('')

TrayCreateItem('Exit')
    TrayItemSetOnEvent(-1, '_Exit')

TraySetClick(8)

TraySetIcon(@SystemDir & '\shell32.dll', -160)

TraySetToolTip('AutoIt Tray')

TraySetState()

While 1
    Sleep(200)
WEnd

Func _Open()
    If Not FileExists($path) then
        _FileCreate($path)
    EndIf

    ShellExecute($path, '', @TempDir, 'edit')
    TrayItemSetState(@TRAY_ID, $TRAY_DEFAULT)
EndFunc

Func _Helpfile()
    $temp = StringSplit(@AutoItExe, '\')
    ShellExecute(StringTrimRight(@AutoItExe,StringLen($temp[$temp[0]])) & '\AutoIt.chm')
    TrayItemSetState(@TRAY_ID, $TRAY_UNCHECKED)
EndFunc

Func _Run()
    Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & $path & '"')
    TrayItemSetState(@TRAY_ID, $TRAY_UNCHECKED)
EndFunc

Func _Exit()
    Exit
EndFunc
Edited by Achilles
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

I hit an awesome stack overflow error once because I accidentally created a recursive constructor. That was so hard to debug.

Tray functions are always fun. Although, with your new function, why don't you just use a file save dialog instead of selecting a folder and using an inputbox? That just seems to me to make a little more sense.

Link to comment
Share on other sites

I hit an awesome stack overflow error once because I accidentally created a recursive constructor. That was so hard to debug.

Tray functions are always fun. Although, with your new function, why don't you just use a file save dialog instead of selecting a folder and using an inputbox? That just seems to me to make a little more sense.

Good idea... I knew there should be an easier way. Thanks, I'll update that sometime.

@fear1313

Thanks! This was the first time I used recursion... It was funny 'cause my AP Computer Science teacher couldn't think of a good example of how to use and I couldn't think how recursion would be useful... But this script showed me how useful it was!

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Ya, recursion is a pretty "specialized" technique. In fact I think the only time I've ever used it is in my example in the online autoit editor topic o_0. And thats pretty bad when your teacher can't come up with an example. :)

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Link to comment
Share on other sites

Ya, recursion is a pretty "specialized" technique. In fact I think the only time I've ever used it is in my example in the online autoit editor topic o_0. And thats pretty bad when your teacher can't come up with an example. :)

My teacher rocks... I don't really blame him for not being able to think of a example of recursion of the top of his head, it doesn't seem to common. (Although I think Windows might use it to make their Start Menu) Plus it's independent study so a friend of mine and I are the only one in the class and he doesn't teach us, we just use the book.

Updated version:

  • Used FileSaveDialog() for the "New Script" function
  • Added the option to recycle scripts
Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

I got to tell you, at first, i though it was kind of useless, but when I actually tried it, it was really good! And I'll probably use it to manage SWB when I'm editing it. Thanks for the neat script!

l

Your welcome :) I use it (or will use it when I have time to use AutoIt more frequently) for helping people solve the problems they post on they post in help and support and the GUI support. It keeps my desktop cleaner!
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

  • 4 weeks later...
  • Moderators

If you have as many .au3 scripts as I do in a directory... this will definately throw a recursion error:

Func _MakeTray($path, $menuID)
    $temp = _FileListToArray($path, '**', 2)
   
    For $index = 1 to UBound($temp) - 1
        $tempIndex = TrayCreateMenu($temp[$index], $menuID)
        _MakeTray($path & '\' & $temp[$index], $tempIndex)
    Next

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I like it.

In fact, this may save me time, specifically when wanting to test a script either I found online or I just thought of.

Thanks!

Your welcome! That's mostly what I use it for too...

@Nahuel

Hey Piano Man! Loooooooving the "Quick Script" option! Hah, I'll use this every day. Thanks smile.gif

Thanks!

@SmOke_N

If you have as many .au3 scripts as I do in a directory... this will definately throw a recursion error:

Any suggestions as to how change that? I was thinking limit each menu group to like 40 items and then tell the user that it has limited the amount of items. Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

  • Moderators

@SmOke_N

Any suggestions as to how change that? I was thinking limit each menu group to like 40 items and then tell the user that it has limited the amount of items.

Use one of the recursion _FileListToArray that randallc or myself made.

Mine is _FileListToArrayEx() here in the example script forum.

His is _FileListToArrayNew <<??? Not so sure, but I know it's in his signature.

To be honest, I think his may be better though I've not had a need lately to need either one to test it.

Anyway, you'll find them to faster in recursion mode, than yours probably is out of the box without recursion.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...

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...