timdecker Posted April 2, 2015 Share Posted April 2, 2015 I am not sure about the best way to go about it, whether by controlID or whatever; but, for testing purposes, when I select a checkbox, I should be able write to the console the entire column/array that I selected.....but I am unable to do so and have tried several iterations of it. By doing so, this should let me (in the future) run through each array, row by row. But for now, I would like to be able to correlate the checkbox with the array/column I selected. Code: expandcollapse popup#cs Solution to that is to move the window to the same screen location every time the program is run or the loop recycles. Or test to see if it's on the X/Y you want and if not, force it there. #ce #include <file.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> Global $a_csv $s_Path = FileOpenDialog("Select CVS File", @ScriptDir, "comma seperated values (*.csv)") If @error Then MsgBox(4096, "", "No File(s) chosen") Exit Else _FileReadToArray($s_Path, $a_csv) GUICreate("CSV Listview", 900, 450, -1, -1) $listview = GUICtrlCreateListView(StringReplace($a_csv[1], ",", "|"), 10, 10, 600, 210) $checkboxName = StringSplit($a_csv[1], ",") $iCount = $checkboxName[0] ;consolewrite($iCount) ;creating buttons Global $aCheck[$iCount + 1] Global $mapColumn[$iCount + 1] $nextSample = GUICtrlCreateButton("Map sample submition button ", 395, 320, 180, 30) $runProg = GUICtrlCreateButton("Run Program", 700, 400, 180, 30) For $j = 1 To $iCount ; Store controIDs of the checkboxes $aCheck[$j] = GUICtrlCreateCheckbox($checkboxName[$j], 10, 190 + (50 * $j), 100, 30) $mapColumn[$j] = GUICtrlCreateButton("Map " & '"' & $checkboxName[$j] & '"' & " to input box", 150, 190 + (50 * $j), 180, 30) GUICtrlSetState($aCheck[$j], $GUI_UNCHECKED) GUICtrlSetState($mapColumn[$j], $GUI_DISABLE) ;ConsoleWrite($aCheck[1]) Next For $i = 2 To UBound($a_csv) - 1 $s_temp = StringReplace($a_csv[$i], ",", "|") GUICtrlCreateListViewItem($s_temp, $listview) Next ;~ #cs -- Below Global $aOut[''][''] for $i = 2 to $a_csv[0] $aLine = stringsplit($a_csv[$i] , ",",3) If ubound($aLine) > ubound($aOut , 2) Then redim $aOut[$i][ubound($aLine)] _ArrayAdd($aOut , $a_csv[$i] , 0 , ",") ;consolewrite("line: " & $aLine[2] & @LF) next ;~ #ce -- See above EndIf GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case Else For $i = 1 To $iCount If $msg = $aCheck[$i] Then If GUICtrlRead($msg) = 1 Then GUICtrlSetState($mapColumn[$i], $GUI_ENABLE) Else GUICtrlSetState($mapColumn[$i], $GUI_DISABLE) EndIf ExitLoop EndIf Next EndSwitch WEnd Exit CSV: expandcollapse popupmaterial_name,material_alias,period,letter HT-000001331,,r1,A1 HT-000001330,alias 3 not 4,r2,A2 dummy,,,A3 RS-000001336,,r4,A4 HT-000001335,,r2,A5 dummy,,,A6 HT-000001334,,r2,A7 HT-000001328,alias1,r1,A8 HT-000001333,,r2,B1 dummy,,,B2 dummy,,,B3 HT-000001332,,r1,B4 dummy,,,B5 HT-000001332,,r2,B6 HT-000001329,alias 2,r2,B7 dummy,,,B8 dummy,,,C1 dummy,,,C2 HT-000001329,alias 2,r1,C3 HT-000001334,,r1,C4 RS-000001336,,r1,C5 dummy,,,C6 HT-000001333,,r1,C7 dummy,,,C8 dummy,,,D1 dummy,,,D2 dummy,,,D3 dummy,,,D4 RS-000001336,,r2,D5 dummy,,,D6 HT-000001330,alias 3 not 4,r1,D7 HT-000001331,,r2,D8 dummy,,,E1 dummy,,,E2 HT-000001335,,r1,E3 RS-000001336,,r3,E4 dummy,,,E5 RS-000001336,,r5,E6 HT-000001328,alias1,r2,E7 dummy,,,E8 Thanks guys! Tim Link to comment Share on other sites More sharing options...
mikell Posted April 2, 2015 Share Posted April 2, 2015 ? While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case Else For $i = 1 To $iCount If $msg = $aCheck[$i] Then If GUICtrlRead($msg) = 1 Then GUICtrlSetState($mapColumn[$i], $GUI_ENABLE) Local $text = "" For $k = 0 to $a_csv[0]-1 $text &= ControlListView ("CSV Listview", "", $listview, "GetText", $k, $i-1) & @crlf Next Msgbox(0,"", $text) Else GUICtrlSetState($mapColumn[$i], $GUI_DISABLE) EndIf ExitLoop EndIf Next EndSwitch WEnd Link to comment Share on other sites More sharing options...
timdecker Posted April 2, 2015 Author Share Posted April 2, 2015 ? While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case Else For $i = 1 To $iCount If $msg = $aCheck[$i] Then If GUICtrlRead($msg) = 1 Then GUICtrlSetState($mapColumn[$i], $GUI_ENABLE) Local $text = "" For $k = 0 to $a_csv[0]-1 $text &= ControlListView ("CSV Listview", "", $listview, "GetText", $k, $i-1) & @crlf Next Msgbox(0,"", $text) Else GUICtrlSetState($mapColumn[$i], $GUI_DISABLE) EndIf ExitLoop EndIf Next EndSwitch WEnd Yeah, that is exactly what I needed! That should help me debug it. Also, within the While loop at the 2nd if statement, where we determine $GUI_Enable, how would I allow a user to map those buttons to a XY screen position and store it for the end of the run program? Thanks mikell!!! Link to comment Share on other sites More sharing options...
mikell Posted April 2, 2015 Share Posted April 2, 2015 Not sure I understand the question, but you could use WinGetPos & ControlGetPos, though playing with screen coordinates is not a really reliable way Link to comment Share on other sites More sharing options...
timdecker Posted April 2, 2015 Author Share Posted April 2, 2015 Not sure I understand the question, but you could use WinGetPos & ControlGetPos, though playing with screen coordinates is not a really reliable way I see the end user moving the screen with the input boxes around from time to time; thereby, changing the location of the input boxes. So what I am looking for, is if the click the "Map 'X' to input box" button, they should then be able to goto the input box of the other program, click it, and that XY position will be stored. Link to comment Share on other sites More sharing options...
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