Paulliev Posted March 3, 2021 Share Posted March 3, 2021 Hello, I have a question. I am making a Windows Form application with C#. I want to automate Chrome, I found out that it won't work properly with AutoITX. So I created a custom AutoIT script and I run it in my C# code. I want to give variables from my C# code to my normal AutoIT and use them there, is that possible? I tried copying a variable to my clipboard in C# and get it in my script, but I don't know how to copy the next variable to my clipboard. See below the code from my C# application. private static void AutoItTicket(Ticket ticket1) { #region Alle variabelen naar notepad exporteren Clipboard.SetText(ticket1.GetContactPersoon()); AutoItX.Run(@"C:\Program Files (x86)\AutoIt3\AutoIt3.exe /AutoIt3ExecuteScript setCompany.au3",@"C:\TicketScripts\", 1); //Clipboard.SetText(ticket1.GetProbleemOmschrijving()); #endregion } Link to comment Share on other sites More sharing options...
Nine Posted March 3, 2021 Share Posted March 3, 2021 Look help file under "Using AutoIt" and "Command Line Parameters", especially the part about $CmdLine. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Paulliev Posted March 10, 2021 Author Share Posted March 10, 2021 @Nine Thanks for your answer and sorry for my late reply. I don't get it working. I need to pass C# variables to my au3 script, but I don't know the syntax. See the code below. for example I want to add $test to the au3 file, how does that look like? $test = "Dynamic variable" ; Pass $test variable to the setCompany.au3 AutoItX.Run(@"C:\Program Files (x86)\AutoIt3\AutoIt3.exe, /AutoIt3ExecuteScript setCompany.au3", @"C:\TicketScripts\", 1); Thanks in advance! Link to comment Share on other sites More sharing options...
Nine Posted March 10, 2021 Share Posted March 10, 2021 I do not have C#, but I will show you with AutoIt : Example2() Func Example2() Local $oAutoIt = ObjCreate("AutoItX3.Control") Local $var = "This is a test" $oAutoIt.Run('"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" /AutoIt3ExecuteScript "C:\Apps\Autoit\Test.au3" ' & _ '"' & $var & '"', "", $oAutoIt.SW_SHOW) EndFunc Test.au3 #include <Constants.au3> MsgBox ($MB_SYSTEMMODAL, $CmdLine[0], $CmdLine[1]) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Danp2 Posted March 10, 2021 Share Posted March 10, 2021 I'm not experienced with C#, but I can't imagine that it doesn't offer the ability to launch an executable without the use of a 3rd party library. Therefore, I'm confused about why you are trying to use AutoItX to launch an AutoIt script. Why not just use native C# for this? P.S. Have you looked at the AutoItX help file entry for Run? To me, this command doesn't appear to support parameters. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Nine Posted March 10, 2021 Share Posted March 10, 2021 @danp2 My example works. It does support parameters “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Danp2 Posted March 10, 2021 Share Posted March 10, 2021 @Nine I see that now. 😉 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Earthshine Posted March 10, 2021 Share Posted March 10, 2021 (edited) here is how you do it. from the master @LarsJ I am not sure if you can do it via the com object mate. I have used the methods below and it works for me. @Nine, you do have .net installed most likely... lol you can use msbuild to build stuff in C# or any .NET language. it's fun! and they have SDKs too if you really want to develop/debug via Visual Code Edited March 10, 2021 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Paulliev Posted March 10, 2021 Author Share Posted March 10, 2021 @Earthshine Thanks for your answer. If I see correctly this is from autoIT to C#/ Dotnet. I have my variables in C# and want to pass them to my autoIT script running locally. I've got the AutoITX included in my C#. So it's the other way around. Link to comment Share on other sites More sharing options...
argumentum Posted March 10, 2021 Share Posted March 10, 2021 1 hour ago, Paulliev said: I've got the AutoITX included in my C#. So it's the other way around so..., wassup Doc. Say, why not write an AutoIt script and IPC back and forth with the C# ?. It'll be better than all this AutoItX, as AutoIt has more stuff. ( my 2 cents. ) Earthshine 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. 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