ListView + HotKey

  • Hey so würde es gehen:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <ListViewConstants.au3>
    #include <GuiListView.au3>
    #include <WinApi.au3>
    #include <Misc.au3>

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

    Opt('GuiOnEventMode', 1)

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

    Global $cShow = False
    GUICreate("listview items", 220, 170, -1, -1)
    GuiSetOnEvent($GUI_EVENT_CLOSE, "_Terminate")
    GUISetBkColor(0x00E0FFFF) ; will change background color

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

    $listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150)
    $item1 = GUICtrlCreateListViewItem("item1|1|2", $listview)
    $item2 = GUICtrlCreateListViewItem("Klick Mich!!|1|2", $listview)
    $item3 = GUICtrlCreateListViewItem("item3|1|2", $listview)
    $item4 = GUICtrlCreateListViewItem("item4|1|2", $listview)
    $item5 = GUICtrlCreateListViewItem("item5|1|2", $listview)
    GUISetState()
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

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

    While 1
    sleep(100)
    While $cShow
    sleep(10)
    If _isPressed("2E") Then MsgBox(0,"Info!", "ENF wurde gedrückt!")
    Wend
    Wend

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

    Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    Local $hWndFrom, $iCode
    If Not IsHWnd($listview) Then $hWndFrom = GUICtrlGetHandle($listview)
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
    Case $listview, $hWndFrom
    Switch $iCode
    Case $NM_CLICK
    If _GUICtrlListView_GetItemSelected($listview, 1) Then
    $cShow = True
    Else
    $cShow = False
    EndIf
    EndSwitch
    EndSwitch
    EndFunc

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

    Func _Terminate()
    Exit
    EndFunc

    [/autoit]
  • ich würde es mit hotkeyset machen, da bei _ispressed die cpu hoch geht ...

    Ich würd ungefähr so machen:

    Spoiler anzeigen
    [autoit]

    hotkeyset('{del}', '_del')

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

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <ListViewConstants.au3>
    #include <GuiListView.au3>
    #include <WinApi.au3>
    #include <Misc.au3>

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

    GUICreate("listview items", 220, 170, -1, -1)

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

    $listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150)
    $item1 = GUICtrlCreateListViewItem("item1|1|2", $listview)
    $item2 = GUICtrlCreateListViewItem("Klick Mich!!|1|2", $listview)
    $item3 = GUICtrlCreateListViewItem("item3|1|2", $listview)
    $item4 = GUICtrlCreateListViewItem("item4|1|2", $listview)
    $item5 = GUICtrlCreateListViewItem("item5|1|2", $listview)
    GUISetState()
    $msg=guigetmsg()

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

    while $msg<>$GUI_EVENT_CLOSE
    $msg=guigetmsg()
    sleep(100) ;==> DEBUG
    WEnd

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

    func _del()
    _GUICtrlListView_DeleteItemsSelected($listview)

    EndFunc

    [/autoit]
  • So ist es am besten ;) ohne _IsPressed und Hotkeyset. und ENTF wird nur erkannt, wenn es in der ListView gedrückt wird:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <ListViewConstants.au3>
    #include <GuiListView.au3>
    #include <WinApi.au3>
    #include <Misc.au3>

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

    Opt('GuiOnEventMode', 1)

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

    Global $ENTF_Pressed = False

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

    GUICreate("listview items", 220, 200, -1, -1)
    GuiSetOnEvent($GUI_EVENT_CLOSE, "_Terminate")
    GUISetBkColor(0x00E0FFFF) ; will change background color

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

    $listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150)
    $item1 = GUICtrlCreateListViewItem("item1|1|2", $listview)
    $item2 = GUICtrlCreateListViewItem("Klick Mich!!|1|2", $listview)
    $item3 = GUICtrlCreateListViewItem("item3|1|2", $listview)
    GUICtrlCreateInput("test", 10, 170,200,20)
    GUISetState()
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

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

    While 1
    sleep(100)
    If $ENTF_Pressed Then
    $ENTF_Pressed = False
    MsgBox(0, '', "ENTF gedrückt")
    EndIf
    Wend

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

    Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    Local $hWndFrom, $iCode, $hWndListView=-1
    If Not IsHWnd($listview) Then $hWndListView = GUICtrlGetHandle($listview)
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
    Case $listview, $hWndListView
    Switch $iCode
    Case $LVN_KEYDOWN
    Local $tagLVKEYDOWN = $tagNMHDR & "; USHORT wVKey; UINT flags;"
    $tNMHDR = DllStructCreate($tagLVKEYDOWN,$lParam)
    If DllStructGetData($tNMHDR,"wVKey") = 0x2E Then ; ENTF-Taste
    $ENTF_Pressed = True
    EndIf
    EndSwitch
    EndSwitch
    EndFunc

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

    Func _Terminate()
    Exit
    EndFunc

    [/autoit]