Jump to content

Recommended Posts

Posted (edited)

I've made this Toobar which start from Tray. Save your settings in config file to load diffrent settings.

Tested with Windows XP SP2 / Use Beta :)

:( New Version look @ trayToolBar2.au3 :D

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.103
; Author:           Michael
;
; Script Function:  Start your favorite application from tray
;
;Date:              23.05.2006 Start scripting
;ChangeLog          24.05.2006 Reduce Memory usage / Code from Valuater 
;                   IF Slide out Config Mode Off
;                   26.05.2006 Tooltip / Func Reset Toolbar
; ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GUIConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <constants.au3>
#NoTrayIcon
Opt("TrayMenuMode",1)
Opt("TrayOnEventMode", 1)
TraySetClick(16)
Global $Button[11],$x
Global $app="TrayToolBar"
Global $ConfigFlag=0
Global $LockFlag=0
Global $IniFile=@ScriptDir&"\"& $app &".TCF"
$font="Comic Sans MS"
$TimerStart = 0
$appWidth=50
$appHeight=405
$Speed=500
_checkIni()
$MainHwnd=GUICreate($app,$appWidth,$appHeight,@DesktopWidth-$appWidth,@DesktopHeight-$appHeight-30,($WS_SYSMENU),BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST ) )
GUISetFont (8, -1, 0, $font)
GUISetBkColor("0xCCCCCC",$MainHwnd)
$Button[1] = GUICtrlCreateButton("Setup", 5, 2, 35, 35,BitOR($BS_ICON,$BS_CENTER) )
$Button[2] = GUICtrlCreateButton("Setup", 5, 40, 35, 35, BitOR($BS_ICON,$BS_CENTER))
$Button[3] = GUICtrlCreateButton("Setup", 5, 78, 35, 35,BitOR($BS_ICON,$BS_CENTER))
$Button[4] = GUICtrlCreateButton("Setup", 5, 116, 35, 35, BitOR($BS_ICON,$BS_CENTER))
$Button[5] = GUICtrlCreateButton("Setup", 5, 154, 35, 35, BitOR($BS_ICON,$BS_CENTER))
$Button[6] = GUICtrlCreateButton("Setup", 5, 192, 35, 35, BitOR($BS_ICON,$BS_CENTER))
$Button[7] = GUICtrlCreateButton("Setup", 5, 230, 35, 35, BitOR($BS_ICON,$BS_CENTER))
$Button[8] = GUICtrlCreateButton("Setup", 5, 268, 35, 35, BitOR($BS_ICON,$BS_CENTER))
$Button[9] = GUICtrlCreateButton("Setup", 5, 306, 35, 35, BitOR($BS_ICON,$BS_CENTER))
$Button[10] = GUICtrlCreateButton("Setup", 5, 344, 35, 35, BitOR($BS_ICON,$BS_CENTER))
_ReDrawButton()
;------------Tray Settings------------
$TrayMnuShow= TrayCreateItem("Show")
TrayItemSetOnEvent(-1, "_slide_in")
$TrayMnuOption=TrayCreateMenu("Options")
$TrayMnuLock=TrayCreateItem("Lock Toolbar",$TrayMnuOption)
TrayItemSetOnEvent(-1, "_LockBar")
TrayCreateItem("",$TrayMnuOption)
$TrayMnuLoad=TrayCreateItem("Load Settings",$TrayMnuOption)
TrayItemSetOnEvent(-1, "_LoadSettings")
$TrayMnuSaveAs=TrayCreateItem("Save Settings",$TrayMnuOption)
TrayItemSetOnEvent(-1, "_SaveSettings")
$TrayMnuReset=TrayCreateItem("Reset current Toolbar",$TrayMnuOption)
TrayItemSetOnEvent(-1, "_ResetSettings")
$TrayMnuSetup=TrayCreateItem("Setup Mode")
TrayItemSetOnEvent(-1, "_ConfigOn")
TrayCreateItem("")
$TrayMnuExit= TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "_Exit")
TraySetState()
_slide_in();Start

_main()

