thanhlam Posted September 10, 2013 Posted September 10, 2013 Hi, I try to use AutoIt to control a soft I have written in C# 4.0. I can start, stop the software, change the state of the checkbox. Something strange to uncheck the check box:; check the checkbox (working fine) ControlCommand($win, "", $checkbox, "Check", "") ; uncheck the checkbox (NOT WORKING) ControlCommand($win, "", $checkbox, "UnCheck", "" ; uncheck the checkbox (working) ControlCommand($win, "", $checkbox, "Check", "") Unfortunately I did not managed to get the check box status using :$res = ControlCommand($win, "", $checkbox, "IsChecked", "")
thanhlam Posted September 10, 2013 Author Posted September 10, 2013 How can I add a 7z with the content of the script and a test program in C#4.0 to illustrate my post ?
michaelslamet Posted September 10, 2013 Posted September 10, 2013 This might doesn't help, but do you notice that you lack a ")" at the end of non-working checkbox line?
thanhlam Posted September 10, 2013 Author Posted September 10, 2013 Hi, thanks for replying but this is only a copy/paste error, that's why I wanted to attach an archive with my sample but I did not find how to upload the archive.
saudumm Posted September 10, 2013 Posted September 10, 2013 You can attach a file using the full editor.
thanhlam Posted September 10, 2013 Author Posted September 10, 2013 Hi Saudumm, Could you be more specific in how to attach the file ? I trye to use "My media" but it propose only to select content that have been uploaded. I found no way to upload a file
saudumm Posted September 10, 2013 Posted September 10, 2013 Hi Saudumm, Could you be more specific in how to attach the file ? I trye to use "My media" but it propose only to select content that have been uploaded. I found no way to upload a file In the full editor there's "Attach Files" under the editor window. There you can select a file from your computer (1) and upload it (2). After that you can attach it to your post (3) :-)
thanhlam Posted September 10, 2013 Author Posted September 10, 2013 Thanks for your help Saudumm, but even in the full editor, just under the textbox I immediately have the "Add Reply, Preview Post or Cancel" line. There is nothing in between that would allow me to attach a file (sorry I cannot attach a screenshot to show you ) There must be a setting somewhere that prevent me from adding files (I just created my account today). Regards
somdcomputerguy Posted September 10, 2013 Posted September 10, 2013 There's probably a new user post count that must be met to allow files to be uploaded. You should post all of your au3 code to get better help. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
saudumm Posted September 10, 2013 Posted September 10, 2013 Maybe this option isn't available for new members. This is my 8. post but I'm registered since 2011 and I'm a normal member. Could you upload your file to Dropbox or something else and share the link?
thanhlam Posted September 10, 2013 Author Posted September 10, 2013 Here is the link to the visual studio project in C# and the test.au3 https://www.dropbox.com/s/fqy75h0qdbou3et/test.7z Here is the code of test.au3. $path = "WindowsFormsApplication1WindowsFormsApplication1binDebug" $bin = "WindowsFormsApplication1.exe" $soft = "[CLASS:WindowsForms10.Window.8.app.0.2bf8098_r20_ad1]" $checkbox = "[NAME:cbTest]" $checkbox2 = "[CLASS:WindowsForms10.BUTTON.app.0.2bf8098_r20_ad1; INSTANCE:1]" Run($path & $bin, $path) $win = WinWaitActive($soft) ; "Uncheck" is not working, have to "Check" a 2nd time to uncheck... ControlCommand($win, "", $checkbox, "Check", "") Sleep(500) ControlCommand($win, "", $checkbox, "Check", "") Sleep(500) ControlCommand($win, "", $checkbox, "Check", "") Sleep(500) $res = ControlCommand($win, "", $checkbox, "IsChecked", "") if 1 = @error Then MsgBox(4, "ERROR", "ERROR") Else MsgBox(4, "IsChecked", $res) EndIf ; Using class ControlCommand($win, "", $checkbox2, "Check", "") ; uncheck Sleep(500) ControlCommand($win, "", $checkbox2, "Check", "") ; recheck Sleep(500) $res = ControlCommand($win, "", $checkbox2, "IsChecked", "") if 1 = @error Then MsgBox(4, "ERROR", "ERROR") Else MsgBox(4, "IsChecked", $res) EndIf WinClose($soft)
saudumm Posted September 10, 2013 Posted September 10, 2013 So, no luck on my end with your script. I found those threads: '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> It seems like your .Net-Checkbox is a non-standard checkbox and is not supported by AutoIt. Maybe somenone with more knowledge can help you.
dragan Posted September 10, 2013 Posted September 10, 2013 (edited) It is good thing that you have control over your own .NET application. My advice is this: - Open your C# project, in the Form select your checkbox, click on the thunder icon (events icon), and double click on the event for "KeyDown" - Then in your C# code make sure you add this code: private void cbTest_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F8) { cbTest.Checked = true; } else if (e.KeyCode == Keys.F12) { cbTest.Checked = false; } } - Then make sure you use this in your autoit script: $path = "WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\" $bin = "WindowsFormsApplication1.exe" $soft = "Form1" $checkbox = "[NAME:cbTest]" Run($path & $bin, $path) $win = WinWaitActive($soft) ControlSend($win, '', $checkbox, "{F8}") MsgBox(0, '', 'it is checked!') ControlSend($win, '', $checkbox, "{F12}") MsgBox(0, '', 'it is unchecked!') WinClose($soft) Edit: Another idea: You could create a local TCP connection between autoit and your C# application, and then exchange informations (i.e. checked state), and make requests for checking/unchecking checkboxes or controlling other controls. Edited September 10, 2013 by dragan
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