Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Side menus, Menu within a menu


  • Please log in to reply
10 replies to this topic
happytodd
  • Members
  • 142 posts
  • Last active: Sep 25 2010 04:21 AM
  • Joined: 12 Nov 2007
Ok as most of you know Ive been trying to make a notepad. I'm trying to make a menu within a menu for eg:
Theres a file and edit button up the top of my notepad page. Then theres a list of options in that. When you highlight your mouse over the side menu button a side menu will come up. For example go into Paint, Click view then theres a link called Zoom. This is the side menu. Does anyone know how to make this for my notepad? My notepad script is:

; Create the sub-menus for the menu bar:
Menu, FileMenu, Add, &New, FileNew,
Menu, FileMenu, Add, &Open...        Ctrl+O, FileOpen 
Menu, FileMenu, Add, &Save             Ctrl+S, FileSave 
Menu, FileMenu, Add, &Save As..., FileSaveAs 
Menu, FileMenu, Add  ; Separator line.
Menu, FileMenu, Add, &Print, FilePrint
Menu, FileMenu, Add  ; Separator line.
Menu, FileMenu, Add, &Exit, FileExit
Menu, EditMenu, Add, &Undo            Ctrl+Z, EditUndo
Menu, EditMenu, Add  ; Separator line.
Menu, EditMenu, Add, &Cut               Ctrl+X, EditCut
Menu, EditMenu, Add, &Copy             Ctrl+Z, EditCopy
Menu, EditMenu, Add, &Paste            Ctrl+V, EditPaste
Menu, EditMenu, Add  ; Separator line.
Menu, EditMenu, Add, &SelectAll       Ctrl+A, EditSelectAll
Menu, HelpMenu, Add, &About Orangi, HelpAbout

; Create the menu bar by attaching the sub-menus to it:
Menu, MyMenuBar, Add, &File, :FileMenu
Menu, MyMenuBar, Add, &Edit, :EditMenu
Menu, MyMenuBar, Add, &Help, :HelpMenu

; Attach the menu bar to the window:
Gui, Menu, MyMenuBar

; Create the main Edit control and display the window:
Gui, +Resize  ; Make the window resizable.
Gui, Add, Edit, vMainEdit WantTab W600 R20
Gui, Show,, Orangi Document
CurrentFileName =  ; Indicate that there is no current file.
return

FileNew:
GuiControl,, MainEdit  ; Clear the Edit control.
return

FileOpen: 
Gui +OwnDialogs  ; Force the user to dismiss the FileSelectFile dialog before returning to the main window.
FileSelectFile, SelectedFileName, 3,, Open File, Text Documents (*.txt)
if SelectedFileName =  ; No file selected.
    return
Gosub FileRead
return

FileRead:  ; Caller has set the variable SelectedFileName for us.
FileRead, MainEdit, %SelectedFileName%  ; Read the file's contents into the variable.
if ErrorLevel
{
    MsgBox Could not open "%SelectedFileName%".
    return
}
GuiControl,, MainEdit, %MainEdit%  ; Put the text into the control.
CurrentFileName = %SelectedFileName%
Gui, Show,, %CurrentFileName%   ; Show file name in title bar.
return

FileSave: 
if CurrentFileName =   ; No filename selected yet, so do Save-As instead.
    Goto FileSaveAs
Gosub SaveCurrentFile
return

FileSaveAs: 
Gui +OwnDialogs  ; Force the user to dismiss the FileSelectFile dialog before returning to the main window.
FileSelectFile, SelectedFileName, S16,, Save File, Text Documents (*.txt)
if SelectedFileName =  ; No file selected.
    return
CurrentFileName = %SelectedFileName%
Gosub SaveCurrentFile
return

FilePrint:
filename := A_ScriptFullPath 
Run Notepad.exe %filename% 
WinWaitActive ahk_class Notepad ; Name varies with localization of Windows 
WinHide ; use the window found above
Send ^p 
Return

EditUndo:
Send ^z

EditCut:
Send ^x

EditCopy:
Send ^c

EditPaste:
send ^v

EditSelectAll:
send ^a

