alien4u Posted March 17, 2016 Share Posted March 17, 2016 (edited) Im doing some work around to software with a dataGrid class on it. I know autoit don't support this but anyways in this scenario is possible to work with it. This particular software has fixed size and can't be resize or maximize and it has 8 rows per page and 3 columns on each row. So what I do is to ControlSend("{PGDN 18}") to position de cursor on last row and ControlSend("^c") to copy the content of that row. Then I get the clipboard data $sData = ClipGet(), until this point is working very well. Then ControlSend("{TAB 2}") to focus a Buttom inside that row but in the column 3. The only way I found to action that button is sending SPACE key. That open a Window's Save Dialog window and CHANGE the value of the variable holding the ClipGet() data($sData). Why is this happening? Here you have the code: #include <MsgBoxConstants.au3> #include <Array.au3> #include <String.au3> ShellExecute("Path to Software.exe","","Working DIR","",@SW_HIDE) WinWait ("[WindowsForms10.Window.8.app.0.2bf8098_r13_ad1]") If WinExists("[CLASS:WindowsForms10.Window.8.app.0.2bf8098_r13_ad1]") Then $winId = WinGetHandle("[CLASS:WindowsForms10.Window.8.app.0.2bf8098_r13_ad1]") ControlFocus($winId, "", "[NAME:dataGridDesbloqueos]") ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","{PGDN 18}") ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","^c") $sData = ClipGet() ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","{TAB 2}") ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","{SPACE}") WinWait ("Guardar como") $Id2 = WinGetHandle("Guardar como") MsgBox($MB_SYSTEMMODAL, "", "Data from ClipGet: "& @CR & $sData) MsgBox($MB_SYSTEMMODAL, "", "Handler of SaveDialog: "& @CR & $Id2) Else MsgBox($MB_SYSTEMMODAL, "", "Window does not exist") EndIf If I check the $sData value before I Send the Space key to open the SaveDialog the value is correct, but if I check the value after the SaveDialog is open the $sData value change taking the Caption of the Save Button as value you can check it: $sData = ClipGet() MsgBox($MB_SYSTEMMODAL, "", "Data from ClipGet: "& @CR & $sData); Correct Data ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","{TAB 2}") ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","{SPACE}") WinWait ("Guardar como") $Id2 = WinGetHandle("Guardar como") MsgBox($MB_SYSTEMMODAL, "", "Data from ClipGet after SaveDialog is open: "& @CR & $sData); Modified Data MsgBox($MB_SYSTEMMODAL, "", "Handler of SaveDialog: "& @CR & $Id2) Fixed Typo pointed by mLipok This was a mistake copying the text from the Editor because I was using a variable for the number of {PGND} I send. Every time I try to test what I was doing I did not realize that I spawn a new process because I was using @SW_HIDE so I got like 10 windows and of course with the same Internal Class names and everything was an entire mess. I really sorry for all this, my apologies. Kind Regards Alien Edited March 21, 2016 by alien4u Fixed typo, Adding more Info, make clear was entirely my fault. Link to comment Share on other sites More sharing options...
mLipok Posted March 17, 2016 Share Posted March 17, 2016 ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","{PGDN 18"}") there is too many " Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
alien4u Posted March 18, 2016 Author Share Posted March 18, 2016 Typo Fixed. This is not the main problem, this typo was because I was using a variable for the number of {PGND} I sent. Kind Regards. Link to comment Share on other sites More sharing options...
alien4u Posted March 18, 2016 Author Share Posted March 18, 2016 I end up writing the ClipGet() data in this case $sData on a file and read that value back to another variable. I don't thinks this is a good way to do it and still cant understand why pressing SPACE change the value already store in a variable? Sure this is not an AutoIt bug? Kind Regards Alien. Link to comment Share on other sites More sharing options...
AutoBert Posted March 18, 2016 Share Posted March 18, 2016 Make a runable reproducer with a App (to automate) everybody has (like notepad.exe). I think you only posted a snipet and somewhere else in your code $data is new assigned. Link to comment Share on other sites More sharing options...
alien4u Posted March 18, 2016 Author Share Posted March 18, 2016 Hi AutoBert thanks for your reply. This is the entire code, no a portion of it. I can't reproduce this because Notepad don't have DataGrid, will find a way to reproduce this, because the software I'm trying to automate only work with a license. Anyways I will try to reproduce this using another software with datagrid. This is really odd and because of this I think is an AutoIt bug, even if I create and array and add $sData value to the array after the SPACE key is pressed and the SaveDialog open the array value also change. This change the value of $sData and $Array, like in this example: $Array[1] $sData = ClipGet() _ArrayAdd($Array,$sData) MsgBox($MB_SYSTEMMODAL, "", "Data from ClipGet: "& @CR & $sData); Show Correct Data _ArrayDisplay($Array) ; Show correct data ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","{TAB 2}") ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","{SPACE}") WinWait ("Guardar como") $Id2 = WinGetHandle("Guardar como") MsgBox($MB_SYSTEMMODAL, "", "Data from ClipGet after SaveDialog is open: "& @CR & $sData); Show Modified Data _ArrayDisplay($Array) ; Show Modified data MsgBox($MB_SYSTEMMODAL, "", "Handler of SaveDialog: "& @CR & $Id2) Kind Regards Alien. Link to comment Share on other sites More sharing options...
alien4u Posted March 19, 2016 Author Share Posted March 19, 2016 More News on this: If you work with the Main Window in @SW_HIDE mode everything work as it should until SaveDialog apear, this even change all the variables and data on that variables even writing to a file does not work. If you work with the Main Window with @SW_HIDE mode and you keep in that way without open the SaveDialog everything work well. In the other hand if you work with the Main Window without @SW_HIDE everything work ok, nothing change and you can do everything as normal. Conclusion: Look like if you use @SW_HIDE and that window spawn a second window in visible mode(Save Dialog) everything become a mess. Maybe AutoIt specialist could explain why this happen or if they think would be a fix in the future. Kind Regards Alien. Link to comment Share on other sites More sharing options...
AutoBert Posted March 19, 2016 Share Posted March 19, 2016 18 hours ago, alien4u said: Hi AutoBert thanks for your reply. This is the entire code, no a portion of it. This change the value of $sData and $Array, like in this example: $Array[1] $sData = ClipGet() _ArrayAdd($Array,$sData) MsgBox($MB_SYSTEMMODAL, "", "Data from ClipGet: "& @CR & $sData); Show Correct Data _ArrayDisplay($Array) ; Show correct data ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","{TAB 2}") ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","{SPACE}") WinWait ("Guardar como") $Id2 = WinGetHandle("Guardar como") MsgBox($MB_SYSTEMMODAL, "", "Data from ClipGet after SaveDialog is open: "& @CR & $sData); Show Modified Data _ArrayDisplay($Array) ; Show Modified data MsgBox($MB_SYSTEMMODAL, "", "Handler of SaveDialog: "& @CR & $Id2) This is no runable script: >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\Bert\AutoIt3.My\Temp\asdf.au3" /UserParams +>15:45:35 Starting AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0 Keyboard:00000407 OS:WIN_81/ CPU:X64 OS:X64 Environment(Language:0407) +> SciTEDir => C:\Program Files\AutoIt3\SciTE UserDir => C:\Users\Bert\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Bert\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.2) from:C:\Program Files\AutoIt3 input:C:\Users\Bert\AutoIt3.My\Temp\asdf.au3 "C:\Users\Bert\AutoIt3.My\Temp\asdf.au3"(1,10) : warning: $Array: possibly used before declaration. $Array[1] ~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Temp\asdf.au3"(1,10) : error: Statement cannot be just an expression. $Array[1] ~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Temp\asdf.au3"(4,23) : warning: $MB_SYSTEMMODAL: possibly used before declaration. MsgBox($MB_SYSTEMMODAL, ~~~~~~~~~~~~~~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Temp\asdf.au3"(6,19) : warning: $winId: possibly used before declaration. ControlSend($winId, ~~~~~~~~~~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Temp\asdf.au3"(1,10) : error: $Array: undeclared global variable. $Array[1] ~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Temp\asdf.au3"(4,23) : error: $MB_SYSTEMMODAL: undeclared global variable. MsgBox($MB_SYSTEMMODAL, ~~~~~~~~~~~~~~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Temp\asdf.au3"(6,19) : error: $winId: undeclared global variable. ControlSend($winId, ~~~~~~~~~~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Temp\asdf.au3"(3,24) : error: _ArrayAdd(): undefined function. _ArrayAdd($Array,$sData) ~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Temp\asdf.au3"(5,21) : error: _ArrayDisplay(): undefined function. _ArrayDisplay($Array) ~~~~~~~~~~~~~~~~~~~~^ C:\Users\Bert\AutoIt3.My\Temp\asdf.au3 - 6 error(s), 3 warning(s) !>15:45:37 AU3Check ended. Press F4 to jump to next error.rc:2 +>15:45:37 AutoIt3Wrapper Finished. >Exit code: 2 Time: 3.981 Link to comment Share on other sites More sharing options...
alien4u Posted March 19, 2016 Author Share Posted March 19, 2016 Hi again AutoBert. When I said this is not a portion of code is the entire code I refer to my first post(is not that obvious?) When I show an example code talking about the Array is a portion of the code because I think is redundant to copy and paste the entire code again. Anyways here you have the entire code with the array example include: #include <MsgBoxConstants.au3> #include <Array.au3> #include <String.au3> Global $Array[1] ShellExecute("Path to Software.exe","","Working DIR","",@SW_HIDE) WinWait ("[WindowsForms10.Window.8.app.0.2bf8098_r13_ad1]") If WinExists("[CLASS:WindowsForms10.Window.8.app.0.2bf8098_r13_ad1]") Then $winId = WinGetHandle("[CLASS:WindowsForms10.Window.8.app.0.2bf8098_r13_ad1]") ControlFocus($winId, "", "[NAME:dataGridDesbloqueos]") ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","{PGDN 18}") ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","^c") $sData = ClipGet() _ArrayAdd($Array,$sData) MsgBox($MB_SYSTEMMODAL, "", "Data from ClipGet: "& @CR & $sData); Show Correct Data _ArrayDisplay($Array) ; Show Correct data ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","{TAB 2}") ControlSend($winId, "", "[NAME:dataGridDesbloqueos]","{SPACE}") WinWait ("Guardar como") $Id2 = WinGetHandle("Guardar como") MsgBox($MB_SYSTEMMODAL, "", "Data from ClipGet after SaveDialog is open: "& @CR & $sData); Show Modified Data _ArrayDisplay($Array) ; Show Modified data Else MsgBox($MB_SYSTEMMODAL, "", "Window does not exist") EndIf If you wish I could send you another example writing to a file. Kind Regards Alien. Link to comment Share on other sites More sharing options...
AutoBert Posted March 19, 2016 Share Posted March 19, 2016 1 minute ago, alien4u said: If you wish I could send you another example writing to a file. I have already tested with notepad: #include <MsgBoxConstants.au3> $iPID = Run("notepad.exe", "", @SW_SHOW) WinWaitActive("[CLASS:Notepad]", "") $hWnd = WinGetHandle("[CLASS:Notepad]", "") Send("This is some text.") MsgBox($MB_SYSTEMMODAL, "", "Put a piece of text to Clipboard: ") WinSetState($hWnd,'',@SW_HIDE) $sData = ClipGet() MsgBox($MB_SYSTEMMODAL, "", "Data from ClipGet: "& @CR & $sData); Show Correct Data WinClose($hWnd) WinWaitActive($hWnd,'',5) MsgBox($MB_SYSTEMMODAL, "", "Data from ClipGet: "& @CR & $sData); Show Correct Data Send("!n") It's not a AutoIt problem as you can see. And when your app is changing data from a script without asking or initiated from you by code then put it in recyclebin. Link to comment Share on other sites More sharing options...
alien4u Posted March 19, 2016 Author Share Posted March 19, 2016 (edited) Hi AutoBert. I think you are missing a point here, please read my previous post before you quote today(I don't mean this, sorry) I mean: read my previous post right before your first post quote today. The problem is not with common windows, is with a window with a DataGrid on it and also that windows in @SW_HIDE mode spawn another windows without @SW_HIDE like an SaveDialog or OpenDialog because that cant be hidden. So you are missing that specific fact, anyways I will try to reproduce that with notepad and I will let you know. Thanks for your help. Kind Regards Alien. Edited March 19, 2016 by alien4u Fixing meaning of what I try to say. Link to comment Share on other sites More sharing options...
LarsJ Posted March 19, 2016 Share Posted March 19, 2016 You can automate a Windows Forms grid control with the UI Automation framework. 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...
alien4u Posted March 19, 2016 Author Share Posted March 19, 2016 1 hour ago, LarsJ said: You can automate a Windows Forms grid control with the UI Automation framework. Hello LarsJ, I will look in to that. Anyways I think there is still a problem when you mix @SW_HIDE windows and that window spawn another one that can't be hidden like Windows OpenDialogs or SaveDialogs. Kind Regards Alien. Link to comment Share on other sites More sharing options...
AutoBert Posted March 19, 2016 Share Posted March 19, 2016 3 hours ago, alien4u said: Hello LarsJ, I will look in to that. Anyways I think there is still a problem when you mix @SW_HIDE windows and that window spawn another one that can't be hidden like Windows OpenDialogs or SaveDialogs. There can't be a problem. When ClipGet assigned data (for example 'some data') to var, this var has this assigned data ('some data') until reassigned. If not it's woodo or a virus. Link to comment Share on other sites More sharing options...
alien4u Posted March 20, 2016 Author Share Posted March 20, 2016 9 hours ago, AutoBert said: There can't be a problem. When ClipGet assigned data (for example 'some data') to var, this var has this assigned data ('some data') until reassigned. If not it's woodo or a virus. Hi AutoBert. Look like we finally tune the same frequency here. I'm with you 120% you are right, but there is no Voodoo and there is no Virus, so what is left? - AutoIt problem. Anyways tomorrow is my day off, I will try to make a video showing the Script running and the very odd behavior. Kind Regards Alien. Link to comment Share on other sites More sharing options...
AutoBert Posted March 20, 2016 Share Posted March 20, 2016 1 hour ago, alien4u said: Look like we finally tune the same frequency here. I'm with you 120% you are right, but there is no Voodoo and there is no Virus, so what is left? - AutoIt problem. There is no AutoIt problem left, only thing left is the layer 8 problem. Ps.: this was my last answer until you can demonstrate the problem: On 18.3.2016 at 7:59 PM, AutoBert said: Make a runable reproducer with a App (to automate) everybody has (like notepad.exe). I think you only posted a snipet and somewhere else in your code $data is new assigned. Link to comment Share on other sites More sharing options...
alien4u Posted March 21, 2016 Author Share Posted March 21, 2016 On 20/3/2016 at 0:31 AM, AutoBert said: There is no AutoIt problem left, only thing left is the layer 8 problem. Ps.: this was my last answer until you can demonstrate the problem: You are right 1000% was entirely my fault. I was trying to reproduce the problem only to realize: Every time I try to test what I was doing I did not realize that I spawn a new process because I was using @SW_HIDE so I got like 10 windows and of course with the same Internal Class names and everything was an entire mess. I really sorry for all this, my apologies. Kind Regards Alien 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