charly99 Posted June 12, 2022 Posted June 12, 2022 (edited) What else can I do so that pressing said shortcut works? only the sub-menu is shown but it does not open the program. Edited June 13, 2022 by charly99
kurtykurtyboy Posted June 12, 2022 Posted June 12, 2022 (edited) Check your GUICtrlSetOnEvent functions. Each one is pointing to a function that does not exist. For example, "Excel 2013" should be "_Excel". After fixing all of those and changing $IconGet to my installation directory, it seemed to work just as expected. Here's the code: expandcollapse popup#include <ModernMenuRaw.au3> ;#NoTrayIcon Opt("TrayMenuMode", 3) Opt("GUIOnEventMode", 1) ;If Not FileExists(@ProgramsCommonDir&"\Excel 2013.lnk") Or Not FileExists(@ProgramsCommonDir&"\Word 2013.lnk") Then Exit Global $hGui = GUICreate("WPI2022 Menu Classic", 0, 0, -200, -200, -1, 0, WinGetHandle(AutoItWinGetTitle())) GUISetState() $Context = GUICtrlCreateContextMenu(GUICtrlCreateDummy()) $nSideItem1 = _CreateSideMenu($Context) _SetSideMenuText($nSideItem1, "Microsoft Office") _SetSideMenuColor($nSideItem1, 0xFFFFFF) _SetSideMenuBkColor($nSideItem1, 92111) _SetSideMenuBkGradColor($nSideItem1, 92111) $IconGet = @HomeDrive & "\Program Files\Microsoft Office\Office15" ;~ $IconGet = @HomeDrive & "\Program Files (x86)\Microsoft Office\root\Office16" ;Excel If FileExists($IconGet & "\EXCEL.EXE") Then Global $step1 = _GUICtrlCreateODMenuItem("Excel 2013", $Context, $IconGet & "\EXCEL.EXE") GUICtrlSetOnEvent(-1, '_Excel') EndIf ;OneNote If FileExists($IconGet & "\ONENOTE.EXE") Then Global $step1 = _GUICtrlCreateODMenuItem("OneNote 2013", $Context, $IconGet & "\ONENOTE.EXE") GUICtrlSetOnEvent(-1, '_OneNote') EndIf ;PowerPoint If FileExists($IconGet & "\POWERPNT.EXE") Then Global $step1 = _GUICtrlCreateODMenuItem("PowerPoint 2013", $Context, $IconGet & "\POWERPNT.EXE") GUICtrlSetOnEvent(-1, '_PowerPoint') EndIf ;Publisher If FileExists($IconGet & "\MSPUB.EXE") Then Global $step1 = _GUICtrlCreateODMenuItem("Publisher 2013", $Context, $IconGet & "\MSPUB.EXE") GUICtrlSetOnEvent(-1, '_Publisher') EndIf ;Word If FileExists($IconGet & "\WINWORD.EXE") Then Global $step1 = _GUICtrlCreateODMenuItem("Word 2013", $Context, $IconGet & "\WINWORD.EXE") GUICtrlSetOnEvent(-1, '_Word') EndIf ;================================================================================== ;================================================================================== ;About GUICtrlCreateMenuItem("", $Context) Global $step2 = _GUICtrlCreateODMenu("Acerca de", $Context, "shell32.dll", -24) Global $step2_1 = _GUICtrlCreateODMenuItem("CyberiaSan", $step2, "shell32.dll", -24) GUICtrlSetOnEvent(-1, '_CyberiaSan') ;================================================================================== TrackPopupMenu($hGui, GUICtrlGetHandle($Context), MouseGetPos(0), MouseGetPos(1)) ;Mostrar en las coordenadas dadas(x, y) el menú emergente (hMenu) que pertenece a una ventana GUI dada(hWnd) Func TrackPopupMenu($hWnd, $hMenu, $x, $y) DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc ;==>TrackPopupMenu ;================================================================================== ;================================================================================== ;Excel Func _Excel() ShellExecute($IconGet & "\EXCEL.EXE") EndFunc ;==>_Excel ;OneNote Func _OneNote() ShellExecute($IconGet & "\ONENOTE.EXE") EndFunc ;==>_OneNote ;PowerPoint Func _PowerPoint() ShellExecute($IconGet & "\POWERPNT.EXE") EndFunc ;==>_PowerPoint ;Publisher Func _Publisher() ShellExecute($IconGet & "\MSPUB.EXE") EndFunc ;==>_Publisher ;Word Func _Word() ShellExecute($IconGet & "\WINWORD.EXE") EndFunc ;==>_Word ;================================================================================== ;About Func _CyberiaSan() ShellExecute(@ComSpec & " /c " & 'start https://www', "", @SW_HIDE) EndFunc Edited June 12, 2022 by kurtykurtyboy added code
charly99 Posted June 12, 2022 Author Posted June 12, 2022 40 minutes ago, kurtykurtyboy said: Check your GUICtrlSetOnEvent functions. Each one is pointing to a function that does not exist. For example, "Excel 2013" should be "_Excel". After fixing all of those and changing $IconGet to my installation directory, it seemed to work just as expected. Here's the code: expandcollapse popup#include <ModernMenuRaw.au3> ;#NoTrayIcon Opt("TrayMenuMode", 3) Opt("GUIOnEventMode", 1) ;If Not FileExists(@ProgramsCommonDir&"\Excel 2013.lnk") Or Not FileExists(@ProgramsCommonDir&"\Word 2013.lnk") Then Exit Global $hGui = GUICreate("WPI2022 Menu Classic", 0, 0, -200, -200, -1, 0, WinGetHandle(AutoItWinGetTitle())) GUISetState() $Context = GUICtrlCreateContextMenu(GUICtrlCreateDummy()) $nSideItem1 = _CreateSideMenu($Context) _SetSideMenuText($nSideItem1, "Microsoft Office") _SetSideMenuColor($nSideItem1, 0xFFFFFF) _SetSideMenuBkColor($nSideItem1, 92111) _SetSideMenuBkGradColor($nSideItem1, 92111) $IconGet = @HomeDrive & "\Program Files\Microsoft Office\Office15" ;~ $IconGet = @HomeDrive & "\Program Files (x86)\Microsoft Office\root\Office16" ;Excel If FileExists($IconGet & "\EXCEL.EXE") Then Global $step1 = _GUICtrlCreateODMenuItem("Excel 2013", $Context, $IconGet & "\EXCEL.EXE") GUICtrlSetOnEvent(-1, '_Excel') EndIf ;OneNote If FileExists($IconGet & "\ONENOTE.EXE") Then Global $step1 = _GUICtrlCreateODMenuItem("OneNote 2013", $Context, $IconGet & "\ONENOTE.EXE") GUICtrlSetOnEvent(-1, '_OneNote') EndIf ;PowerPoint If FileExists($IconGet & "\POWERPNT.EXE") Then Global $step1 = _GUICtrlCreateODMenuItem("PowerPoint 2013", $Context, $IconGet & "\POWERPNT.EXE") GUICtrlSetOnEvent(-1, '_PowerPoint') EndIf ;Publisher If FileExists($IconGet & "\MSPUB.EXE") Then Global $step1 = _GUICtrlCreateODMenuItem("Publisher 2013", $Context, $IconGet & "\MSPUB.EXE") GUICtrlSetOnEvent(-1, '_Publisher') EndIf ;Word If FileExists($IconGet & "\WINWORD.EXE") Then Global $step1 = _GUICtrlCreateODMenuItem("Word 2013", $Context, $IconGet & "\WINWORD.EXE") GUICtrlSetOnEvent(-1, '_Word') EndIf ;================================================================================== ;================================================================================== ;About GUICtrlCreateMenuItem("", $Context) Global $step2 = _GUICtrlCreateODMenu("Acerca de", $Context, "shell32.dll", -24) Global $step2_1 = _GUICtrlCreateODMenuItem("CyberiaSan", $step2, "shell32.dll", -24) GUICtrlSetOnEvent(-1, '_CyberiaSan') ;================================================================================== TrackPopupMenu($hGui, GUICtrlGetHandle($Context), MouseGetPos(0), MouseGetPos(1)) ;Mostrar en las coordenadas dadas(x, y) el menú emergente (hMenu) que pertenece a una ventana GUI dada(hWnd) Func TrackPopupMenu($hWnd, $hMenu, $x, $y) DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc ;==>TrackPopupMenu ;================================================================================== ;================================================================================== ;Excel Func _Excel() ShellExecute($IconGet & "\EXCEL.EXE") EndFunc ;==>_Excel ;OneNote Func _OneNote() ShellExecute($IconGet & "\ONENOTE.EXE") EndFunc ;==>_OneNote ;PowerPoint Func _PowerPoint() ShellExecute($IconGet & "\POWERPNT.EXE") EndFunc ;==>_PowerPoint ;Publisher Func _Publisher() ShellExecute($IconGet & "\MSPUB.EXE") EndFunc ;==>_Publisher ;Word Func _Word() ShellExecute($IconGet & "\WINWORD.EXE") EndFunc ;==>_Word ;================================================================================== ;About Func _CyberiaSan() ShellExecute(@ComSpec & " /c " & 'start https://www', "", @SW_HIDE) EndFunc this is the directory where the app is: $IconGet = @HomeDrive & "\Program Files\Microsoft Office\Office15" but when I try it nothing is executed as if it did not find the path.(my office is 2013)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now