SaveCurrentFile:  ; Caller has ensured that CurrentFileName is not blank.
IfExist %CurrentFileName%
{
    FileDelete %CurrentFileName%
    if ErrorLevel
    {
        MsgBox The attempt to overwrite "%CurrentFileName%" failed.
        return
    }
}
GuiControlGet, MainEdit  ; Retrieve the contents of the Edit control.
FileAppend, %MainEdit%, %CurrentFileName%  ; Save the contents to the file.
; Upon success, Show file name in title bar (in case we were called by FileSaveAs):
Gui, Show,, %CurrentFileName%
return
HelpAbout:
  MsgBox, 32, About %GUI_TITLE% %GUI_VERSION% %GUI_BUILDDATE%,
  ( LTrim,
    Orangi was designed for educational purposes only.
    
    It started back in early November 2007. I started
    studying a program called AutoHotKey from there I have
    designed this short program for everyone to try out.
    If anyone has any complaints of suggestions please
    email me.
    
    Orangi works on Windows 2000/XP/NT and above only.

    Author:
    ` ` Happytodd <[email protected]>

    Special Thanks:
    ` ` Paulo-nli, engunneer.
  )
Return

Gui, 2:Add, Button, Default, OK
Gui, 2:Show
return

2ButtonOK:  ; This section is used by the "about box" above.
2GuiClose:
2GuiEscape:
Gui, 1:-Disabled  ; Re-enable the main window (must be done prior to the next step).
Gui Destroy  ; Destroy the about box.
return

GuiDropFiles:  ; Support drag & drop.
Loop, parse, A_GuiEvent, `n
{
    SelectedFileName = %A_LoopField%  ; Get the first file only (in case there's more than one).
    break
}
Gosub FileRead
return

GuiSize:
if ErrorLevel = 1  ; The window has been minimized.  No action needed.
    return
; Otherwise, the window has been resized or maximized. Resize the Edit control to match.
NewWidth := A_GuiWidth - 20
NewHeight := A_GuiHeight - 20
GuiControl, Move, MainEdit, W%NewWidth% H%NewHeight%
return

FileExit:     ; User chose "Exit" from the File menu.
GuiClose:  ; User closed the window.
ExitApp

Please help as I want to use this side menu for templates by clicking a button like html and a html template will load on the page by using macros.
Thanks for your time happytodd
Posted Image
Posted Image

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

To have MenuItemName become a submenu -- which is a menu item that opens a new menu when selected -- specify for Label-or-Submenu a colon followed by the MenuName of an existing custom menu. For example:

Menu, MySubmenu, add, Item1
Menu, tray, add, This Menu Item Is A Submenu, :MySubmenu



Micahs
  • Members
  • 463 posts
  • Last active: Mar 01 2013 06:01 AM
  • Joined: 01 Dec 2006
Something like this?
Menu, FileMenu, Add, &New, FileNew,
Menu, FileMenu, Add, &Open...        Ctrl+O, FileOpen
Menu, FileMenu, Add, &Save             Ctrl+S, FileSave
Menu, FileMenu, Add, &Save As..., FileSaveAs
Menu, FileMenu, Add  ; Separator line.
Menu, FileMenu, Add, &Print, FilePrint
Menu, FileMenu, Add  ; Separator line.
Menu, FileMenu, Add, &Exit, FileExit
Menu, EditMenu, Add, &Undo            Ctrl+Z, EditUndo
Menu, EditMenu, Add  ; Separator line.
Menu, EditMenu, Add, &Cut               Ctrl+X, EditCut
Menu, EditMenu, Add, &Copy             Ctrl+Z, EditCopy
Menu, EditMenu, Add, &Paste            Ctrl+V, EditPaste
Menu, EditMenu, Add  ; Separator line.
Menu, EditMenu, Add, &SelectAll       Ctrl+A, EditSelectAll
Menu, HelpMenu, Add, &About Orangi, HelpAbout

Menu, ZoomMenu, Add, &Normal, ZoomNorm
Menu, ZoomMenu, Add, &Large, ZoomLarge
Menu, ZoomMenu, Add, &Really Big, ZoomReallyBig

Menu, ViewMenu, Add, &View Something, ZoomSomething
Menu, ViewMenu, Add, &Something Else, ZoomSomethingElse
Menu, ViewMenu, Add, &Zoom, :ZoomMenu

; Create the menu bar by attaching the sub-menus to it:
Menu, MyMenuBar, Add, &File, :FileMenu
Menu, MyMenuBar, Add, &Edit, :EditMenu
Menu, MyMenuBar, Add, &View, :ViewMenu
Menu, MyMenuBar, Add, &Help, :HelpMenu

; Attach the menu bar to the window:
Gui, Menu, MyMenuBar
Gui, Add, Button, w250, Hello
Gui, Show

Return

ZoomSomething:
ZoomSomethingElse:
ZoomNorm:
ZoomLarge:
ZoomReallyBig:
FileNew:
FileOpen:
FileSave:
FileSaveAs:
FilePrint:
FileExit:
EditUndo:
EditCut:
EditCopy:
EditPaste:
EditSelectAll:
HelpAbout:
Return

guiClose:
	ExitApp
Return

Posted Image

happytodd
  • Members
  • 142 posts
  • Last active: Sep 25 2010 04:21 AM
  • Joined: 12 Nov 2007
Yes thankyou very much, I might be able to use some more than just the sub menu script. Your also going in my list of thankyous :D
Posted Image
Posted Image

happytodd
  • Members
  • 142 posts
  • Last active: Sep 25 2010 04:21 AM
  • Joined: 12 Nov 2007
It was very confusing for me to set up right but now...
I want a message to appear when I press a certain button in the menu list. For example when I click the button some text will be written up into my notepad page. Anyone got tips please?
Posted Image
Posted Image

happytodd
  • Members
  • 142 posts
  • Last active: Sep 25 2010 04:21 AM
  • Joined: 12 Nov 2007
Sorry I figured it out. Had to add a Send input first. Now I want too add another feature. When making the script and you have like a paragraph for example. If you want to skip to the next line how do you make it skip because my paragraph just keeps connecting up in the same line. Anyone know how to skip a line?
Posted Image
Posted Image

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005
For example when I click the button some text will be written up into my notepad page.
I'm not sure I'm understand your question
this example writes to notepad
#NoEnv
#persistent
setworkingdir, %a_scriptdir%
SetTitleMatchMode, 2
SetTitleMatchMode, fast

AA=Untitled - Notepad   ;english  look for the correct title upper lower
;AA=Unbenannt - Editor    ;german

IfWinNotexist,%AA%
   Run, Notepad.exe,

   Menu,S3,add,http://www.autohotkey.com  ,MH4
   Menu,S3,add,http://www.metric4us.com/  ,MH4
   Menu,S3,add,%A_now%  your ahk- version is: %A_AHKVERSION% ,MH4

   menu,myMenuBar,Add,Search  ,:S3
   gui,3:menu,MyMenuBar

gui,3:show,x0 y0 h30 w420,test
return

MH4:
ControlSend, Edit1,{Space}%A_ThisMenuItem%`n,%AA%
return

