openDataTable( inTradingSymbol, retryCount ){
global NowWindowTitle, DTWindowTitle, TradingSymbolColIndex
WinClose, %DTWindowTitle% // Close DT If already Opened
Loop, 5{ // Sometimes {HOME} does not work when NOW is active - try 5 times
ControlGet, RowCount, List, Count, SysListView323, %NowWindowTitle% // No of rows in MarketWatch
ControlSend, SysListView323, {Home 2}, %NowWindowTitle% // Start from top and search for scrip
Loop, %RowCount%{ // Select row with our scrip
ControlGet, RowSymbol, List, Selected Col%TradingSymbolColIndex%, SysListView323, %NowWindowTitle%
// Take Trading Symbol from column Number in %TradingSymbolColIndex%
if( RowSymbol = inTradingSymbol ){ // and compare it with input
break
}
ControlSend, SysListView323, {Down}, %NowWindowTitle% // Move Down to next row if not found yet
}
if( RowSymbol = inTradingSymbol )
break
}
if ( RowSymbol != inTradingSymbol ) {
MsgBox, %inTradingSymbol% Not Found.
Exit
}
ControlSend, SysListView323, {Shift Down}d{Shift Up}, %NowWindowTitle% // At this point row should be selected. Open Data Table with shift-d
// Note - This also selects scrip starting with d in MW. Check
if( !waitforDTOpen( inTradingSymbol, retryCount, 1, 30 ) ) { // Wait for DataTable to open and load
openDataTable( inTradingSymbol, retryCount+1 ) // Wait upto 30 seconds, try only once
}
isDataLoaded := waitForDTData( inTradingSymbol )
WinMinimize, %DTWindowTitle%
return isDataLoaded
}