Func _main()
    while 1
        if TimerDiff($TimerStart) > 60000 then
            _ReduceMemory() 
            $TimerStart = TimerInit()
        EndIF
        $Msg = GUIGetMsg()
        $trayMsg =TrayGetMsg()
    Select
        Case  $Msg=$Button[1]
            $x=1
            _checkAction()
        Case  $Msg=$Button[2]
            $x=2
            _checkAction()
        Case  $Msg=$Button[3]
            $x=3
            _checkAction()
        Case  $Msg=$Button[4]
            $x=4
            _checkAction()
        Case  $Msg=$Button[5]
            $x=5
            _checkAction()
        Case  $Msg=$Button[6]
            $x=6
            _checkAction()
        Case  $Msg=$Button[7]
            $x=7
            _checkAction()
        Case  $Msg=$Button[8]
            $x=8
            _checkAction()
        Case  $Msg=$Button[9]
            $x=9
            _checkAction()
        Case $Msg=$Button[10]
            $x=10
            _checkAction()
        Case $Msg=$GUI_EVENT_CLOSE
            _slide_out()
        EndSelect
    wend
    Sleep(100)
EndFunc



Func _checkAction()
    If $ConfigFlag=1 or GUICtrlRead($Button[$x])="Setup" then
            _SetupButton()
            Else
;Start Program
            $var=IniRead($IniFile,$app,"Button"&$x,"")
            run($var)
            _slide_out()
            EndIf       
EndFunc 

Func _SetupButton()
$var=FileOpenDialog("Select Program",@ProgramFilesDir&"\","Programs (*.exe)")
if not @error Then
Iniwrite($IniFile,$app,"Button"&$x,$var)
_ConfigOff()
_ReDrawButton()
Else
_ConfigOff()    
EndIf   
EndFunc 

Func _slide_in()
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $MainHwnd, "int", $Speed, "long", 0x00040008);slide-in from bottom
GUISetState(@SW_SHOW, $MainHwnd)
EndFunc

Func _slide_out()
    if $ConfigFlag=1 then _ConfigOff()
if $LockFlag=0 then DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $MainHwnd, "int", $Speed, "long", 0x00050004);slide-out to bottom 
EndFunc

Func _ConfigOn()
$ConfigFlag=1   
 GUISetBkColor("0xF00000",$MainHwnd)
 GUISetCursor(3,1)
_slide_in()
EndFunc 

Func _ConfigOff()
    $ConfigFlag=0   
    GUISetBkColor("0xCCCCCC",$MainHwnd)
    GUISetCursor(2,1)
    _slide_in()
EndFunc 

Func _checkIni()
    If not FileExists($IniFile) Then;create new ini
        for $i=1 to 10
            IniWrite($IniFile,$app,"Button"&$i,"Setup")
        next
            IniWrite($IniFile,$app,"LastConfig",$IniFile)
        Else
        $var=IniRead($IniFile,$app,"LastConfig",$IniFile)
        if $var<>$IniFile then $IniFile=$var
    EndIf

EndFunc

Func _ReDrawButton()
    for $i=1 to 10
    $var=IniRead($IniFile,$app,"Button"&$i,"Setup")
    If $var="Setup" Then
    GUICtrlSetImage($Button[$i], 'shell32.dll', 162, $BS_ICON);Use setup Icon 
        GUICtrlSetData($Button[$i],"Setup")
        GUICtrlSetTip($Button[$i],"Click to Setup")