3Guiclose:
exitapp


happytodd
  • Members
  • 142 posts
  • Last active: Sep 25 2010 04:21 AM
  • Joined: 12 Nov 2007
No I mean like:
made a button called Macro and when I press this button my message will load up in a giant textbox. Now If I want a paragraph in my textbox area how will I change it in my script? Because if I have a message and and I would want a new paragraph I press enter in the code but it doesn't work. It just keeps going next to it. Text this:

; Create the sub-menus for the menu bar:
Menu, FileMenu, Add, &New, FileNew,
Menu, FileMenu, Add, &Open...        Ctrl+O, FileOpen 
Menu, FileMenu, Add, &Save             Ctrl+S, FileSave 
Menu, FileMenu, Add, &Save As..., FileSaveAs
Menu, FileMenu, Add  ; Separator line.
Menu, TempMenu, Add, &Html, TempHtml 
Menu, TempMenu, Add, &AutoHotKey, TempAutoHotKey 
Menu, FileMenu, Add, &Templates, :TempMenu  
Menu, FileMenu, Add, &Print, FilePrint
Menu, FileMenu, Add  ; Separator line.
Menu, FileMenu, Add, &Exit, FileExit
Menu, EditMenu, Add, &Undo            Ctrl+Z, EditUndo
Menu, EditMenu, Add  ; Separator line.
Menu, EditMenu, Add, &Cut               Ctrl+X, EditCut
Menu, EditMenu, Add, &Copy             Ctrl+Z, EditCopy
Menu, EditMenu, Add, &Paste            Ctrl+V, EditPaste
Menu, EditMenu, Add  ; Separator line.
Menu, EditMenu, Add, &SelectAll       Ctrl+A, EditSelectAll
Menu, HelpMenu, Add, &About Orangi, HelpAbout


; Create the menu bar by attaching the sub-menus to it:
Menu, MyMenuBar, Add, &File, :FileMenu
Menu, MyMenuBar, Add, &Edit, :EditMenu
Menu, MyMenuBar, Add, &Help, :HelpMenu

; Attach the menu bar to the window:
Gui, Menu, MyMenuBar

; Create the main Edit control and display the window:
Gui, +Resize  ; Make the window resizable.
Gui, Add, Edit, vMainEdit WantTab W600 R20
Gui, Show,, Orangi Document
CurrentFileName =  ; Indicate that there is no current file.
return

TempHtml:
Send
<html>
    <body>
    </body>
    </html>
return

TempAutoHotKey:


FileNew:
GuiControl,, MainEdit  ; Clear the Edit control.
return

FileOpen: 
Gui +OwnDialogs  ; Force the user to dismiss the FileSelectFile dialog before returning to the main window.
FileSelectFile, SelectedFileName, 3,, Open File, Text Documents (*.txt)
if SelectedFileName =  ; No file selected.
    return
