Sign in to follow this  
Followers 0
satanttin

.au3 files automaticly added to menu help?

12 posts in this topic

Hello,

What i am trying to do is making a script that holds test scripts so i can easily find specific snippets for when i need it.

So first step is figure out how to add the .au3 scripts in the scriptdir in a traymenu. problem is i don't know if it is possible to do and how to begin.

So hope someone can tell me where to start looking and maybe tell me what function it is that i need to use.

I use oneventmode since that's the only way i can script :')

 

Thanks in advance.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi, had this base script, made some changes, it's very preliminar, see how it works for you.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
;#AutoIt3Wrapper_Icon=.ico
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Comment=By:
;#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_SaveSource=y
;#AutoIt3Wrapper_Res_Icon_Add=.ico
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <File.au3>
#include <GUIConstantsEx.au3>
Opt("TrayMenuMode", 1)
Opt("TrayIconHide", 0)
Opt("GUIResizeMode", 1)
Opt("TrayIconDebug", 1)
Opt("TrayAutoPause", 0)
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 0)
Opt("GUIEventOptions", 1)
Opt("TrayOnEventMode", 1)
Opt("ExpandEnvStrings", 1)
Opt("WinDetectHiddenText", 1)

;Gui
Local $GUI, $Frm_main, $Button_1
;Tray
Local $PLTray, $PSTray, $STTray, $NTray, $PTray, $CTTray, $ExitItem
;Vars
Local $Au3filesArray, $Item