Else    
    $file=IniRead($IniFile,$app,"Button"&$i,"")
    GUICtrlSetImage($Button[$i],$file,"Button"&$i,1)
    GUICtrlSetData($Button[$i],$i)
    GUICtrlSetTip($Button[$i],StringTrimLeft($file,StringInStr($file,"\",0,-1)))
    EndIf
    next
EndFunc 

Func _lockBar()
    if $LockFlag=0 Then
        _slide_in()
        $LockFlag=1
        TrayItemSetState($TrayMnuLock,$TRAY_CHECKED)
    Else
        $LockFlag=0
        TrayItemSetState($TrayMnuLock,$TRAY_UNCHECKED)
    EndIf       
    
EndFunc 

Func _SaveSettings()
$file=FileSaveDialog($app,@ScriptDir&"\","TrayToolBar Profile (*.tcf)")
if not @error then
    if StringRight($file,4)<>".tcf" then $file=$file &".tcf"
        Dim $aRecords
        If Not _FileReadToArray($IniFile,$aRecords) Then
        MsgBox(4096,"Error", " Error reading settings    error:" & @error)
    Else
    _FileWriteFromArray($file,$aRecords,1)
    IniWrite($IniFile,$app,"LastConfig",$file)  
    $IniFile=$file
    EndIf
EndIf
EndFunc 

Func _LoadSettings()
$file=FileOpenDialog($app,@ScriptDir&"\","Config (*.tcf)",1,"TrayToolBar.tcf")
    if Not @error Then
    $IniFile=$file
    _ReDrawButton()
    EndIf   
EndFunc 

Func _ResetSettings()
$var=MsgBox(4,$app,"Shure reset all settings "&$app&" ?")
        if $var=6 Then
            for $i=1 to 10
            Iniwrite($IniFile,$app,"Button"&$i,"Setup")
            Next    
        EndIf
        _ReDrawButton()
EndFunc 


Func _exit()
$LockFlag=0 
IniWrite(@ScriptDir&"\"& $app&".tcf",$app,"LastConfig",$IniFile)    
_slide_out()
exit
EndFunc 



Func _ReduceMemory($i_PID = -1);from Valuater see http://www.autoitscript.com/forum/index.ph...topic=19370&hl=
    
   If $i_PID <> -1 Then
Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
Else
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
EndIf
If @error Then Return 1
Return $ai_Return[0]
EndFunc;==> _ReduceMemory()

EDIT 1 Now no blank Icon if not configured it use setup icon

EDIT 2 Now it works with Win98 Thanks Lapo

EDIT 3 Change _Reduce Memory()

EDIT 4 New Version TrayToolBar2.au3 uploaded :oops:

comming soon new version with parameters and better tooltip :(

TrayToolBar.ico

TrayToolBar.au3

TrayToolBar2.au3

Edited by Micha1405
Posted

Yep works fine! Nice idea!

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Posted

Yes it works well. The blank buttons should have a setup icon i think before they are assigned to a program.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Posted

Looks nice, but why you create .tdf file? and not a ini?

--------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote]

Posted

I prefer this one to the other toolbars recently put on this forum

also, what would be nice would be a parameters option ie: explorer.exe c:\temp ?

and an optional description tooltip

other than that its brilliant

Who needs puzzles when we have AutoIt!!

Posted

:) No Comments ??? Not working or not good ??

Changing this (Return $ai_Return[0] >> Return $ai_Return ) works fine on a

win98se beta 3, 1, 1, 125

Func _ReduceMemory($i_PID = -1);from Valuater see http://www.autoitscript.com/forum/index.ph...topic=19370&hl=

If $i_PID <> -1 Then

Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)

Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])

DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])

Else

Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)

EndIf

Return $ai_Return

EndFunc;==> _ReduceMemory()

Posted

I prefer this one to the other toolbars recently put on this forum

also, what would be nice would be a parameters option ie: explorer.exe c:\temp ?

and an optional description tooltip

other than that its brilliant

:) Nice idea it will be in the next version

Posted (edited)

:) Thanks i 've changed it and update the first post

SORRY it was a workaround .. the correct one is :

thanks to Zedna http://www.autoitscript.com/forum/index.ph...=189233&st=60

Func _ReduceMemory($i_PID = -1);from Valuater see http://www.autoitscript.com/forum/index.php?showtopic=19370&hl=
    
   If $i_PID <> -1 Then
Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
Else
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
EndIf
If @error Then Return 1
Return $ai_Return[0]
EndFunc;==> _ReduceMemory()

sorry again

Edited by Lapo
  • 1 month later...
Posted

Update file at top, so peoples don't must search whole topic for latest version.

Very good script :whistle:

i542

I can do signature me.

Posted

Next Version is online :whistle:

Now you can use:

- other icons

- parameters for your application

- your own tooltip text

- Hotkey F10 for config mode

download traytoolbar2.au3 and enjoy it

Is it possible to open a file throught the default application of window ?

without having to specified the application

Someting like Run ( cmd /c c:\myscript.au3 )

? :-)

Posted (edited)

It works great! As another poster stated, I too like it better than the other toolbar scripts on the forum. :)

Edit: I'd like to suggest a drag-and-drop method of adding new programs to it. Also, perhaps more than 10 buttons (user-configurable?) for more programs. :whistle:

Edited by Somniis

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
  • Recently Browsing   0 members

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