Menu Separator and Always Available?

Get help with using AutoHotkey and its commands and hotkeys
Confusedatwork3
Posts: 38
Joined: 29 Jan 2016, 16:23

Menu Separator and Always Available?

19 Jul 2016, 13:18

Code: Select all

!^M::
Menu, cgcmenu1, Add,CGC Report Thede Ward, Menuhandler
Menu, cgcmenu1, Add,CGC Adjust File, Menuhandler
Menu, sohmenu1, Add,Inbound Order, Menuhandler
Menu, sohmenu1, Add,Load Setup, Menuhandler
Menu, sohmenu1, Add,FOB Code Setup, Menuhandler


Menu, FullMenu, Add, Hamilton, :hamMenu1
Menu, FullMenu, Add, Great Lakes, :gleMenu1
Menu, FullMenu, Add, Milling Group, :millingMenu1
Menu, FullMenu, Add, P&H, :P&HMenu1
Menu, FullMenu, Add, Winnipeg, :WinnipegMenu1
Menu, FullMenu, Add, Primo, :PrimoMenu1
Menu, FullMenu, Add, Satelitte, :SatMenu1
Menu, FullMenu, Add, CGC Reports, :CGCMenu1
Menu, FullMenu, Add, Shipping Order Hamilton, :SOHMenu1
I have the following codes... is there a way to add a line separator to the full menu? I did have one but everytime i ran the report it would just keep adding lines.

This also got me thinking, instead of pressing ^!M all the time, could i run the script and have the menu in the background all the time?

THanks everyone
Shadowpheonix
Posts: 1259
Joined: 16 Apr 2015, 09:41

Re: Menu Separator and Always Available?

19 Jul 2016, 18:22

By restructuring your code as follows, you can add the line separator without having it constantly add more...

Code: Select all

; Put everything between this comment and the next one in the AutoExec section of your script (IE: before any hotkeys, hotstrings, or return commands).
Menu, cgcmenu1, Add,CGC Report Thede Ward, Menuhandler
Menu, cgcmenu1, Add,CGC Adjust File, Menuhandler
Menu, sohmenu1, Add,Inbound Order, Menuhandler
Menu, sohmenu1, Add,Load Setup, Menuhandler
Menu, sohmenu1, Add,FOB Code Setup, Menuhandler
 
 
Menu, FullMenu, Add, Hamilton, :hamMenu1
Menu, FullMenu, Add, Great Lakes, :gleMenu1
Menu, FullMenu, Add, Milling Group, :millingMenu1
Menu, FullMenu, Add, P&H, :P&HMenu1
Menu, FullMenu, Add, Winnipeg, :WinnipegMenu1
Menu, FullMenu, Add, Primo, :PrimoMenu1
Menu, FullMenu, Add, Satelitte, :SatMenu1
Menu, FullMenu, Add, CGC Reports, :CGCMenu1
Menu, FullMenu, Add, Shipping Order Hamilton, :SOHMenu1
; Everything above this point should be in the AutoExec section of your script.


!^M::
Menu, FullMenu, Show
Return

!^G::    ; Toggle an always on top button you can click to show your menu.
If !WinExist("ahk_ID " ShowFullMenuGuiHWND)
{
	Gui, ShowFullMenuGui:New, +AlwaysOnTop +HWNDShowFullMenuGuiHWND -Resize -SysMenu
	Gui, ShowFullMenuGui:Add, Button, g!^M, Menu    ; The "g!^M" portion here creates a "GoTo Label" that runs the code for the "!^M" hotkey.
	Gui, ShowFullMenuGui:Show
}
Else
	Gui, ShowFullMenuGui:Destroy
Return
hunter99
Posts: 128
Joined: 20 Jan 2014, 17:57

Re: Menu Separator and Always Available?

20 Jul 2016, 00:29

Hi Confuse,
Just add these 2 lines at the start of every new MenuName you use.
Would add another line with each usage; pulling out my hair, then found this:
https://autohotkey.com/board/topic/1057 ... s-growing/
GEV had the answer.
I never used this with a hotkey, just a label in a script but it should work.

Code: Select all

!^M::
Menu, cgcmenu1, Add				;ADDED
Menu, cgcmenu1, deleteAll		;ADDED
Menu, cgcmenu1, Add,CGC Report Thede Ward, Menuhandler
Menu, cgcmenu1, Add,CGC Adjust File, Menuhandler
Menu, sohmenu1, Add				;ADDED		
Menu, sohmenu1, deleteAll		;ADDED
Menu, sohmenu1, Add,Inbound Order, Menuhandler
Menu, sohmenu1, Add,Load Setup, Menuhandler
Menu, sohmenu1, Add,FOB Code Setup, Menuhandler
 
Menu, FullMenu, Add				;ADDED	
Menu, FullMenu, deleteAll 		;ADDED
Menu, FullMenu, Add, Hamilton, :hamMenu1
Menu, FullMenu, Add, Great Lakes, :gleMenu1
Menu, FullMenu, Add, Milling Group, :millingMenu1
Menu, FullMenu, Add, P&H, :P&HMenu1
Menu, FullMenu, Add, Winnipeg, :WinnipegMenu1
Menu, FullMenu, Add, Primo, :PrimoMenu1
Menu, FullMenu, Add, Satelitte, :SatMenu1
Menu, FullMenu, Add, CGC Reports, :CGCMenu1
Menu, FullMenu, Add, Shipping Order Hamilton, :SOHMenu1
hunter99
hunter99
Posts: 128
Joined: 20 Jan 2014, 17:57

Re: Menu Separator and Always Available?

20 Jul 2016, 08:27

Found time to test code in my prior post. OP's orig example was missing too many menus to use as an example. I'm old and lazy.
Here is a short example to show using the deleteAll function to stop extra lines from being added. You can comment out the 3 "deleteAll lines" to see problem.

Code: Select all

!^M::
Menu, FullMenu, Add				;here it adds the FullMenu so next line works
Menu, FullMenu, deleteAll 		;ADDED to stop adding a extra line on every use.
Menu, cgcmenu1, Add				;Creates a separator line.
Menu, cgcmenu1, deleteAll		;ADDED to stop adding a extra line on every use.
Menu, cgcmenu1, Add,CGC Report Thede Ward, ThedeWard 
Menu, cgcmenu1, add
Menu, cgcmenu1, Add,CGC Adjust File, CGCAdjust
Menu, sohmenu1, Add				;Creates a separator line.
Menu, sohmenu1, deleteAll		;ADDED to stop adding a extra line on every use.
Menu, sohmenu1, Add,Inbound Order, Inbound
Menu, sohmenu1, Add
Menu, sohmenu1, Add,Load Setup, Load
Menu, sohmenu1, Add,FOB Code Setup, FOB
Menu, FullMenu, Add, CGC Reports, :CGCMenu1
Menu, FullMenu, Add				;Creates a separator line.
Menu, FullMenu, Add, Shipping Order Hamilton, :SOHMenu1
Menu, FullMenu, Show
return

;used to show clicking on menu items for this test.
ThedeWard:
msgbox,,, CGC Report Thede Ward
return
CGCAdjust:
msgbox,,, CGC Adjust File
return
Inbound:
msgbox,,, Inbound Order
return
Load:
msgbox,,, Load Setup
return
FOB:
msgbox,,, FOB Code Setup
return

esc::
ExitApp
return
hunter99

You may to get a copy of CodeQuicktester by GeekDude for easy testing of small snippets of code. From here:
https://autohotkey.com/boards/viewtopic.php?f=6&t=6113

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], masato, moowee, songdg and 51 guests