Gosub FileRead
return

FileRead:  ; Caller has set the variable SelectedFileName for us.
FileRead, MainEdit, %SelectedFileName%  ; Read the file's contents into the variable.
if ErrorLevel
{
    MsgBox Could not open "%SelectedFileName%".
    return
}
GuiControl,, MainEdit, %MainEdit%  ; Put the text into the control.
CurrentFileName = %SelectedFileName%
Gui, Show,, %CurrentFileName%   ; Show file name in title bar.
return

FileSave: 
if CurrentFileName =   ; No filename selected yet, so do Save-As instead.
    Goto FileSaveAs
Gosub SaveCurrentFile
return

FileSaveAs: 
Gui +OwnDialogs  ; Force the user to dismiss the FileSelectFile dialog before returning to the main window.
FileSelectFile, SelectedFileName, S16,, Save File, Text Documents (*.txt)
if SelectedFileName =  ; No file selected.
    return
CurrentFileName = %SelectedFileName%
Gosub SaveCurrentFile
return

FilePrint:
filename := A_ScriptFullPath 
Run Notepad.exe %filename% 
WinWaitActive ahk_class Notepad ; Name varies with localization of Windows 
WinHide ; use the window found above
Send ^p 
Return

EditUndo:
Send ^z

EditCut:
Send ^x

EditCopy:
Send ^c

EditPaste:
send ^v

EditSelectAll:
send ^a

SaveCurrentFile:  ; Caller has ensured that CurrentFileName is not blank.
IfExist %CurrentFileName%
{
    FileDelete %CurrentFileName%
    if ErrorLevel
    {
        MsgBox The attempt to overwrite "%CurrentFileName%" failed.
        return
    }
}
GuiControlGet, MainEdit  ; Retrieve the contents of the Edit control.
FileAppend, %MainEdit%, %CurrentFileName%  ; Save the contents to the file.
; Upon success, Show file name in title bar (in case we were called by FileSaveAs):
Gui, Show,, %CurrentFileName%
return
HelpAbout:
  MsgBox, 32, About %GUI_TITLE% %GUI_VERSION% %GUI_BUILDDATE%,
  ( LTrim,
    Orangi was designed for educational purposes only.
    
    It started back in early November 2007. I started
    studying a program called AutoHotKey from there I have
    designed this short program for everyone to try out.
    If anyone has any complaints of suggestions please
    email me.
    
    Orangi works on Windows 2000/XP/NT and above only.

    Author:
    ` ` Happytodd <[email protected]>

    Special Thanks:
    ` ` Paulo-nli, engunneer, lexikos, Micahs.
  )
Return

Gui, 2:Add, Button, Default, OK
Gui, 2:Show
return

2ButtonOK:  ; This section is used by the "about box" above.
2GuiClose:
2GuiEscape:
Gui, 1:-Disabled  ; Re-enable the main window (must be done prior to the next step).
Gui Destroy  ; Destroy the about box.
return

GuiDropFiles:  ; Support drag & drop.
Loop, parse, A_GuiEvent, `n
{
    SelectedFileName = %A_LoopField%  ; Get the first file only (in case there's more than one).
    break
}
Gosub FileRead
return

GuiSize:
if ErrorLevel = 1  ; The window has been minimized.  No action needed.
    return
; Otherwise, the window has been resized or maximized. Resize the Edit control to match.
NewWidth := A_GuiWidth - 20
NewHeight := A_GuiHeight - 20
GuiControl, Move, MainEdit, W%NewWidth% H%NewHeight%
return

FileExit:     ; User chose "Exit" from the File menu.
GuiClose:  ; User closed the window.
ExitApp
But in this theres a link called Html and itll send a html template on the page. But it all goes next to it like
<html> <body> </body> </html> but I want it to appear like
<html>
<body>
</body>
</html>
how do I configure it? if it makes any sense
Posted Image
Posted Image

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005
TempHtml:

gosub,filenew

Send,<html>`n<body>`n</body>`n</html>`n

return



TempAutoHotKey:

gosub,filenew

send,autohotkeytest1`nautohotkeytest2`n

return



happytodd
  • Members
  • 142 posts
  • Last active: Sep 25 2010 04:21 AM
  • Joined: 12 Nov 2007
This is what Im after, Thankyou very much :) sorry it was a little confusing to explain the problem :p
Posted Image
Posted Image

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005
if you like you can send whole test file to the editfield, example file test22.txt
TempHtml:
gosub,filenew
fileread,AA,text22.txt
GuiControl,Text,Edit1,%AA%
return