Temporäres DropDown Menü per HotKey ausserhalb der GUI

  • Moin Moin und Hallo Liebe Community,

    ich habe schon stunden mit Google zugebracht aber leider nichts finden können.
    Es geht darum mittels HotkeySet an der Stelle, an der, der Mousecurser steht ein DropDown menü zu öffnen.
    Die Herrausvorderung ist, das die Stelle nicht innerhalb einer AutoIT GUI ist sondern Hauptsächlich im Internet Explorer.

    Später sollten dann das DropDown Menü einige Textfelder auslesen, bestimmte Schlüsselwörter daraus als Auswahl geben und nach der Auswahl eine Function ausführen.
    Aber das stellt nicht das Problem dar.


    Ich freue mich auf einige Ideen und verbleibe mit Besten Grüßen aus dem Rhein-Land,
    Bronko

    2 Mal editiert, zuletzt von dabronko1 (17. Mai 2014 um 23:52)

  • Schonmal in die Hilfe geschaut?

    [autoit]

    guictrlcreatecontextmenu

    [/autoit]

    Dort findest du ein fast fertiges Beispiel für das was du erreichen willst.
    Hier das überarbeitete Example2:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <ButtonConstants.au3>

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

    HotKeySet("+!d", "hotkeymenu") ;Shift-Alt-d

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

    ; *****************
    ; * Second sample *
    ; *****************

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

    Global $hGui, $OptionsBtn, $OptionsDummy, $OptionsContext, $OptionsCommon, $OptionsFile, $msg, $HotkeyDummy, $HotkeyContext, $HotkeyTestItem
    Global $OptionsExit, $HelpBtn, $HelpDummy, $HelpContext, $HelpWWW, $HelpAbout
    $hGui = GUICreate("My GUI", 170, 40)

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

    $OptionsBtn = GUICtrlCreateButton("&Options", 10, 10, 70, 20, $BS_FLAT)

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

    ; At first create a dummy control for the options and a contextmenu for it
    $OptionsDummy = GUICtrlCreateDummy()
    $OptionsContext = GUICtrlCreateContextMenu($OptionsDummy)
    $OptionsCommon = GUICtrlCreateMenuItem("Common", $OptionsContext)
    $OptionsFile = GUICtrlCreateMenuItem("File", $OptionsContext)
    GUICtrlCreateMenuItem("", $OptionsContext)
    $OptionsExit = GUICtrlCreateMenuItem("Exit", $OptionsContext)

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

    $HelpBtn = GUICtrlCreateButton("&Help", 90, 10, 70, 20, $BS_FLAT)

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

    ; Create a dummy control and a contextmenu for the help too
    $HelpDummy = GUICtrlCreateDummy()
    $HelpContext = GUICtrlCreateContextMenu($HelpDummy)
    $HelpWWW = GUICtrlCreateMenuItem("Website", $HelpContext)
    GUICtrlCreateMenuItem("", $HelpContext)
    $HelpAbout = GUICtrlCreateMenuItem("About...", $HelpContext)

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

    $HotkeyDummy = GUICtrlCreateDummy()
    $HotkeyContext = GUICtrlCreateContextMenu($HotkeyDummy)
    $HotkeyTestItem = GUICtrlCreateMenuItem("Test", $HotkeyContext)

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

    GUISetState()

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

    While 1
    $msg = GUIGetMsg()

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

    Switch $msg
    Case $OptionsExit, $GUI_EVENT_CLOSE
    ExitLoop

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

    Case $OptionsBtn
    ShowMenu($hGui, $msg, $OptionsContext)

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

    Case $HelpBtn
    ShowMenu($hGui, $msg, $HelpContext)

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

    Case $HelpAbout
    MsgBox(64, "About...", "GUICtrlGetHandle-Sample")

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

    Case $HotkeyTestItem
    MsgBox(64, "HotkeyTest", "Test")
    EndSwitch
    WEnd
    GUIDelete()

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

    Func hotkeymenu()
    ShowMenu($hGui, -1, $HotkeyContext)
    EndFunc

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

    ; Show a menu in a given GUI window which belongs to a given GUI ctrl
    Func ShowMenu($hWnd, $CtrlID, $nContextID)
    Local $arPos, $x, $y
    Local $hMenu = GUICtrlGetHandle($nContextID)

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

    if $CtrlID = -1 Then
    $arPos = MouseGetPos()
    $x = $arPos[0]
    $y = $arPos[1]
    Else
    $arPos = ControlGetPos($hWnd, "", $CtrlID)
    $x = $arPos[0]
    $y = $arPos[1] + $arPos[3]
    ClientToScreen($hWnd, $x, $y)
    EndIf

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

    TrackPopupMenu($hWnd, $hMenu, $x, $y)
    EndFunc ;==>ShowMenu

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

    ; Convert the client (GUI) coordinates to screen (desktop) coordinates
    Func ClientToScreen($hWnd, ByRef $x, ByRef $y)
    Local $stPoint = DllStructCreate("int;int")

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

    DllStructSetData($stPoint, 1, $x)
    DllStructSetData($stPoint, 2, $y)

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

    DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint))

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

    $x = DllStructGetData($stPoint, 1)
    $y = DllStructGetData($stPoint, 2)
    ; release Struct not really needed as it is a local
    $stPoint = 0
    EndFunc ;==>ClientToScreen

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

    ; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd)
    Func TrackPopupMenu($hWnd, $hMenu, $x, $y)
    DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
    EndFunc ;==>TrackPopupMenu

    [/autoit]

    Du musst dir nun nur noch einfallen lassen wie du die GUI verschwinden lässt oder erst garnicht sichtbar erstellst. Das sollte aber wohl kein sonderliches Problem sein.

  • Hi nochmal,

    das funktioniert ansich sehr gut, nur zwei ergänzende Fragen habe ich noch.

    Ist es auch möglich dieses erzeugte Menü nun mit der tastur zu nutzen?
    Hintergrund ist, das der curser in einem Feld steht, ich den HotKey nutze und mit den Pfeil Tasten den belibiegen Wert wählen kann.
    Aktuell muss ich die Maus nehmen und einen Wert wählen.

    Vielen DanK!"