Menüleiste hat keine Controll ID

  • Hi, es ist zum Mäuse melken, ich versuch ein programm so zu steuern, dass es im hintergrund gesteuert werden kann.

    Deshalb versuch ich grad alle Befehle auf ControllClick und Controll Send umzuschalten.

    Mein Problem: Die Menüleiste (Da wo immer Datei, Bearbeiten, Ansicht,... steht) lifert mir keine ControllID oder ähnliches
    Hier ein Screenshot vom Fenster:
    [Blockierte Grafik: http://home.arcor.de/wichtel2000/pathaway.JPG
    und die dazugehörige auszug von Windowinfo mit der Maus auf Controll File:

    Wie kann ich das Menü so ansprechen, dass ich das Fenster im minimierten Zustand steuern kann.

    Danke für eure Hilfe

  • Es geht mit WinMenuSelectItem, aber da muss der Text angegeben werden. (also schlecht, wenn die Items übersetzt werden.)
    Hab die Funktion daher nochmal neu aus dem AHK-code geschrieben, da gehen jetzt Text, Index (0-basiert) und direkt über die ItemID
    In Scite z.B. Export as HTML: ID 111

    Spoiler anzeigen
    [autoit]

    #include <GUImenu.au3>
    Opt("WinTitleMatchMode",2)

    [/autoit] [autoit][/autoit] [autoit]

    _WinMenuSelectItem(" SciTE ","","&Datei","&Neu Ctrl+N") ; Datei NEU

    [/autoit] [autoit][/autoit] [autoit]

    _WinMenuSelectItem(" SciTE ","",0,0) ; Datei NEU

    [/autoit] [autoit][/autoit] [autoit]

    _WinMenuSelectItem(" SciTE ","","&Datei",0) ; Datei NEU

    [/autoit] [autoit][/autoit] [autoit]

    _WinMenuSelectItem(" SciTE ","","ID#101",0) ; Datei NEU

    [/autoit] [autoit][/autoit] [autoit]

    ;~ _WinMenuSelectItem(" SciTE ","","ID#111") ; Export as HTML

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _WinMenuSelectItem
    ; Description:: selects a menu command
    ; Parameter(s): $aTitle - Title or handle of Window (like WinExists)
    ; $aText - Text of window
    ; $aMenu1 - Index, ID or text of MenuItem
    ; $aMenu2...$aMenu7 - Index, text of MenuItem
    ; Remarks: Index must be given as Number / Integer
    ; ID as string prefixed with ID#
    ; text can be with ot without &
    ; Requirement(s): GUIMenu.au3, WinAPI.au3
    ; Return Value(s): Sucess 1, error 0
    ; Author(s): Prog@ndy (converted from AHK source)
    ;
    ;===============================================================================
    ;
    Func _WinMenuSelectItem($aTitle, $aText, $aMenu1, $aMenu2="", $aMenu3="", $aMenu4="", $aMenu5="", $aMenu6="", $aMenu7="")
    ;~ // Set up a temporary array make it easier to traverse nested menus & submenus
    ;~ // in a loop. Also add a NULL at the end to simplify the loop a little:
    ;~ char *menu_param[] = {aMenu1, aMenu2, aMenu3, aMenu4, aMenu5, aMenu6, aMenu7, NULL};

    [/autoit] [autoit][/autoit] [autoit]

    Local $target_window = WinGetHandle($aTitle, $aText);
    If @error Then Return SetError(1,0,0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hMenu = _GUICtrlMenu_GetMenu($target_window);
    if (Not $hMenu) Then Return SetError(2,0,0)

    Local $menu_item_count = _GUICtrlMenu_GetItemCount($hMenu);
    if ($menu_item_count < 1) Then Return SetError(3,0,0)

    Local Const $MENU_ITEM_IS_SUBMENU = "SUBMENU"
    Local $menu_id = StringRegExp($aMenu1,"\AID#(\d+)\Z",3)
    If Not @error Then
    Local $INFO = _GUICtrlMenu_GetItemInfo($hMenu,$menu_id[0],False)
    If Not IsDllStruct($INFO) Or DllStructGetData($INFO,"SubMenu") Then Return SetError(8,0,0)
    _WinAPI_PostMessage($target_window, 273, $menu_id[0], 0); ;$WM_COMMAND
    Return SetError(0,0,1)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $menu_id = $MENU_ITEM_IS_SUBMENU;
    Local $menu_text;
    Local $match_found;
    Local $this_menu_param_length, $menu_text_length;
    Local $pos, $target_menu_pos;
    Local $this_menu_param;

    [/autoit] [autoit][/autoit] [autoit]

    for $i=1 To (@NumParams-2)
    $this_menu_param = Eval("aMenu"&$i); // For performance and convenience.

    [/autoit] [autoit][/autoit] [autoit]

    if ($hMenu=0) Then _ ; // The nesting of submenus ended prior to the end of the list of menu search terms.
    Return SetError(4,0,0); // Let ErrorLevel tell the story.

    [/autoit] [autoit][/autoit] [autoit]

    $this_menu_param_length = StringLen($this_menu_param);
    $target_menu_pos = IsInt($this_menu_param)
    if ($target_menu_pos) Then
    if ($this_menu_param >= $menu_item_count) Then _ ;// Invalid menu position (doesn't exist).
    Return SetError(5,0,0);; // Let ErrorLevel tell the story.
    UPDATE_MENU_VARS($this_menu_param,$hMenu,$menu_id,$menu_item_count)
    else ;// Searching by text rather than numerical position.
    Local $match_found = false

    for $pos = 0 To $menu_item_count-1
    $menu_text = _GUICtrlMenu_GetItemText($hMenu, $pos);, menu_text, sizeof(menu_text) - 1, MF_BYPOSITION);
    ;~ // v1.0.43.03: It's debatable, but it seems best to support locale's case insensitivity for
    ;~ // menu items, since menu names tend to adapt to the user's locale. By contrast, things
    ;~ // like process names (in the Process command) do not tend to change, so it seems best to
    ;~ // have them continue to use stricmp(): 1) avoids breaking exisitng scripts; 2) provides
    ;~ // consistent behavior across multiple locales; 3) performance.
    ;~ $match_found = !lstrcmpni(menu_text // This call is basically a strnicmp() that obeys locale.
    ;~ , menu_text_length > this_menu_param_length ? this_menu_param_length : menu_text_length
    ;~ , this_menu_param, this_menu_param_length);
    $match_found = ($menu_text=$this_menu_param)
    ;//match_found = strcasestr(menu_text, this_menu_param);
    if (Not $match_found) Then
    ;~ // Try again to find a match, this time without the ampersands used to indicate
    ;~ // a menu item's shortcut key:
    $menu_text = StringReplace($menu_text, "&", "",0,1);
    ;~ menu_text_length = strlen(menu_text);
    ;~ match_found = !lstrcmpni(menu_text // This call is basically a strnicmp() that obeys locale.
    ;~ , menu_text_length > this_menu_param_length ? this_menu_param_length : menu_text_length
    ;~ , this_menu_param, this_menu_param_length);
    ;~ //match_found = strcasestr(menu_text, this_menu_param);
    $match_found = ($menu_text=$this_menu_param)
    EndIf
    If $match_found Then
    UPDATE_MENU_VARS($pos,$hMenu,$menu_id,$menu_item_count)
    ExitLoop
    ;~ break;
    EndIf
    Next ;} // inner for()
    if (Not $match_found) Then _ ; // The search hierarchy (nested menus) specified in the params could not be found.
    Return SetError(6,0,0)
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ;~ // This would happen if the outer loop above had zero iterations due to aMenu1 being NULL or blank,
    ;~ // or if the caller specified a submenu as the target (which doesn't seem valid since an app would
    ;~ // next expect to ever receive a message for a submenu?):
    if ($menu_id == $MENU_ITEM_IS_SUBMENU) Then _
    Return SetError(7,0,0)

    [/autoit] [autoit][/autoit] [autoit]

    ;~ // Since the above didn't return, the specified search hierarchy was completely found.
    _WinAPI_PostMessage($target_window, 273, $menu_id, 0); $WM_COMMAND
    Return SetError(0,0,1)
    ;~ return g_ErrorLevel->Assign(ERRORLEVEL_NONE); // Indicate success.
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func UPDATE_MENU_VARS($menu_pos,ByRef $hMenu, ByRef $menu_id, ByRef $menu_item_count,$ISID=False)
    Local Const $MENU_ITEM_IS_SUBMENU = "SUBMENU"
    $menu_id = _GUICtrlMenu_GetItemID($hMenu, $menu_pos);
    $hMenu = _GUICtrlMenu_GetItemSubMenu($hMenu, $menu_pos)
    if ($hMenu) Then
    $menu_id = $MENU_ITEM_IS_SUBMENU
    $menu_item_count = _GUICtrlMenu_GetItemCount($hMenu);
    else
    $menu_item_count = 0
    $hMenu = 0
    EndIf
    EndFunc

    [/autoit]