Jump to content

Navigating Menu issues


Yata
 Share

Recommended Posts

Well, I wanted and am writing codes to automate some tutorials for the program Paint.NET. The program has an effect menu which can be navigated by means of MouseClick() or Send("{DOWN 3}") etc.

The problem is this:

There are many effect plugins for Paint.NET and every user's menu is different. The plugins are kept in .dll format in c:\program files\paint.net\effects.

Now, seeing as how both the MouseClick() and Send() functions can have varying results depending on how many effects a user has installed, then it makes it extremely hard for me to make the code work properly. At this time, I'm forced to tell users to remove the plugins before they run the automation, and this is just a turn off seeing as how you have to do it yourself.

Here is a screenshot of the menu.

[link]

Is there an easier way to accomplish the activation of the right effect by other means? I would greatly appreciate any feedback regarding this.

Thank you.

Edited by Yata
Link to comment
Share on other sites

Well, I wanted and am writing codes to automate some tutorials for the program Paint.NET. The program has an effect menu which can be navigated by means of MouseClick() or Send("{DOWN 3}") etc.

The problem is this:

There are many effect plugins for Paint.NET and every user's menu is different. The plugins are kept in .dll format in c:\program files\paint.net\effects.

Now, seeing as how both the MouseClick() and Send() functions can have varying results depending on how many effects a user has installed, then it makes it extremely hard for me to make the code work properly. At this time, I'm forced to tell users to remove the plugins before they run the automation, and this is just a turn off seeing as how you have to do it yourself.

Here is a screenshot of the menu.

[link]

Is there an easier way to accomplish the activation of the right effect by other means? I would greatly appreciate any feedback regarding this.

Thank you.

Have you looked at A3LMenu.au3 and the example Menu2.au3 in Auto3Lib?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Thats actually very interesting looking at Menu2.au3. I coulden't find a A3LMenu.au3 though.

Could someone explain how I would use the code in Menu2.au3 to simulate the new menu, and be able to run the effects off of it?

Just for quick reference, the Menu2 code

#include <A3LMenu.au3>
#include <A3LString.au3>

Opt("MustDeclareVars", 1)

; ====================================================================================================

===========================
; Description ...: Have some fun with the Notepad menus
; Author ........: Paul Campbell (PaulIA)
; Notes .........:
; ====================================================================================================

===========================

; ====================================================================================================

===========================
; Global variables
; ====================================================================================================

===========================

Global $hWnd, $hMain, $hMenus[7]

; ====================================================================================================

===========================
; Main
; ====================================================================================================

===========================
Run("Notepad.exe")
_Lib_WinWaitActive("Untitled - Notepad")
$hWnd  = WinGetHandle("Untitled - Notepad")
if @Error then _Lib_ShowError("Unable to get Notepad window handle")
$hMain = _Menu_GetMenu($hWnd)
if $hMain = 0 then _Lib_ShowError("Unable to get Notepad menu handle")

AddNewMenu()
GetMenus()
ShowMenu($hMain, 0)

; ====================================================================================================

===========================
; Add a new menu to Notepad
; ====================================================================================================

===========================
Func AddNewMenu()
  Local $hTool, $hItem1

  $hItem1 = _Menu_CreateMenu()
  _Menu_InsertMenuItem($hItem1, 0, "SubItem &1", 0x1000)
  _Menu_InsertMenuItem($hItem1, 1, "SubItem &2", 0x1001)

  $hTool = _Menu_CreateMenu()
  _Menu_InsertMenuItem($hTool , 0, "Item &1"   , 0x2000, $hItem1)
  _Menu_InsertMenuItem($hTool , 1, "Item &2"   , 0x2001)
  _Menu_InsertMenuItem($hTool , 2, ""         ,   0)
  _Menu_InsertMenuItem($hTool , 3, "Item &3"   , 0x2002)
  _Menu_InsertMenuItem($hTool , 4, "Item &4"   , 0x2003)

  _Menu_InsertMenuItem($hMain , 6, "&Auto3Lib" ,      0, $hTool)
  _Menu_DrawMenuBar($hWnd)
EndFunc

; ====================================================================================================

===========================
; Load the top level menu handles
; ====================================================================================================

===========================
Func GetMenus()
  Local $iI

  for $iI = 0 to 6
    $hMenus[$iI] = _Menu_GetItemSubMenu($hMain, $iI)
  next
EndFunc

; ====================================================================================================

===========================
; Recursively show the names of the menu items
; ====================================================================================================

===========================
Func ShowMenu($hMenu, $iIndent)
  Local $iI, $sText, $hSubMenu

  for $iI = 0 to _Menu_GetItemCount($hMenu) - 1
    $sText = _Menu_GetItemText($hMenu, $iI)
    if $sText <> "" then
      _Lib_ConsoleWrite(_Str_Repeat(" ", $iIndent) & $sText)
      $hSubMenu = _Menu_GetItemSubMenu($hMenu, $iI)
      if $hSubMenu <> 0 then ShowMenu($hSubMenu, $iIndent + 2)
    endif
  next
EndFunc

Also, I think I may have posted in the wrong section. My intentions were to post in General, but I guess I clicked the wrong link.

My apologies.

Link to comment
Share on other sites

Thats actually very interesting looking at Menu2.au3. I coulden't find a A3LMenu.au3 though.

Could someone explain how I would use the code in Menu2.au3 to simulate the new menu, and be able to run the effects off of it?

I was imagining that you would be able to find out what the menus were using this. Then you could work out how to navigate them.

Eg

#include <A3LMenu.au3>
#include <A3LString.au3>

Opt("MustDeclareVars", 1)

; ===============================================================================================================================
;taken from Paulia's Menu2.au3
; ===============================================================================================================================

; ===============================================================================================================================
; Global variables
; ===============================================================================================================================

Global $hWnd, $hMain, $hMenus[7]
Global $t
; ===============================================================================================================================
; Main
; ===============================================================================================================================
;Assuming the paint program is running
$t = "Whatever the title of your Paint.net program is"
if not Winexists($t) then exit
WinActivate($t)
_Lib_WinWaitActive($t)
$hWnd  = WinGetHandle($t)
if @Error then _Lib_ShowError("Unable to get Paint window handle")
$hMain = _Menu_GetMenu($hWnd)
if $hMain = 0 then _Lib_ShowError("Unable to get Paint menu handle")

GetMenus()
ShowMenu($hMain, 0)
 ===============================================================================================================================
; Load the top level menu handles
; ===============================================================================================================================
Func GetMenus()
  Local $iI

  for $iI = 0 to 6
    $hMenus[$iI] = _Menu_GetItemSubMenu($hMain, $iI)
  next
EndFunc

; ===============================================================================================================================
; Recursively show the names of the menu items
; ===============================================================================================================================
Func ShowMenu($hMenu, $iIndent)
  Local $iI, $sText, $hSubMenu

  for $iI = 0 to _Menu_GetItemCount($hMenu) - 1
    $sText = _Menu_GetItemText($hMenu, $iI)
    if $sText <> "" then
      _Lib_ConsoleWrite(_Str_Repeat(" ", $iIndent) & $sText)
      $hSubMenu = _Menu_GetItemSubMenu($hMenu, $iI)
      if $hSubMenu <> 0 then ShowMenu($hSubMenu, $iIndent + 2)
    endif
  next
EndFunc

Not all applications will work with this. I tried it with Scite and it's ok, but with Firefox it fails.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

When I run the script you posted, it comes up with an error "Unable to get handle.".

If it actually says "unable to get menu handle" then the method doesn't work for your PAINT program. My apologies for wasting your time. I don't have any other suggestions at the moment.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...