Sign in to follow this  
Followers 0
Marss

Sending {ENTER} with _GUICtrlListView_SetItem ?

6 posts in this topic

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

Share this post


Link to post
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}")

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Marss

Share this post


Link to post
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}")

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0