And if the answer is yes... How ?

Code: Select all
EnableExplicit
; Edit: Windows only solution:
; Easy MenuItem Constants
;
#MENUINDEX_Compiler = 4 ; "Compiler"
#MENUINDEX_RestartCompiler = 7 ; "Re&start Compiler" ..... this is the correct menu item for Restart Compiler
;#MENUINDEX_RestartCompiler = 9 ; "Compiler Options..." ..... for test reasons -> this shows the Options Dialog
; ---
Procedure GetPureBasicMainWindowHandle()
Protected hwndMain
;
; simplified version
;
hwndMain = FindWindow_("WindowClass_2", #Null) ; handle of Purebasic main window
ProcedureReturn hwndMain
EndProcedure
; ---
Procedure.s ReadMenuItemText(hMenu, Index)
Protected mii.MENUITEMINFO
Protected text$
mii\cbSize = SizeOf(MENUITEMINFO)
mii\fMask = #MIIM_STRING
mii\fType = #MFT_STRING
mii\dwTypeData = 0 ; <= get the needed length
If GetMenuItemInfo_(hMenu, Index, #True, @mii) ; : Debug "cch = " + mii\cch
text$ = Space(mii\cch)
mii\dwTypeData = @text$
If GetMenuItemInfo_(hMenu, Index, #True, @mii)
text$ = PeekS(mii\dwTypeData, mii\cch) ; success
Else
text$ = "" ; failure
EndIf
EndIf
ProcedureReturn text$
EndProcedure
; ---
Procedure GetMenuItemSubMenu(hMenu, Index)
Protected result, mii.MENUITEMINFO
mii\cbSize = SizeOf(MENUITEMINFO)
mii\fMask = #MIIM_SUBMENU
If GetMenuItemInfo_(hMenu, Index, #True, @mii)
ProcedureReturn mii\hSubMenu
EndIf
ProcedureReturn 0
EndProcedure
; ---
Procedure SendMenuItemClick(hWnd, hMenu, Index)
Protected nMenuID
nMenuID = GetMenuItemID_(hMenu, Index)
PostMessage_(hWnd, #WM_COMMAND, nMenuID, #Null) ; hit the menu...
EndProcedure
; ---
Procedure SendRestartCompilerClick()
Protected hwndPB, hMenu, hSubMenu
Protected text$
hwndPB = GetPurebasicMainWindowHandle()
If hwndPB
hMenu = GetMenu_(hwndPB)
If hMenu
; text$ = ReadMenuItemText(hMenu, #MENUINDEX_Compiler)
; Debug " MenuItem [" + #MENUINDEX_Compiler + "] = '" + text$ + "'"
hSubmenu = GetMenuItemSubMenu(hMenu, #MENUINDEX_Compiler)
If hSubmenu
; text$ = ReadMenuItemText(hSubMenu, #MENUINDEX_RestartCompiler)
; Debug " MenuItem [" + #MENUINDEX_RestartCompiler + "] = '" + text$ + "'"
SendMenuItemClick(hwndPB, hSubmenu, #MENUINDEX_RestartCompiler)
EndIf
EndIf
EndIf
EndProcedure
SendRestartCompilerClick()
Here is freak's feature thread:Bisonte wrote: Thu Jan 02, 2025 2:00 am At some point freak had mentioned making IDE functions accessible
via external tools (unfortunately I can't find the post at the moment)