Is it possible in AutoGui to programmatically toggle AutoClose Brackets?
I would like to disable this funcion before sending hotstrings and re-enable it just after.
Thanks.
AutoClose Brackets Topic is solved
Re: AutoClose Brackets
Maybe just paste the contents instead of using the hotstring to "type" the text.
https://www.autohotkey.com/boards/viewtopic.php?t=39078
https://www.autohotkey.com/boards/viewtopic.php?t=39078
Re: AutoClose Brackets
Thanks, but it does not solve my problem.
Is it possible to use gui scripting to trigger the menu item?
Is it possible to use gui scripting to trigger the menu item?
--
Windows 11
AHK 1.1.35.00
Adventure 3.0.4
Windows 11
AHK 1.1.35.00
Adventure 3.0.4
Re: AutoClose Brackets
Try this:
Code: Select all
::rc::
ToggleBrackets()
Send VarSetCapacity(RECT, 16, 0)
ToggleBrackets()
Return
ToggleBrackets() {
TopMenu := " &Options "
MenuItem := "Autoclose &Brackets"
WinMenuSelectItem A,, %TopMenu%, %MenuItem%
}
Re: AutoClose Brackets
Thanks, Alguimist.
And my appologies for being so late to respond.
The script is fine but:
could we know if the menu item is checked prior to select it?
And my appologies for being so late to respond.
The script is fine but:
could we know if the menu item is checked prior to select it?
--
Windows 11
AHK 1.1.35.00
Adventure 3.0.4
Windows 11
AHK 1.1.35.00
Adventure 3.0.4
Re: AutoClose Brackets Topic is solved
You can do it with the Windows API function GetMenuState.Rafio wrote:could we know if the menu item is checked prior to select it?
Code: Select all
Global g_AppName := "AutoGUI"
, g_TopMenu := " &Options "
, g_MenuItem := "Autoclose &Brackets"
::rc::
Enabled := IsAutocloseBracketEnabled() ; Store current state
If (Enabled == -1) {
Return
}
EnableAutocloseBrackets(0) ; Disable
Send VarSetCapacity(RECT, 16, 0)
If (Enabled) {
EnableAutocloseBrackets(1) ; Restore
}
Return
EnableAutocloseBrackets(Enable := True) {
AutocloseBracketsEnabled := IsAutocloseBracketEnabled()
If ((!Enable && AutocloseBracketsEnabled) || (Enable && !AutocloseBracketsEnabled)) {
WinMenuSelectItem A,, %g_TopMenu%, %g_MenuItem%
}
}
IsAutocloseBracketEnabled() {
WinGet hWnd, ID, %g_AppName% v ahk_class AutoHotkeyGUI
If (!hWnd) {
MsgBox 0x10, Error, The window could not be found.
Return -1
}
hMenu := GetMenu(hWnd)
OptionsMenuPos := FindMenuPos(hMenu, g_TopMenu)
hMenuOptions := GetSubMenu(hMenu, OptionsMenuPos)
AutocloseBracketsPos := FindMenuPos(hMenuOptions, g_MenuItem)
Return IsMenuItemChecked(hMenuOptions, AutocloseBracketsPos)
}
FindMenuPos(hMenu, MenuString) {
MenuItemCount := GetMenuItemCount(hMenu)
Loop %MenuItemCount% {
If (GetMenuString(hMenu, A_Index - 1) = MenuString) {
Return A_Index - 1 ; Zero-based
}
}
Return -1
}
GetMenu(hWnd) {
Return DllCall("GetMenu", "Ptr", hWnd, "Ptr")
}
GetSubMenu(hMenu, nPos) {
Return DllCall("GetSubMenu", "Ptr", hMenu, "UInt", nPos, "Ptr")
}
GetMenuItemCount(hMenu) {
Return DllCall("GetMenuItemCount", "Ptr", hMenu)
}
GetMenuItemID(hMenu, nPos) {
Return DllCall("GetMenuItemID", "Ptr", hMenu, "UInt", nPos)
}
GetMenuString(hMenu, uIDItem) { ; zero-based
Local lpString, MenuItemID
VarSetCapacity(lpString, 4096)
If !(DllCall("GetMenuString", "Ptr", hMenu, "UInt", uIDItem, "Str", lpString, "UInt", 4096, "UInt", 0x400)) {
MenuItemID := GetMenuItemID(hMenu, uIDItem)
If (MenuItemID > -1) {
Return "SEPARATOR"
} Else {
Return (GetSubMenu(hMenu, uIDItem)) ? "SUBMENU" : "ERROR"
}
}
Return lpString
}
IsMenuItemChecked(hMenu, Pos) {
MenuState := DllCall("GetMenuState", "Ptr", hMenu, "UInt", Pos, "UInt", 0x400) ; By position
Return MenuState & 0x8 ; MF_CHECKED
}
Re: AutoClose Brackets
Perfect!
I have modified your script to make it a unique function that only desables the menu item.
Problem solved.
I have modified your script to make it a unique function that only desables the menu item.
Problem solved.
--
Windows 11
AHK 1.1.35.00
Adventure 3.0.4
Windows 11
AHK 1.1.35.00
Adventure 3.0.4
Who is online
Users browsing this forum: No registered users and 3 guests