Candle
Joined: 19 Aug 2004 Posts: 334
|
Posted: Sun Sep 16, 2007 5:51 am Post subject: Little help with the right click |
|
|
When I run this you have to click two or three times on the desktop or system tray icon before the full menu opens with all the program links?
Thanks for the help.
| Code: | ; ========== opens with Rightclick under desktop , can add new links ==================================
#Persistent
setworkingdir, %a_scriptdir%
;------ here your path to read ------------
AAA=C:\Program Files\
Menu,Tray,NoStandard
Menu, Tray, UseErrorLevel
Menu, Tray, Add , edit menu, editmenu
Menu, Tray, Add
Menu, Tray, Add, Add menu item, AddMenuItem
Menu, Tray, Add, Exit,exit
Filedelete,MenuItems.txt
Loop %AAA%\*.exe,,1
FileAppend,%A_LoopFileName% `t %A_LoopFileLongPath%`n,MenuItems.txt
Loop,read,MenuItems.txt
{
StringSplit, MenuComponent, A_LoopReadLine, %a_tab%
if MenuComponent1 <>
{
Menu, tray, add, %MenuComponent1%, MenuHandler
}
}
return
;--------------
RButton::
MouseGetPos, , , WindowUnderMouse
WinGetClass, ClassUnderMouse, ahk_id %WindowUnderMouse%
if ClassUnderMouse <> WorkerW
{
if ClassUnderMouse <> Progman ; No desktop, so make RButton behave normally.
{
MouseClick, right, , , , , D
Loop
{
Sleep, 10
GetKeyState, RButtonState, RButton, P
if RButtonState = U ; button has been released
break
}
MouseClick, right, , , , , U
return
}
}
; Otherwise, the user has clicked on the desktop, so do a custom action.
Menu, Tray, Show
Loop, read, MenuItems.txt
{
StringSplit, MenuComponent, A_LoopReadLine, %a_tab%
if A_ThisMenuItem = %MenuComponent1%
{
MenuComponent2=%MenuComponent2%
Run, %MenuComponent2%
break
}
}
return
;--------------------
AddMenuItem:
FileSelectFile, Filename,,,, Executable Files (*.exe; *.bat; *.com)
if Filename =
return
SplitPath, Filename,,,, FilenameNoExt
InputBox, MenuItemName, Choose Menu Item Name, Type the name of this item as it will appear in the menu.,,,,,,,, %FilenameNoExt%
FileAppend, %MenuItemName%`t%Filename%`n, MenuItems.txt
Menu, tray, add, %MenuItemName%, MenuHandler
return
exit:
ExitApp
return
MenuHandler:
Loop, read, MenuItems.txt
{
StringSplit, MenuComponent, A_LoopReadLine, %a_tab%
if A_ThisMenuItem = %MenuComponent1%
{
MenuComponent2=%MenuComponent2%
Run, %MenuComponent2%
break
}
}
return
editmenu:
Run, MenuItems.txt
return
;================================================================================= |
_________________ Autohotkey Just drives me crazy .. |
|