Marss Posted March 4, 2015 Share Posted March 4, 2015 Hello all, I am new to Autoit and so far really like it. I have made a simple script that is supposed to change the values in certain cells within an application. I played around a lot with delays but it still seems sluggish. The eventual goal of the script is to have an application writing values to the script and run it. The script will then input these values in certain cells in a table in an application. However, sometimes the script does not enter all numbers. For instance, if I want it to put the value "65567800" into a cell it will put "567800" or "65567", essentially skipping over these numbers. How can I make it does not happen? Can I only fix this by increasing the delays? Below is my code (comments are in dutch, if anyone would like I can translate them in english) expandcollapse popup$windowTitle = "VTable 8.04 (COM3 [115200]) - [1: - 603 206 000 ; 12087363]" $windowControlID = "[CLASS:SysListView32; INSTANCE:6]" $liDraaiafstand = 65536*5 $reDraaiafstand = -65536*5 $liSnelheid = 16384000 $reSnelheid = 16384000 $delayL = 25 $delayS = 25 ;-------------------------------------- ; Start Script ;-------------------------------------- ; Set delays Opt("SendKeyDelay", 30) Opt("SendKeyDownDelay", 30) ; Activeer Vtable WinActivate($windowTitle) ; Wacht tot het scherm actief is WinWaitActive($windowTitle) ;-------------------------------------- ; Index 1 (linksom) ;-------------------------------------- ; Klik binnen Vtable 1 maal met de linkermuisknop op de coordinaten(rij 1, kolom 2) ControlClick($windowTitle, "", $windowControlID, "left", 1, 150, 26) Sleep($delayS) ; Stuur de omdraaiwaarde (positief is linksom, negatief is rechtsom, 1 rondje heeft waarde 65536) en druk op enter om de waarde in te voeren Send($liDraaiafstand) ;Sleep($delayL) Send("{ENTER}") ;Sleep($delayS) ; Klik binnen Vtable 1 maal met de linkermuisknop op de coordinaten(rij 2, kolom 2) ControlClick($windowTitle, "", $windowControlID, "left", 1, 150, 43) Sleep($delayS) ; Stuur de snelheidswaarde en druk op enter om de waarde in te voeren Send($liSnelheid) ;Sleep($delayL) Send("{ENTER}") ;Sleep($delayS) ;-------------------------------------- ; Index 2 (rechtsom) ;-------------------------------------- ; Klik binnen Vtable 1 maal met de linkermuisknop op de coordinaten(rij 1, kolom 3) ControlClick($windowTitle, "", $windowControlID, "left", 1, 235, 26) Sleep($delayS) Send($reDraaiafstand) ;Sleep($delayL) Send("{ENTER}") ;Sleep($delayS) ; Klik binnen Vtable 1 maal met de linkermuisknop op de coordinaten(rij 2, kolom 3) ControlClick($windowTitle, "", $windowControlID, "left", 1, 235, 43) Sleep($delayS) ; Stuur de snelheidswaarde en druk op enter om de waarde in te voeren Send($reSnelheid) ;Sleep($delayL) Send("{ENTER}") ;Sleep($delayS) Link to comment Share on other sites More sharing options...
SadBunny Posted March 5, 2015 Share Posted March 5, 2015 Waarom vertalen? Ik kan het prima lezen Anyway, if you send the keystrokes to a notepad window instead, do they get sent correctly? If they do, it's a problem with the application accepting the keystrokes, if they don't, it's a problem with your logic. also, what is it exactly that you are trying to automate? There may be much better ways then doing it through mouse/keyboard simulation, which is generally a last resort. (Or a game-automation attempt... Which yours doesn't seem to be ) Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
jdelaney Posted March 5, 2015 Share Posted March 5, 2015 (edited) Use the list view functions...(just an example of what the functions look like) _GUICtrlListView_AddArray Don't use sends or clicks, and your script will be tons more reliable. _GUICtrlListView_SetItemText Sends are the weakest form of automation you can perform. It's entirely reliant on the processing power of both your computer and the application you are sending to. It's a last resort kind of function. Edited March 5, 2015 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
markyrocks Posted March 5, 2015 Share Posted March 5, 2015 (edited) Just a question but where does 65567800 come from? Edited March 5, 2015 by markyrocks Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
Marss Posted March 5, 2015 Author Share Posted March 5, 2015 Waarom vertalen? Ik kan het prima lezen Anyway, if you send the keystrokes to a notepad window instead, do they get sent correctly? If they do, it's a problem with the application accepting the keystrokes, if they don't, it's a problem with your logic. also, what is it exactly that you are trying to automate? There may be much better ways then doing it through mouse/keyboard simulation, which is generally a last resort. (Or a game-automation attempt... Which yours doesn't seem to be ) I tried. They get sent to notepad correctly. If I use the script the very first time, it often misplaces the values. If I use it 9 times directly afterwards it generally puts the correct values in the correct cells. Here is a screenshot of the application: I am trying to change the values in the cells 1202 / 1, 1202 / 2, 1203 / 1, 1203 / 2. (or 1.2, 1.3, 2.2, 2.3). If I change these values and press enter (or tab) the application automatically sends these value to the motor. The application is designed to sends commands to an industrial servomotor. I am trying to automate these commands so another application can easily write the correct values of how far the motor needs to rotate and how fast it needs to go. Use the list view functions...(just an example of what the functions look like) _GUICtrlListView_AddArray Don't use sends or clicks, and your script will be tons more reliable. _GUICtrlListView_SetItemText Sends are the weakest form of automation you can perform. It's entirely reliant on the processing power of both your computer and the application you are sending to. It's a last resort kind of function. I will dive into this. Wanted to respond asap first. Thank you for your suggestion, will let you know how it turns out. Just a question but where does 65567800 come from? 65536 is the number of units it takes to complete a full round of the servomotor (or 360 degrees). The motor is powerful enough to rotate hundreds of times per second so its very accurate. Link to comment Share on other sites More sharing options...
SadBunny Posted March 5, 2015 Share Posted March 5, 2015 (edited) If you type manually, does the application look like it does anything while you are typing (parsing, saving, error checking, sync other values, whatever)? If so, it may just be too busy to recognize the keystrokes/mouseclicks. Anyway, I wouldn't like my industrial motor processes dependent on the success of keystroke/mouseclicks. This is going to kick you in the ass sooner or later as those are highly unreliable, at least in terms of how reliably you want an industrial process to be controlled that actually works on real-world materials It may be worth your time researching how to directly manipulate the data the application uses. (Is there a database you may be able to access/manipulate? Does it take csv tables as input files?) Maybe even how to directly communicate with the com port (there's more information on this forum from some other people facing these sorts of issues), though I would rather have something like a small C application in between for that. Edited March 5, 2015 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Marss Posted March 5, 2015 Author Share Posted March 5, 2015 If the application is running and is actually powering the motor is does not do anything while I am typing until I hit the ENTER or TAB key. I am aware it will kick me in the ass later. This script is just a quick(er) fix for demonstration purposes, allowing us to show that we can automate the process. Eventually we would like to write an application that communicates directly with the motor, but that is beyond the scope of our current project. (I just dont know enough about coding yet to write those kinds of apps). Also it will not be anything industrial related, the motor is there to just shake an object whenever an event occurs in our own application. So delays up until ~300, maybe 500ms could be acceptable if that means its at least ~98% reliable We have not been able to find an API for the application, nor does it accept any sort of csv / xml / etc files as input. Link to comment Share on other sites More sharing options...
SadBunny Posted March 5, 2015 Share Posted March 5, 2015 Maybe try this dirty workaround: instead of Send()'ing an entire string, try writing a wrapper function that takes the string you want to send and send it character by character. #include <StringConstants.au3> _mySend("hallo") Func _mySend($string) For $c In StringSplit($string, "", $STR_NOCOUNT) send($c) Next EndFunc ;==>_mySend Don't know if it changes anything. Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Marss Posted March 5, 2015 Author Share Posted March 5, 2015 Unfortunately that did not work. Could it be something with the mouseclicks? Otherwise I'll just only run the app on the fastest pc I can find ;-) Link to comment Share on other sites More sharing options...
SadBunny Posted March 5, 2015 Share Posted March 5, 2015 (edited) Very hard to tell, that's the problem... Especially since you indicated that it's not even structurally reproducable. What does the Au3Info tool (ctrl+f6 in scite4autoit3) tell you about the window? And the >simplespy script? Maybe that gives some extra ideas on what other kinds of more direct automation are perhaps possible. Groeten uit Sydney, ik gaat eens een stukje aftaaien van mijn werk, tien uur alweer... Morgen vroeg weer op Edited March 5, 2015 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Marss Posted March 5, 2015 Author Share Posted March 5, 2015 (edited) Au3info Summary: >>>> Window <<<< Title: VTable 8.04 (COM3 [115200]) - [1: - 603 206 000 ; 12087363] Class: Afx:400000:b:10003:6:802069d Position: 114, 26 Size: 1080, 892 Style: 0x14CF8000 ExStyle: 0x00000100 Handle: 0x000F062C >>>> Control <<<< Class: SysListView32 Instance: 6 ClassnameNN: SysListView326 Name: Advanced (Class): [CLASS:SysListView32; INSTANCE:6] ID: 2000 Text: Position: 195, 2 Size: 869, 485 ControlClick Coords: 126, 28 Style: 0x5091000D ExStyle: 0x00000000 Handle: 0x0889056A >>>> Mouse <<<< Position: 443, 107 Cursor ID: 0 Color: 0xFFFFFF >>>> StatusBar <<<< 1: Minimum value: 1 u/s^2; Default value: 327680 u/s^2; Maximum value: 2147483647 u/s^2 2: 3: 4: >>>> ToolsBar <<<< >>>> Visible Text <<<< Minimum value: 1 u/s^2; Default value: 327680 u/s^2; Maximum value: 2147483647 u/s^2 >>>> Hidden Text <<<< 32768000 List1 Simplespy when I hover mouse over the cell from screenshot above (1202 - index 1) expandcollapse popupMouse position is retrieved 315-85 At least we have an element [327680 units][] Having the following values for all properties: Title is: <327680 units> Class := <> controltype:= <UIA_TextControlTypeId> ,<50020> , (0000C364) 286;75;80;17 *** Parent Information top down *** 4: Title is: <Bureaublad> Class := <#32769> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 0;0;1920;1080 "Title:=Bureaublad;controltype:=UIA_PaneControlTypeId;class:=#32769" 3: Title is: <VTable 8.04 (COM3 [115200]) - [1: - 603 206 000 ; 12087363]> Class := <Afx:400000:b:10003:6:802069d> controltype:= <UIA_WindowControlTypeId> ,<50032> , (0000C370) 2;2;1080;892 "Title:=VTable 8.04 (COM3 [115200]) - [1: - 603 206 000 ; 12087363];controltype:=UIA_WindowControlTypeId;class:=Afx:400000:b:10003:6:802069d" 2: Title is: <> Class := <#32770> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 10;53;1064;814 "Title:=;controltype:=UIA_PaneControlTypeId;class:=#32770" 1: Title is: <> Class := <SysListView32> controltype:= <UIA_ListControlTypeId> ,<50008> , (0000C358) 205;55;869;485 "Title:=;controltype:=UIA_ListControlTypeId;class:=SysListView32" 0: Title is: <> Class := <> controltype:= <UIA_ListItemControlTypeId> ,<50007> , (0000C357) 206;75;867;17 "Title:=;controltype:=UIA_ListItemControlTypeId;class:=" ;~ *** Standard code *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) Local $oP3=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=VTable 8.04 (COM3 [115200]) - [1: - 603 206 000 ; 12087363];controltype:=UIA_WindowControlTypeId;class:=Afx:400000:b:10003:6:802069d", $treescope_children) _UIA_Action($oP3,"setfocus") Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=#32770", $treescope_children) _UIA_Action($oP2,"setfocus") Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_ListControlTypeId;class:=SysListView32", $treescope_children) _UIA_Action($oP1,"setfocus") Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_ListItemControlTypeId;class:=", $treescope_children) ;~ First find the object in the parent before you can do something ;~$oUIElement=_UIA_getObjectByFindAll("327680units.mainwindow", "title:=327680 units;ControlType:=UIA_TextControlTypeId", $treescope_subtree) Local $oUIElement=_UIA_getObjectByFindAll($oP0, "title:=327680 units;ControlType:=UIA_TextControlTypeId", $treescope_subtree) _UIA_action($oUIElement,"click") *** Detailed properties of the highlighted element *** UIA_title:= <327680 units> UIA_text:= <327680 units> UIA_regexptitle:= <327680 units> UIA_iaccessiblechildId:= <0> UIA_handle:= <0> UIA_RuntimeId:= <42;143197546;2;0;2> UIA_BoundingRectangle:= <286;75;80;17> UIA_ProcessId:= <3856> UIA_ControlType:= <50020> UIA_LocalizedControlType:= <tekst> UIA_Name:= <327680 units> UIA_HasKeyboardFocus:= <False> UIA_IsKeyboardFocusable:= <True> UIA_IsEnabled:= <True> UIA_Culture:= <0> UIA_IsControlElement:= <True> UIA_IsContentElement:= <True> UIA_IsPassword:= <False> UIA_NativeWindowHandle:= <0> UIA_IsOffscreen:= <False> UIA_Orientation:= <0> UIA_FrameworkId:= <Win32> UIA_IsRequiredForForm:= <False> UIA_IsDockPatternAvailable:= <False> UIA_IsExpandCollapsePatternAvailable:= <False> UIA_IsGridItemPatternAvailable:= <False> UIA_IsGridPatternAvailable:= <False> UIA_IsInvokePatternAvailable:= <False> UIA_IsMultipleViewPatternAvailable:= <False> UIA_IsRangeValuePatternAvailable:= <False> UIA_IsScrollPatternAvailable:= <False> UIA_IsScrollItemPatternAvailable:= <False> UIA_IsSelectionItemPatternAvailable:= <False> UIA_IsSelectionPatternAvailable:= <False> UIA_IsTablePatternAvailable:= <False> UIA_IsTableItemPatternAvailable:= <False> UIA_IsTextPatternAvailable:= <False> UIA_IsTogglePatternAvailable:= <False> UIA_IsTransformPatternAvailable:= <False> UIA_IsValuePatternAvailable:= <False> UIA_IsWindowPatternAvailable:= <False> UIA_ValueIsReadOnly:= <True> UIA_RangeValueValue:= <0> UIA_RangeValueIsReadOnly:= <True> UIA_RangeValueMinimum:= <0> UIA_RangeValueMaximum:= <0> UIA_RangeValueLargeChange:= <0> UIA_RangeValueSmallChange:= <0> UIA_ScrollHorizontalScrollPercent:= <0> UIA_ScrollHorizontalViewSize:= <100> UIA_ScrollVerticalScrollPercent:= <0> UIA_ScrollVerticalViewSize:= <100> UIA_ScrollHorizontallyScrollable:= <False> UIA_ScrollVerticallyScrollable:= <False> UIA_SelectionCanSelectMultiple:= <False> UIA_SelectionIsSelectionRequired:= <False> UIA_GridRowCount:= <0> UIA_GridColumnCount:= <0> UIA_GridItemRow:= <0> UIA_GridItemColumn:= <0> UIA_GridItemRowSpan:= <1> UIA_GridItemColumnSpan:= <1> UIA_DockDockPosition:= <5> UIA_ExpandCollapseExpandCollapseState:= <3> UIA_MultipleViewCurrentView:= <0> UIA_WindowCanMaximize:= <False> UIA_WindowCanMinimize:= <False> UIA_WindowWindowVisualState:= <0> UIA_WindowWindowInteractionState:= <0> UIA_WindowIsModal:= <False> UIA_WindowIsTopmost:= <False> UIA_SelectionItemIsSelected:= <False> UIA_TableRowOrColumnMajor:= <2> UIA_ToggleToggleState:= <2> UIA_TransformCanMove:= <False> UIA_TransformCanResize:= <False> UIA_TransformCanRotate:= <False> UIA_IsLegacyIAccessiblePatternAvailable:= <True> UIA_LegacyIAccessibleChildId:= <0> UIA_LegacyIAccessibleName:= <327680 units> UIA_LegacyIAccessibleRole:= <41> UIA_LegacyIAccessibleState:= <1048576> UIA_IsDataValidForForm:= <False> UIA_ProviderDescription:= <[pid:3856,hwnd:0x0 Main(parent link):Microsoft: ListView SubItem Proxy (unmanaged:uiautomationcore.dll)]> UIA_IsItemContainerPatternAvailable:= <False> UIA_IsVirtualizedItemPatternAvailable:= <False> UIA_IsSynchronizedInputPatternAvailable:= <False> Thanks for taking the time to help! Groeten terug! Ik zie het wel verschijnen zodra het normalere tijden zijn Edited March 5, 2015 by Marss Link to comment Share on other sites More sharing options...
caramen Posted March 5, 2015 Share Posted March 5, 2015 (edited) Opt("SendKeyDelay", 5) ;5 milliseconds Opt("SendKeyDownDelay", 1) ;1 millisecond Maybe ?^^ Edited March 5, 2015 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
Marss Posted March 5, 2015 Author Share Posted March 5, 2015 (edited) @caramen Decreasing the opt delay only makes the script work worse I have currently set the values at 30ms :-/ @SadBunny Using SimpleSpy on different cells I can see that the only distinct variable is either the title (which is the input from the string that varies all the time so I cant use that) and "UTA_RuntimeID" For the cell from the screenshot on row 1202 + Index 1 its UIA_RuntimeId:= <42;143197546;2;0;2> and: 0: Title is: <> Class := <> controltype:= <UIA_ListItemControlTypeId> ,<50007> , (0000C357) 206;75;867;17 "Title:=;controltype:=UIA_ListItemControlTypeId;class:=" 1202 + Index 2 UIA_RuntimeId:= <42;143197546;2;0;3> and: 0: Title is: <> Class := <> controltype:= <UIA_ListItemControlTypeId> ,<50007> , (0000C357) 206;75;669;17 "Title:=;controltype:=UIA_ListItemControlTypeId;class:=" 1203 + Index 1 UIA_RuntimeId:= <42;143197546;2;1;2> and: 0: Title is: <> Class := <> controltype:= <UIA_ListItemControlTypeId> ,<50007> , (0000C357) 206;92;867;17 "Title:=;controltype:=UIA_ListItemControlTypeId;class:=" Can I use these IDs to send values to ? How would I incorporate that in my current code? Edited March 5, 2015 by Marss Link to comment Share on other sites More sharing options...
SadBunny Posted March 5, 2015 Share Posted March 5, 2015 To be very honest: I haven't a clue. I've just seen other people do great stuff with it. Maybe look at a couple of example scripts, I see functions like setvalue, settext, settext using key and what not. As I don't have access to your program and have no use for this in my world, I am not going to research that awesome project just now. I'm afraid I can't think of any other approaches... You could always ask a new question of course, more specifically aimed at using the simplespy stuff to tinker with those fields. Maybe a more l33t topic title will attract a more l33t baws who is much more experienced that I am Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Marss Posted March 5, 2015 Author Share Posted March 5, 2015 Thanks for helping SadBunny:) Anyone else have any ideas? =] Link to comment Share on other sites More sharing options...
jdelaney Posted March 5, 2015 Share Posted March 5, 2015 (edited) Don't use send. That's a hack that is unreliable...and it will never be reliable, no matter how many tweaks you add. Even if you get it to work consistently, I doubt your script will ever run a success but 80% of the time. You can up that percent substantially with other functions. Use (click on it to see the helpfile with an example): _GUICtrlListView_SetItemText Edited March 5, 2015 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Marss Posted March 6, 2015 Author Share Posted March 6, 2015 (edited) Don't use send. That's a hack that is unreliable...and it will never be reliable, no matter how many tweaks you add. Even if you get it to work consistently, I doubt your script will ever run a success but 80% of the time. You can up that percent substantially with other functions. Use (click on it to see the helpfile with an example): _GUICtrlListView_SetItemText I've been trying to read up on examples of GUICtrl, but it seems like they all build their own tables instead of reading tables from other applications. I have tried the following codes in my script: $windowTitle = "VTable 8.04 (COM3 [115200]) - [1: - 603 206 000 ; 12087363]" $windowControlID = "[CLASS:SysListView32; INSTANCE:6]" ; Try #1: _GUICtrlListView_SetItemText($windowTitle, 1, "1000") ;Try #2: _GUICtrlListView_SetItemText($windowControlID, 1, "1000") It just gives me an error. I'm sure I must be doing something wrong, could you point me in the right direction? What kind of input do I need to give here? The example on the link you gave me seems to work only with a newly created listview. Edited March 6, 2015 by Marss Link to comment Share on other sites More sharing options...
jdelaney Posted March 6, 2015 Share Posted March 6, 2015 (edited) You need to use handles...and you flubbed the params, I think $windowTitle = "VTable 8.04 (COM3 [115200]) - [1: - 603 206 000 ; 12087363]" $windowControlID = "[CLASS:SysListView32; INSTANCE:6]" $hWin = WinGetHandle($windowTitle) $hControl = ControlGetHandle($hWin,"",$windowControlID) ;~ _GUICtrlListView_SetItem($hWnd, $sText [, $iIndex = 0 [, $iSubItem = 0 [, $iImage = -1 [, $iParam = -1 [, $iIndent = -1]]]]]) $iRowToEdit = 1 ; the row $iSubItemToEdit = 2 ; the column _GUICtrlListView_SetItem($hControl,"texttoadd",$iRowToEdit,$iSubItemToEdit) These functions work on 3rd party, and self created, list views...so no worries there. Edited March 6, 2015 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Marss Posted March 9, 2015 Author Share Posted March 9, 2015 (edited) jdelaney, thanks a lot for your help so far. I have tried using your code, but autoit is throwing me an error saying it's an unknown function name. I've tried to play around with $windowTitle and $windowControlID but I am not sure where I am going wrong. I have attached a screenshot of AutoIT info, along with my code. I hope it's not too much to ask if you could please look it over and see if you can spot my error? expandcollapse popup#include <StringConstants.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) $iRowToEdit = 1 $iSubItemToEdit = 2 $liDraaiafstand = 65536*5 $reDraaiafstand = -65536*5 $liSnelheid = 16384000 $reSnelheid = 16384000 $delayL = 25 $delayS = 35 ;-------------------------------------- ; Start Script ;-------------------------------------- ; Set delays Opt("SendKeyDelay", 30) Opt("SendKeyDownDelay", 30) ; Activate Vtable WinActivate($windowTitle) ; Wait till active WinWaitActive($windowTitle) ;-------------------------------------- ; Index 1 ;-------------------------------------- ; Click once inside Vtable on the coordinates in the function ;ControlClick($windowTitle, "", $windowControlID, "left", 1, 150, 26) ;Sleep($delayS) _GUICtrlListView_SetItem($hControl,"105000",$iRowToEdit,$iSubItemToEdit) ; Send the rotatevalue (1 full round is 65536 units) press enter to confirm value ;Send($liDraaiafstand) ;Sleep($delayL) Send("{ENTER}") ;Sleep($delayS) ; Click once inside Vtable on the coordinates in the function ControlClick($windowTitle, "", $windowControlID, "left", 1, 150, 43) Sleep($delayS) ; Send the speed value, press enter to confirm value Send($liSnelheid) ;Sleep($delayL) Send("{ENTER}") ;Sleep($delayS) ;-------------------------------------- ; Index 2 ;-------------------------------------- ; Click once inside Vtable on the coordinates in the function ControlClick($windowTitle, "", $windowControlID, "left", 1, 235, 26) Sleep($delayS) ; Send the rotatevalue (1 full round is 65536 units) press enter to confirm value Send($reDraaiafstand) ;Sleep($delayL) Send("{ENTER}") ;Sleep($delayS) ; Click once inside Vtable on the coordinates in the function ControlClick($windowTitle, "", $windowControlID, "left", 1, 235, 43) Sleep($delayS) ; Send the speed value, press enter to confirm value Send($reSnelheid) ;Sleep($delayL) Send("{ENTER}") ;Sleep($delayS) Edited March 9, 2015 by Marss Link to comment Share on other sites More sharing options...
Marss Posted March 9, 2015 Author Share Posted March 9, 2015 (edited) Huge win It now sets the values correctly and its superfast. However... It sets the text correctly in the cells, the application however requires that after I set the text I press "enter" or "tab". If I send {ENTER} then its just puts the string "{ENTER}" in the cell without simulating pressing the enter key. How do I do that? Because if I dont send enter after putting in the values it automatically revert back to the older values after ~3 seconds. expandcollapse popup#include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #include <GuiListView.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 ;-------------------------------------- ; Activate Vtable WinActivate($windowTitle) ; Wait till active WinWaitActive($windowTitle) ;-------------------------------------- ; Index 1 ;-------------------------------------- ;Target Position value Index 1 in Vtable $iRowToEdit = 0 $iSubItemToEdit = 2 _GUICtrlListView_SetItem($hControl,"100001",$iRowToEdit,$iSubItemToEdit) ;Target Speed value Index 1 in Vtable $iRowToEdit = 1 $iSubItemToEdit = 2 _GUICtrlListView_SetItem($hControl,"105000",$iRowToEdit,$iSubItemToEdit) ;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,"106000",$iRowToEdit,$iSubItemToEdit) Edited March 9, 2015 by Marss 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