topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Monday November 4, 2024, 5:25 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: program menu printing  (Read 11369 times)

ares09x

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 5
    • View Profile
    • Donate to Member
IDEA: program menu printing
« on: March 11, 2009, 02:12 PM »
Greetings,

Perhaps this program already exists, but I have not yet found it ...

A friend of mine asked me to print out all of the menus in a particular program (in this case, it was MSN Premium) and write out explanations of what each of them does.  I would like to have a program that is capable of printing all of the menus that another program makes available in some kind of outline form, even just plain text, so that I can annotate each one with additional information.  I know that I can go through manually and capture the menu pages using something like SnagIt, and add annotations, but that seems like a very manual process to go through for a lot of menus.

As an example, the results for the File menu for MSN might look like this:

File
   • New
  • Mail Message - Ctrl+N
  • Window - Ctrl+Shift+N
  • Appointment - Ctrl+Shift+A
  • Contact - Ctrl+Shift+C
   • Open... - Ctrl+O
   • Save As...
   • Appointment - Ctrl+Shift+A
   • Copy E-mail...
   • Print... - Ctrl+P
   • Print Preview...
   • Send Link by E-mail
   • Close - Alt+F4

I would want to invoke the program and then point it to a .exe file, or else drop a desktop shortcut onto its desktop shortcut to generate an output - it would ask what the output's filename should be and where it should be stored (maybe with some default?).  There might be some options like the format of the output (eg, .txt, RTF, Excel/CSV, etc), but I'd love to start with something basic that will generate this kind of output automatically.

Any ideas about existing programs, or how hard it would be to create such a program?

Thanks,
Bob Y.
« Last Edit: March 11, 2009, 09:22 PM by ares09x »

mmdoogie

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 14
    • View Profile
    • My Projects
    • Donate to Member
Re: IDEA: program menu printing
« Reply #1 on: April 07, 2009, 11:20 PM »
You might want to give the EXE a look with one of these first.
http://angusj.com/resourcehacker/
http://www.wilsonc.d...10resourceeditor.htm

One way menus can be stored is as resources in the EXE.
If its done this way, there should be a entries for the menus; however, there are lots of other ways to make menus work too.

Its been a while since I've used either, so I don't remember how easy it is to copy the info out, but I think you can save it as a text file or copy and paste it or something.

From the program side, I have an idea of how to go about it, but don't really have time to mash it out right now.
For the other coders out there: with WINAPI you can use GetCursorPos to get the cursor position, then WindowFromPoint to get the hWnd for the window under that point.  From there, you can do GetMenu to get the hMenu.  Then, just recurse through the menu structures to print out the names.

Hope this helps.

--matt

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: program menu printing
« Reply #2 on: April 08, 2009, 08:53 AM »
It's a nice idea to use a resource editor, but it probably wont help you too much with menus..

Another thing you could do is record a screencast movie of you opening all the menus, and then just print the frames of your choice (or send them the video if that is sufficient).

It would'nt be too hard to use a screenshot program like Screenshot Captor to capture an image of each menu in turn using a hotkey.. i still think that still might be your best way to go.  So pulldown menu, hit hotkey, pulldown next menu, hit hotkey, etc.. Sometimes the manual approaches are the most efficient.  You'd just want to make sure you have Screenshot Captor configured in the autosave mode so it doesn't prompt you after each screenshot.


skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: program menu printing
« Reply #3 on: April 08, 2009, 07:17 PM »
 :) Try GetMenus!

Press F1 to extract the menus of the active window to a text file.

Skrommel

;GetMenus.ahk
; Press F1 to extract the menus of the active window to a text file
;Skrommel @ 2009

#SingleInstance,Force
SetBatchLInes,-1
AutoTrim,Off


F1::
WinGet,hWnd,ID,A
wholemenu=
space=
hMenu:=DllCall("user32\GetMenu","UInt",hWnd)
GETMENU(hMenu)
FileDelete,%A_Temp%\Menus.txt
FileAppend,%wholemenu%,%A_Temp%\Menus.txt
Run,%A_Temp%\Menus.txt
Return


GETMENU(hMenu)
{
  nMaxCount=100
  uFlag:=0x0400  ;MF_BYPOSITION
  global wholemenu
  global space

  menuitemcount:=DllCall("GetMenuItemCount",UInt,hMenu)
  Loop,%menuitemcount%
  {
    nPos:=A_Index-1
    VarSetCapacity(lpString,100,0) ; line inserted on 2008-02-18 -- Hope you dont mind Skrommel! - Moderator!
    length:=DllCall("user32\GetMenuString","UInt",hMenu,"UINT",nPos,"STR",lpString,"int",nMaxCount,"UINT",uFlag)
    wholemenu=%wholemenu%%nPos%%A_Tab%%space%%lpString%`n
    hSubMenu:=DllCall("user32\GetSubMenu","UInt",hMenu,"int",nPos)
    If hSubMenu>-1
    {
      Loop,3
        space=%space%%A_Space%
      GETMENU(hSubMenu)
      StringTrimRight,space,space,3
    }
  }
  Return
}

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • View Profile
    • Donate to Member
Re: IDEA: program menu printing
« Reply #4 on: April 08, 2009, 09:04 PM »
Brilliant!  :up: :up:

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,913
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: program menu printing
« Reply #5 on: April 08, 2009, 10:45 PM »
Don't encourage him chris -- he's making the rest of us coders look bad!

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: program menu printing
« Reply #6 on: April 09, 2009, 09:23 PM »
Try GetMenus!

Press F1 to extract the menus of the active window to a text file.

great script! i didn't know this was even possible. :up:

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: program menu printing
« Reply #7 on: April 10, 2009, 04:21 AM »
 :-[ You guys...

Skrommel

ares09x

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 5
    • View Profile
    • Donate to Member
Re: IDEA: program menu printing
« Reply #8 on: June 09, 2009, 11:32 AM »
Thanks, Skrommel, that's great  :Thmbsup: - sorry I didn't get back sooner, I've been busy with some University teaching recently :(.

Since I'm a complete noob about this, what do I send the .ahk file to???  I bet there's an easy answer, and I would love to try this out ...

Best regards,
ares09x (aka Bob Y.)

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: program menu printing
« Reply #9 on: June 09, 2009, 08:16 PM »
@ares09x: you have to download & install AutoHotKey then copy the above code and save it as <whatevername>.ahk and execute this ahk file.

ares09x

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 5
    • View Profile
    • Donate to Member
Re: IDEA: program menu printing
« Reply #10 on: June 09, 2009, 08:17 PM »
Thanks, lanux128.