And if the answer is yes... How ?
Special Question about IDE-Tools
Special Question about IDE-Tools
Is it possible to trigger a menu item of the IDE, from an external tool ( e.g. "Restart Compiler" ) ?
And if the answer is yes... How ?
And if the answer is yes... How ?
Re: Special Question about IDE-Tools
@Bisonte,
you can try this on your own risk.
you can try this on your own risk.
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()
Last edited by Axolotl on Thu Jan 02, 2025 2:26 pm, edited 1 time in total.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Re: Special Question about IDE-Tools
Nice approach, but unfortunately this will only work on Windows.
At some point freak had mentioned making IDE functions accessible
via external tools (unfortunately I can't find the post at the moment)
and it could have been that it somehow slipped past me unnoticed...
At some point freak had mentioned making IDE functions accessible
via external tools (unfortunately I can't find the post at the moment)
and it could have been that it somehow slipped past me unnoticed...
Re: Special Question about IDE-Tools
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)
viewtopic.php?t=44895
The feature was canceled:
https://github.com/fantaisie-software/p ... c/pull/169

Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Re: Special Question about IDE-Tools
Yeah, sorry. I am on windows, only.
Trying Linux, but still not sure if I stay with PB on Linux.
So another answer to your Question: Maybe this is available on Linux and MacOS:
1. Create a shortcut
2. Call the shortcut by (I dont know) SendKeys() or similar.
BTW: Is this section only intended for platform-independent solutions?
Trying Linux, but still not sure if I stay with PB on Linux.
So another answer to your Question: Maybe this is available on Linux and MacOS:
1. Create a shortcut
2. Call the shortcut by (I dont know) SendKeys() or similar.
BTW: Is this section only intended for platform-independent solutions?
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).

