Luke94 Posted June 30, 2021 Posted June 30, 2021 If this doesn't work - I don't have a clue.. expandcollapse popup#include <GuiListView.au3> Global $g_hWnd Global $g_hListView Global $g_iCount Global $g_iIndex $g_hWnd = WinGetHandle('AmiBroker') ; Get AmiBroker window handle If IsHWnd($g_hWnd) = 1 Then ; Check the window handle is valid If WinActive($g_hWnd) = 0 Then ; Check if AmiBroker is NOT active WinActivate($g_hWnd) ; If it's NOT active, activate it WinWaitActive($g_hWnd, '', 5) ; Wait for the handle to become active EndIf While 1 ; Loop forever If IsHWnd($g_hWnd) = 1 Then $g_hListView = ControlGetHandle($g_hWnd, '', '[CLASS:SysListView32; ID:903]') ; Get the ListView handle $g_iCount = (_GUICtrlListView_GetItemCount($g_hListView) - 1) ; Get the number of items in the ListView $g_iIndex = 0 ControlFocus($g_hWnd, '', '[CLASS:SysListView32; ID:903]') Do If $g_iIndex > 0 Then _GUICtrlListView_SetItemFocused($g_hListView, ($g_iIndex - 1), False) _GUICtrlListView_SetItemSelected($g_hListView, ($g_iIndex - 1), False) EndIf _GUICtrlListView_SetItemFocused($g_hListView, $g_iIndex, True) _GUICtrlListView_SetItemSelected($g_hListView, $g_iIndex, True) _GUICtrlListView_EnsureVisible($g_hListView, $g_iIndex) $g_iIndex += 1 Sleep(2000) ;~ Sleep(100) Until $g_iIndex > $g_iCount _GUICtrlListView_SetItemFocused($g_hListView, $g_iIndex, False) _GUICtrlListView_SetItemSelected($g_hListView, $g_iIndex, False) _GUICtrlListView_EnsureVisible($g_hListView, 0) Sleep(15000) Else $g_hWnd = WinGetHandle('AmiBroker') Sleep(1000) ; Wait 1000ms EndIf WEnd EndIf I've tested it on the following GUI: #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 218, 218, 192, 124) $ListView1 = GUICtrlCreateListView("Column 1|Column 2", 8, 8, 201, 201) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 98) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 99) For $i = 0 To 99 Step 1 _GUICtrlListView_AddItem($ListView1, 'Item ' & ($i + 1)) _GUICtrlListView_AddSubItem($ListView1, $i, 'SubItem ' & ($i + 1), 1) Next GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd It appears to work as expected. Even when the GUI isn't active.
LearningEW Posted June 30, 2021 Author Posted June 30, 2021 This is moving perfectly from 1st stock to last then again to 1st stock but its just highlighting the names and not select and scrolling as it does in previous codes. As in previous codes when it selects next stock name the chart also changes. Thanks a lot Luke for all the kind help.
Solution Luke94 Posted June 30, 2021 Solution Posted June 30, 2021 (edited) I couldn't leave this! 😛 Think I've solved it! #include <GuiListView.au3> Global $g_hWnd Global $g_hListView Global $g_iCount Global $g_iIndex Global $g_aItemRect $g_hWnd = WinGetHandle('AmiBroker') If IsHWnd($g_hWnd) = 1 Then If WinActive($g_hWnd) = 0 Then WinActivate($g_hWnd) WinWaitActive($g_hWnd, '', 10) EndIf While 1 If IsHWnd($g_hWnd) = 1 Then $g_hListView = ControlGetHandle($g_hWnd, '', '[CLASS:SysListView32; ID:903]') $g_iCount = (_GUICtrlListView_GetItemCount($g_hListView) - 1) $g_iIndex = 0 Do _GUICtrlListView_EnsureVisible($g_hListView, $g_iIndex) $g_aItemRect = _GUICtrlListView_GetItemRect($g_hListView, $g_iIndex, 2) ControlClick($g_hWnd, '', '[CLASS:SysListView32; ID:903]', 'Left', 2, $g_aItemRect[0], $g_aItemRect[1]) $g_iIndex += 1 Sleep(2000) Until $g_iIndex > $g_iCount _GUICtrlListView_EnsureVisible($g_hListView, 0) Sleep(15000) Else $g_hWnd = WinGetHandle('AmiBroker') Sleep(1000) EndIf WEnd EndIf This actually simulates a mouse click on the ListView so it should make the stock charts appear/change. Also tested on the ListView GUI I posted earlier and it works as intended. FINGERS CROSSED! Edited June 30, 2021 by Luke94
LearningEW Posted July 1, 2021 Author Posted July 1, 2021 😆 Thanks a lot. This seems to be working 🤞.Thanks for putting so much time in helping. 👍
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now