name22

Navigate ListView with GUI Buttons

Mar 4th, 2014
161
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <GUIConstants.au3>
  2. #include <SendMessage.au3>
  3.  
  4. $hWnd = GUICreate("LIstView Button Navigation", 300, 410)
  5. $cList = GUICtrlCreateListView("Test A|TestB", 5, 5, 290, 340)
  6. $cButton_Up = GUICtrlCreateButton("Up", 5, 350, 80, 25)
  7. $cButton_Down = GUICtrlCreateButton("Down", 5, 380, 80, 25)
  8. GUISetState()
  9.  
  10. $hWnd_ListView = GUICtrlGetHandle($cList)
  11.  
  12. For $i = 1 To 20
  13.     GUICtrlCreateListViewItem($i & "|" & Random(), $cList)
  14. Next
  15.  
  16. While True
  17.     Switch GUIGetMsg()
  18.         Case $GUI_EVENT_CLOSE
  19.             Exit
  20.         Case $cButton_Up
  21.             _SendMessage($hWnd_ListView, $WM_KEYDOWN, 0x26, 0)
  22.             Sleep(100)
  23.             _SendMessage($hWnd_ListView, $WM_KEYUP, 0x26, 0)
  24.         Case $cButton_Down
  25.             _SendMessage($hWnd_ListView, $WM_KEYDOWN, 0x28, 0)
  26.             Sleep(100)
  27.             _SendMessage($hWnd_ListView, $WM_KEYUP, 0x28, 0)
  28.     EndSwitch
  29. WEnd
RAW Paste Data