Iulia_Vascan Posted October 30, 2018 Share Posted October 30, 2018 Hello, I am new to AutoIT, I am trying to automate the push of two buttons in a GUI. The first one is presented in a1.png ("Add" - Button), the second one in a2.png ("GetDP circuit" - Button). This is my code: Run("E:\Iulia_Vascan\dolomites-release-python\Dolomites.exe") ControlClick("Dolomites","", controlID [, button = "left" [, clicks = 1 [, 217 [, 298]]]] ) ControlClick("Dolomites","", controlID [, button = "left" [, clicks = 1 [, 307 [, 59]]]] ) ControlFocus("Save GetDP circuit", "", "Edit1") ControlSetText("Save GetDP circuit", "", "Edit1", "E:\Iulia_Vascan\Metoda_2\winding.pro") ControlClick("Save GetDP circuit", "","Button2") I write the ControlClick function as is presented in the Help - Function Reference, but it didn't work and I can't figure out why. Thank you! Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted October 30, 2018 Share Posted October 30, 2018 Hi @Iulia_Vascan, and welcome to the AutoIt Forums First of all, when you call your Control* functions, you don't have to write the square brackets, because the only mean that they are optional parameters. Then, you have to see the Control tab in the AutoItWindowsInfoTool instead of Mouse tab; from there, you can see the Control class, ID, and so on, which you can use in your Control* functions. So, run once again the AutoItWindowInfoTool and look at the Control button, in which there are all the information needed to use ControlClick() function Once you have finished, post again your code, replacing all the information you got Xandy and Iulia_Vascan 2 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Iulia_Vascan Posted October 30, 2018 Author Share Posted October 30, 2018 I was looking in the section which you mentioned, but I have no info for the Control part. Link to comment Share on other sites More sharing options...
Iulia_Vascan Posted October 30, 2018 Author Share Posted October 30, 2018 @FrancescoDiMuro I was looking in the section which you mentioned, but I have no info for the Control part. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted October 30, 2018 Share Posted October 30, 2018 (edited) Since your case may be this, use Mose postion to use ControlClick(): ControlClick("Dolomites","", "", "left", 1, 215, 298) Try this and let us know Edited October 30, 2018 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Iulia_Vascan Posted October 30, 2018 Author Share Posted October 30, 2018 Run("E:\Iulia_Vascan\dolomites-release-python\Dolomites.exe") ControlClick("Dolomites","", "", "left", 1, 215, 298) ControlClick("Dolomites","", "", "left", 1, 307, 59) ControlFocus("Save GetDP circuit", "", "Edit1") ControlSetText("Save GetDP circuit", "", "Edit1", "E:\Iulia_Vascan\Metoda_2\winding.pro") ControlClick("Save GetDP circuit", "","Button2") @FrancescoDiMuro I tried this way, but it's not working ... the script just run the exe file and that's all. Link to comment Share on other sites More sharing options...
Earthshine Posted October 30, 2018 Share Posted October 30, 2018 you have to wait for controls...... My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Iulia_Vascan Posted October 30, 2018 Author Share Posted October 30, 2018 @Earthshine I've been waiting like 5 minutes to do something... but it doesn't. Are you referring to something else? Like a function or smth? Link to comment Share on other sites More sharing options...
Earthshine Posted October 30, 2018 Share Posted October 30, 2018 (edited) so, can you give us the information for each button or object you wish to click or interact with from the Windows Information Tool? What I mean for waiting for controls is that they don't just exist immediately when the script is run, you need to wait for them.... see my WaitForControls udf, also, if they are not standard windows components, then your methods of manipulation will vary Edited October 30, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted October 30, 2018 Share Posted October 30, 2018 @Iulia_Vascan What Eartshine was meaning, is that you have to wait the Controls to be "ready", in order to interact with them. So, you could add a WinWaitActive() with your window, in order to know when your window will be active and "ready" to play with Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Earthshine Posted October 30, 2018 Share Posted October 30, 2018 that wraps most controls that can be clicked. to get logging working, get the logger from this site and configure it in the main script so then when you call this the logging works. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
caramen Posted October 30, 2018 Share Posted October 30, 2018 1 hour ago, Earthshine said: so, can you give us the information for each button or object you wish to click or interact with from the Windows Information Tool? What I mean for waiting for controls is that they don't just exist immediately when the script is run, you need to wait for them.... see my WaitForControls udf, also, if they are not standard windows components, then your methods of manipulation will vary Not sure... But i think you are maybe false. How can you be sure he have to wait for a Control ? Exept if you know the software but you did not mentioned it. He is trying to get information from a control ... I mean if the control is visible he is existing... Or I am false ? .net application should not be able to receive a postmessage controlclick Exept with IUIAutomation...? But still it is not post message click. 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...
Earthshine Posted October 30, 2018 Share Posted October 30, 2018 i know because that's how windows works. it takes time for an app that has just launched to be ready. the other theory is that they are not windows controls and he won't be able to click them using autoit anyway. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
caramen Posted October 30, 2018 Share Posted October 30, 2018 (edited) He will, if he use the IUIA UDF So no it s not the only one Theory There is some case where you cannot click and you can couturn it. Java application .net Application probably more And yes it is true that you have to wait each time you run an application: in some milisecond. But if you script correctly you wont access an unexistant control... You implement a sleep a winactivate or what ever.... I dont want to make you help small. Just advising no worry. Edited October 30, 2018 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...
Earthshine Posted October 30, 2018 Share Posted October 30, 2018 now i am going to test the app he's talking about for myself. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Earthshine Posted October 30, 2018 Share Posted October 30, 2018 (edited) only option it to try IUIAutomation. let me try it. it is not made with windows controls. IUIAutomation works, this clicks the Wizard button, then clicks it. Works! I used the portable Dolomites, and it correctly highlights everything it's looking for, in pretty good time too. do I win a badge? lol expandcollapse popup;~ *** Standard code maintainable *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) _UIA_setVar("oP1","Title:=Dolomites;controltype:=UIA_WindowControlTypeId;class:=Qt5QWindowIcon") ;Dolomites _UIA_setVar("oP2","Title:=;controltype:=UIA_CustomControlTypeId;class:=") ; _UIA_setVar("oP3","Title:=;controltype:=UIA_SplitButtonControlTypeId;class:=") ; _UIA_setVar("oP4","Title:=;controltype:=UIA_CustomControlTypeId;class:=") ; _UIA_setVar("oP5","Title:=;controltype:=UIA_CustomControlTypeId;class:=") ; _UIA_setVar("oP6","Title:=;controltype:=UIA_SplitButtonControlTypeId;class:=") ; _UIA_setVar("oP7","Title:=;controltype:=UIA_SplitButtonControlTypeId;class:=") ; _UIA_setVar("oP8","Title:=;controltype:=UIA_CustomControlTypeId;class:=") ; ;~ $oUIElement=_UIA_getObjectByFindAll("Wizard....mainwindow", "title:=Wizard...;ControlType:=UIA_ButtonControlTypeId", $treescope_subtree) _UIA_setVar("oUIElement","Title:=Wizard...;controltype:=UIA_ButtonControlTypeId;class:=") ;ControlType:=UIA_ButtonControlTypeId;classname:=") ;~ Actions split away from logical/technical definition above can come from configfiles ;~_UIA_Action("oP1","highlight") _UIA_Action("oP1","setfocus") ;~_UIA_Action("oP2","highlight") _UIA_Action("oP2","setfocus") ;~_UIA_Action("oP3","highlight") _UIA_Action("oP3","setfocus") ;~_UIA_Action("oP4","highlight") _UIA_Action("oP4","setfocus") ;~_UIA_Action("oP5","highlight") _UIA_Action("oP5","setfocus") ;~_UIA_Action("oP6","highlight") _UIA_Action("oP6","setfocus") ;~_UIA_Action("oP7","highlight") _UIA_Action("oP7","setfocus") ;~_UIA_Action("oP8","highlight") _UIA_Action("oP8","setfocus") _UIA_action("oUIElement","highlight") _UIA_action("oUIElement","click") Edited October 30, 2018 by Earthshine FrancescoDiMuro 1 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
caramen Posted October 31, 2018 Share Posted October 31, 2018 (edited) If you do this the op will omit to care about the parent children windows focus. Anyway. It was obvius . Edited October 31, 2018 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...
Iulia_Vascan Posted October 31, 2018 Author Share Posted October 31, 2018 @Earthshine Sorry for the delay. This are my buttons info from AutoIT v3 Window. Can you please explain me what have you done there? Thank you! Link to comment Share on other sites More sharing options...
caramen Posted October 31, 2018 Share Posted October 31, 2018 (edited) He just used the IUIAutomation UDF. That is allowing you to automate.net windows that autoIT cannot automate. This UDF request some training. Mail you can search in my precedent posts. I have a topic named IUIAutomation learning. It will show you how i learned it and what issue i encoutered and how i resolved them. You will have to face on this if you want to use IUIA UDF. Here you go : Edited October 31, 2018 by caramen Iulia_Vascan and Earthshine 2 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...
Earthshine Posted October 31, 2018 Share Posted October 31, 2018 (edited) yeah, run simplespy, move your mouse over the app and press Ctrl-W, then paste the code to your AutoIt editor and start playing around. IUIAutomation is not really that difficult when you figure out what you looking for. I suggest going through all the examples and getting stuff to work and start learning that way. if you need more help, post back. One thing I have done to really get into @junkew's IUIAutomation is study his actual UDF code. it's a gold mine. but that comes later, for now, get the samples to work, we can help with that. post back if you need help. That Dolomites program is pretty cool actually. Playing with coils... sweet. Edited October 31, 2018 by Earthshine Iulia_Vascan 1 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Recommended Posts