Marss Posted March 11, 2015 Share Posted March 11, 2015 Hello, My quetion stems from this thread: '?do=embed' frameborder='0' data-embedContent>> So, I have finally been able to get _GUICtrlListView_SetItem to work, setting values to cell I need it to. However, the application that Im setting the values to requires that after I set the values, I need to press ENTER or TAB. If I dont do that, it will automatically revert back to the old values after a few seconds. I can not use _GUICtrlListView_SetItem and put {ENTER}, as it will litelly send the string to the cell and not simulate pressing the enter key. I have tried using ASCII chars aswell, but no go. Furthermore, Ive tried _IsPressed() but that doesnt work because no keys actually get pressed with the SetItem method. Screenshot of my application that I need to set values in: I need to set the values in cells row 1, index 1 and index 2 and in row 2, index 1 and index 2 My code: expandcollapse popup#include <GuiListView.au3> #include <Misc.au3> ;--------------------------------------- ; Define Variables ;--------------------------------------- $windowTitle = "VTable 8.04 (COM3 [115200]) - [1: - 603 206 000 ; 12087363]" $windowControlID = "[CLASS:SysListView32; INSTANCE:6]" $hWin = WinGetHandle($windowTitle) $hControl = ControlGetHandle($hWin,"",$windowControlID) ;-------------------------------------- ; Start Script ;-------------------------------------- ;-------------------------------------- ; Index 1 ;-------------------------------------- ;Target Position value Index 1 in Vtable $iRowToEdit = 0 $iSubItemToEdit = 2 _GUICtrlListView_SetItem($hControl,"17777777",$iRowToEdit,$iSubItemToEdit) ;Target Speed value Index 1 in Vtable $iRowToEdit = 1 $iSubItemToEdit = 2 _GUICtrlListView_SetItem($hControl,"1638400",$iRowToEdit,$iSubItemToEdit) ;-------------------------------------- ; Index 2 ;-------------------------------------- ;Target position value Index 2 in Vtable $iRowToEdit = 0 $iSubItemToEdit = 3 _GUICtrlListView_SetItem($hControl,"100002",$iRowToEdit,$iSubItemToEdit) ;Target Speed value Index 2 in Vtable $iRowToEdit = 1 $iSubItemToEdit = 3 _GUICtrlListView_SetItem($hControl,"1638400",$iRowToEdit,$iSubItemToEdit) Really hope anyone can help, its the last piece of this puzzle that Ive been struggling with for days now Link to comment Share on other sites More sharing options...
orbs Posted March 11, 2015 Share Posted March 11, 2015 why don't i see anything like this in your code? ControlSend($hWin,"",$windowControlID,"{ENTER}") or even just this (when the application window is active): Send("{ENTER}") Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Marss Posted March 11, 2015 Author Share Posted March 11, 2015 (edited) I don't know if it's noticable in my screenshot but as you might see there's a black border around the field surrounding all the cells (the field that's been targeted by AutoIT window info). So if I do something like ; Activate Vtable WinActivate($windowTitle) ;Wait till active WinWaitActive($windowTitle) Send("{ENTER}") It will just send an ENTER to the field and not to a specific cell, thus not updating the cell's values. The same goes for ControlSend, I cannot get the handle for any specific cell, just the entire field. If anyone has any suggestions to get around that, please let me know Edited March 11, 2015 by Marss Link to comment Share on other sites More sharing options...
LarsJ Posted March 11, 2015 Share Posted March 11, 2015 You can try this based on the UI Automation framework:Identify the row in the LVFind all cells in this rowWalk through the cells one by one in a loop to identify the cellThe first cell is column 1, second cell is column 2, etc.ExitLoop when you reached the proper cellSet focus to this cellSend("{ENTER}") Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
orbs Posted March 12, 2015 Share Posted March 12, 2015 no doubt UI Automation Framework is the way to go, but perhaps this would work: _GUICtrlListView_SetItem($hControl,"100002"&Chr(13),$iRowToEdit,$iSubItemToEdit) Chr(13) commonly equivalent to Enter. also try instead Chr(9) for TAB. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Marss Posted March 16, 2015 Author Share Posted March 16, 2015 You can try this based on the UI Automation framework: Identify the row in the LV Find all cells in this row Walk through the cells one by one in a loop to identify the cell The first cell is column 1, second cell is column 2, etc. ExitLoop when you reached the proper cell Set focus to this cell Send("{ENTER}") Ive tried UI Automation. Unfortunately, it is way too slow :-( no doubt UI Automation Framework is the way to go, but perhaps this would work: _GUICtrlListView_SetItem($hControl,"100002"&Chr(13),$iRowToEdit,$iSubItemToEdit) Chr(13) commonly equivalent to Enter. also try instead Chr(9) for TAB. Tried that too, did not work. It would send value if I for instance used Chr(49) but it would not send TAB or ENTER with chr(13) and/or chr(9) I have reverted back to using controlclick and setting the mouse cursor in the first cell and then just using Send("{TAB"}) to get to the correct cell and use Send("$value"). Not perfect but it will have to do. 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