TraySetIcon("ico.ico")
$GUI = GUICreate('Au3', 150, 100, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Restore")

$ExitItem = TrayCreateItem("Close")
TrayItemSetOnEvent(-1, "Quit")

$Button_1 = GUICtrlCreateButton("Search and add scripts", 10, 10)
GUICtrlSetOnEvent($Button_1, "SrchAdd")

GUISetState()
TraySetState(1)
TraySetClick(8)
;=============================================================================

Do
    Sleep(15)
Until GUIGetMsg() = $GUI_EVENT_CLOSE

;=============================================================================

Func SrchAdd()
    $Au3filesArray = _FileListToArray(@ScriptDir, '*.au3', 1, 0)
    For $i = 1 To $Au3filesArray[0]
        ConsoleWrite('$Au3filesArray[$i] ' & $Au3filesArray[$i] & @CRLF)
        $Au3filesArray[$i] = TrayCreateItem($Au3filesArray[$i])
        TrayItemSetOnEvent($Au3filesArray[$i], $Au3filesArray[$i])
    Next
EndFunc   ;==>SrchAdd

;=============================================================================

Func Minimize()
    WinSetState('', '', @SW_MINIMIZE)
EndFunc   ;==>Minimize

Func Restore()
    WinSetState('', '', @SW_RESTORE)
EndFunc   ;==>Restore

Func Quit()
    Exit
EndFunc   ;==>Quit

;=============================================================================

This got me thinking, now how do i click those? :P

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Share this post


Link to post
Share on other sites

Thanks for the script ^^ shall check it and let u know if it works :3

Share this post


Link to post
Share on other sites

Woah so close O.o just have to adjust it a little bit :P

don't want the gui so gonna make a tray button out of it.

the only problem now is when i press a tray button it won't open the script mhmm

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Yup, working on it, not sure i will be able to figure it out, since the new tray items are in memory.

EDIT: I think the best way to make this work, is by somehow detect in which item you click, retrieve the text, and use that to open the script.

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Share this post


Link to post
Share on other sites

ahh okay :( well atleast i got a good start thanks to you^^

now just figure out how to open them when i click them :P

i shall post the full script when i find it ^^

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

This works for me, and should for you, assuming that your SciTe directory is the same as mine, if not, change it to the correct one.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
;#AutoIt3Wrapper_Icon=.ico
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Comment=By:
;#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_SaveSource=y
;#AutoIt3Wrapper_Res_Icon_Add=.ico
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <TrayConstants.au3>
Opt("TrayMenuMode", 3)
Opt("TrayIconHide", 0)
Opt("GUIResizeMode", 1)
Opt("TrayIconDebug", 1)
Opt("TrayAutoPause", 0)
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 0)
Opt("GUIEventOptions", 1)
Opt("TrayOnEventMode", 0)
Opt("ExpandEnvStrings", 1)
Opt("WinDetectHiddenText", 1)

;Gui
Local $GUI, $Frm_main, $Button_1
;Tray
Local $PLTray, $PSTray, $STTray, $NTray, $PTray, $CTTray, $ExitItem
;Vars
Local $Au3filesArray, $Item, $State, $Msg, $GuiMsg, $CursorInfo, $txt

TraySetIcon("ico.ico")
$GUI = GUICreate('Au3', 150, 100, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Restore")

$ExitItem = TrayCreateItem("Close")
TrayItemSetOnEvent(-1, "Quit")

$Button_1 = GUICtrlCreateButton("Search and add scripts", 10, 10)
GUICtrlSetOnEvent($Button_1, "SrchAdd")

GUISetState()
TraySetState(1)
TraySetClick(8)
;=============================================================================

Do
    $Msg = TrayGetMsg()
    If $Msg > 0 Then
        $txt = TrayItemGetText($Msg)
        ConsoleWrite('$txt ' & $txt & @CRLF)
        If $txt = 'Close' Then Quit()
        ConsoleWrite(@ScriptDir & '\' & $txt & @CRLF)
        Run("C:\Program Files (x86)\AutoIt3\SciTE\SciTE.exe " & @ScriptDir & '\' & $txt)
    EndIf
    Sleep(50)
Until GUIGetMsg() = $GUI_EVENT_CLOSE

;=============================================================================

Func SrchAdd()
    $Au3filesArray = _FileListToArray(@ScriptDir & '\', '*.au3', 1, 0)
    ConsoleWrite('$Au3filesArray[1] ' & $Au3filesArray[1] & @CRLF)
    ConsoleWrite('$Au3filesArray[2] ' & $Au3filesArray[2] & @CRLF)
    For $i = 1 To $Au3filesArray[0]
        $Au3filesArray[$i] = TrayCreateItem($Au3filesArray[$i])
        TrayItemSetOnEvent($Au3filesArray[$i], $Au3filesArray[$i])
    Next
EndFunc   ;==>SrchAdd

;=============================================================================

Func Minimize()
    WinSetState('', '', @SW_MINIMIZE)
EndFunc   ;==>Minimize

Func Restore()
    WinSetState('', '', @SW_RESTORE)
EndFunc   ;==>Restore

Func Quit()
    Exit
EndFunc   ;==>Quit

;=============================================================================
Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Share this post


Link to post
Share on other sites

Thank you, thank you very much :D

Share this post


Link to post
Share on other sites

If you find it useful, i made it so it reads the SciTe directory from registry, so it's all automatic.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
;#AutoIt3Wrapper_Icon=.ico
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Comment=By:
;#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_SaveSource=y
;#AutoIt3Wrapper_Res_Icon_Add=.ico
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <TrayConstants.au3>
Opt("TrayMenuMode", 3)
Opt("TrayIconHide", 0)
Opt("GUIResizeMode", 1)
Opt("TrayIconDebug", 1)
Opt("TrayAutoPause", 0)
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 0)
Opt("GUIEventOptions", 1)
Opt("TrayOnEventMode", 0)
Opt("ExpandEnvStrings", 1)
Opt("WinDetectHiddenText", 1)

;Gui
Local $GUI, $Frm_main, $Button_1
;Tray
Local $PLTray, $PSTray, $STTray, $NTray, $PTray, $CTTray, $ExitItem
;Vars
Local $Au3filesArray, $Msg, $txt, $Reg, $RegTrim

TraySetIcon("ico.ico")
$GUI = GUICreate('Au3', 150, 100, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Restore")

$ExitItem = TrayCreateItem("Close")
TrayItemSetOnEvent(-1, "Quit")

$Button_1 = GUICtrlCreateButton("Search and add scripts", 10, 10)
GUICtrlSetOnEvent($Button_1, "SrchAdd")

GUISetState()
TraySetState(1)
TraySetClick(8)

$Reg = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoIt3Script\Shell\Edit\Command', '')
$RegTrim = StringTrimRight($Reg, 5)

;=============================================================================

Do
    $Msg = TrayGetMsg()
    If $Msg > 0 Then
        $txt = TrayItemGetText($Msg)
        If $txt = 'Close' Then Quit()
        Run($RegTrim & ' ' & @ScriptDir & '\' & $txt)
    EndIf
    Sleep(50)
Until GUIGetMsg() = $GUI_EVENT_CLOSE

;=============================================================================

Func SrchAdd()
    $Au3filesArray = _FileListToArray(@ScriptDir & '\', '*.au3', 1, 0)
    ConsoleWrite('$Au3filesArray[1] ' & $Au3filesArray[1] & @CRLF)
    ConsoleWrite('$Au3filesArray[2] ' & $Au3filesArray[2] & @CRLF)
    For $i = 1 To $Au3filesArray[0]
        $Au3filesArray[$i] = TrayCreateItem($Au3filesArray[$i])
        TrayItemSetOnEvent($Au3filesArray[$i], $Au3filesArray[$i])
    Next
EndFunc   ;==>SrchAdd

;=============================================================================

Func Minimize()
    WinSetState('', '', @SW_MINIMIZE)
EndFunc   ;==>Minimize

Func Restore()
    WinSetState('', '', @SW_RESTORE)
EndFunc   ;==>Restore

Func Quit()
    Exit
EndFunc   ;==>Quit

;=============================================================================

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Share this post


Link to post
Share on other sites

Only problem is btw that my snippets need to be in the @scriptDir and in a map named folderO.o

is that also the problem that u have or am i missing something here?

Share this post


Link to post
Share on other sites

Got it working how i want now :D

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
;#AutoIt3Wrapper_Icon=.ico
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Comment=By:
;#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_SaveSource=y
;#AutoIt3Wrapper_Res_Icon_Add=.ico
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <TrayConstants.au3>
Opt("TrayMenuMode", 3)
Opt("TrayIconHide", 0)
Opt("GUIResizeMode", 1)
Opt("TrayIconDebug", 1)
Opt("TrayAutoPause", 0)
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 0)
Opt("GUIEventOptions", 1)
Opt("TrayOnEventMode", 0)
Opt("ExpandEnvStrings", 1)
Opt("WinDetectHiddenText", 1)

;Gui
Local $GUI, $Frm_main, $Button_1
;Tray
Local $PLTray, $PSTray, $STTray, $NTray, $PTray, $CTTray, $ExitItem
;Vars
Local $Au3filesArray, $Item, $State, $Msg, $GuiMsg, $CursorInfo, $txt

TraySetIcon("ico.ico")
$GUI = GUICreate('Au3', 150, 100, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Restore")

$ExitItem = TrayCreateItem("Close")
TrayItemSetOnEvent(-1, "Quit")

$Button_1 = GUICtrlCreateButton("Search and add scripts", 10, 10)
GUICtrlSetOnEvent($Button_1, "SrchAdd")

GUISetState()
TraySetState(1)
TraySetClick(8)
;=============================================================================

Do
    $Msg = TrayGetMsg()
    If $Msg > 0 Then
        $txt = TrayItemGetText($Msg)
        ConsoleWrite('$txt ' & $txt & @CRLF)
        If $txt = 'Close' Then Quit()
        ConsoleWrite(@ScriptDir & '\' & $txt & @CRLF)
        Run("C:\Program Files (x86)\AutoIt3\SciTE\SciTE.exe " & @ScriptDir & '\' & "Snippets" & '\' & $txt)
    EndIf
    Sleep(50)
Until GUIGetMsg() = $GUI_EVENT_CLOSE

;=============================================================================

Func SrchAdd()
    $Au3filesArray = _FileListToArray(@ScriptDir & '\'& "Snippets" & '\', '*.au3', 1, 0)
    ConsoleWrite('$Au3filesArray[1] ' & $Au3filesArray[1] & @CRLF)
    For $i = 1 To $Au3filesArray[0]
        $Au3filesArray[$i] = TrayCreateItem($Au3filesArray[$i])
        TrayItemSetOnEvent($Au3filesArray[$i], $Au3filesArray[$i])
    Next
EndFunc   ;==>SrchAdd

;=============================================================================

Func Minimize()
    WinSetState('', '', @SW_MINIMIZE)
EndFunc   ;==>Minimize

Func Restore()
    WinSetState('', '', @SW_RESTORE)
EndFunc   ;==>Restore

Func Quit()
    Exit
EndFunc   ;==>Quit

;=============================================================================

So how it works u got this script and u got a map named Snippets and just put the scripts in that map and run the script refresh the data and click away :D

hope u like how i made a little change ^^

Share this post


Link to post
Share on other sites

Great job. :)


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Share this post


Link to post
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
Sign in to follow this  
Followers 0