Jump to content

Sending {ENTER} with _GUICtrlListView_SetItem ?


 Share

Recommended Posts

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:

Screen_Vplus_Auto_IT.jpg

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:

#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

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

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 by Marss
Link to comment
Share on other sites

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}")
Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...