Jump to content
Sign in to follow this  
Farality

WindowsForm C# AutoIT ControlClick not working but ControlSetText is working

Recommended Posts

Farality

I want to automate it with a hidden windows . 

Here is my scripts  . I'm new to AutoIT and trying to test a function on the windowsform C#.

                string _title = $"Form1";
                string _class = $"WindowsForms10.Window.8.app.0.141b42a_r10_ad1";
                string _titleClass = $"[TITLE:{_title};CLASS:{_class}]";
                IntPtr _hwnd = AutoIt.AutoItX.WinGetHandle($"{_titleClass}");
                IntPtr _ctrHandle = AutoIt.AutoItX.ControlGetHandle(_hwnd, "");
                string _ctrId = $"[Class:WindowsForms10.BUTTON.app.0.141b42a_r10_ad1;Instance:1]";

                  
                //AutoIt.AutoItX.ControlClick(_hwnd,"",$"{_ctrlId}");    /// Doesn't work
                ///AutoIt.AutoItX.ControlClick(_hwnd, _ctrHandle, "left", 1, 318, 144);    /// Doesn't work
                AutoIt.AutoItX.ControlClick(_titleClass,"","[Class:Button;Name:button2]","left",1);   ///////// Doesn't work
                AutoIt.AutoItX.ControlSetText(_titleClass, "", "[NAME:textBox1]", "Text was changed by ControlSetText"); /////// Worked !

 

PS. If the button2 is clicked then the messagebox will be pop up.

 

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  

×