ASuite Normal Beenden nicht abschießen

  • Hi, ich benutze die ASuite von http://www.salvadorsoftware.com. Da mir das Abmelden des Usb-Sticks nicht gefiel habe im Internet gesucht und folgendes Script gefunden.

    Code
    #cs Utility AutoIt3 Script
    #
    # EJECTUSB.AU3
    #
    # AI3 Script - EjectUSB - version 1.6

    Ich war überrascht, das es ein VB ähnliches Programm zum Programieren schon seit längeren gab.
    Da ich mich ein wenig mit VBA auskenne gings gleich los.
    Ich habe einige Versuch unternommen um ASuite zu beenden leider ohne Erfolg, deshalb bitte ich Euch mir zu helfen!
    Meine Versuch an die Sache rannzugehen.

    für Eure Hilfe bin ich sehr Dankbar
    Mfg gabischatz

    Einmal editiert, zuletzt von gabischatz (31. August 2009 um 13:26)

  • Ich verstehe nicht so ganz was du möchtest..
    Du willst einfach nur ASuite beenden?
    Oder soll da noch irgendetwas geprüft werden, und DANN beenden?

    Deine Frage war etwas unklar!

  • ja ich möchte die ASuite beenden ohne beim nächsten start diese Fehlermeldung zubekommen.

    Warning
    ASuite wurde nicht korrekt beendet. Letzte Sitzung wiederherstellen?
    Yes/No

    es soll nichts weiter geprüft werden!

  • Bitteschön:

    [autoit]

    #include<WinApi.au3>
    #include<WindowsConstants.au3>
    $mnu = WinGetHandle("[CLASS:TfrmMain;TITLE:ASuite]") ; Au3Info
    _SendMessage($mnu, $WM_COMMAND, 10) ; Command für menuitem: Exit
    ; laut WinSpector bei ASuite 1.5.2Beta

    [/autoit]
  • Denke schon. Du muss nur die command-ID vom Beenen-Menueintrag haben.
    Dazu kannst du z.B. WinSpector verwenden und hunderte von Windowsmessages durchsugen oder z.B. "mein" _WinMenuSelectItem verwenden. Damit kann man den Eintrag auch nach anderen Kriterien auswählen. Bei erfolg ist dan in @extended die CommandID:

    Spoiler anzeigen
    [autoit]

    #include <GUImenu.au3>
    ;===============================================================================
    ;
    ; 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 (0-based)
    ; ID as string prefixed with ID#
    ; text can be with or without &
    ; text comparison is NOT casesensitive
    ; 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 Or $target_window == "" 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)

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

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

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

    Local Const $MENU_ITEM_IS_SUBMENU = "SUBMENU"
    Local $menu_id = StringRegExp($aMenu1,"\AID#(\d+)\Z",3) ; support to call an Item by ID
    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][/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<0) Or ($this_menu_param >= $menu_item_count) Then _ ;// Invalid menu position (doesn't exist).
    Return SetError(5,0,0);; // Let ErrorLevel tell the story.
    __WMSI_UPDATE_MENU_VARS($this_menu_param,$hMenu,$menu_id,$menu_item_count)
    else ;// Searching by text rather than numerical position.
    Local $match_found = false

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

    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
    __WMSI_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,$menu_id,1)
    ;~ return g_ErrorLevel->Assign(ERRORLEVEL_NONE); // Indicate success.
    EndFunc

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

    Func __WMSI_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]


    Es gibt aber eine Einschränkung: Dafür muss das Fenster existieren, es reicht auch versteckt (@SW_HIDE). Da weiß ich jezt nicht wie OutlookExpress das macht.