jcddcjjcd Posted January 23, 2012 Author Share Posted January 23, 2012 (edited) Thanks for adding the documentation Joe. I happened by here and was delighted to see your post. Regards, John. Edited January 23, 2012 by jcddcjjcd Link to comment Share on other sites More sharing options...
jcddcjjcd Posted January 23, 2012 Author Share Posted January 23, 2012 When you are developing an app using AnyCPU you need a way to provide the correct 32 for 64 bit implementation of AutoItX3. To do this I include both AutoItX3.dll and AutoItX3_x64.dll in the build but in AutoItX3Declarations I change all references to AutoItX3.dll to AutoItX3_targetted.dll Then in MainForm.Load I copy the AutoItX3.dll orAutoItX3_x64.dll to a new file called AutoItX3_targetted.dll based on whether we are running in 32 bit or 64 bit environment. Here is the code. //So that we can target 32 and 64bit system with AnyCPU we need to provide the correct AutoItX3 dll depending on platform. //We can't refference both of them. string ExecutingAssemblyPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string fullPath = ""; string newFilePath = Path.Combine(ExecutingAssemblyPath, "AutoItX3_targetted.dll"); if (IntPtr.Size == 4) { fullPath = Path.Combine(ExecutingAssemblyPath, "AutoItX3.dll"); } else { fullPath = Path.Combine(ExecutingAssemblyPath, "AutoItX3_x64.dll"); } if (System.IO.File.Exists(fullPath)) { try { System.IO.File.Copy(fullPath, newFilePath, true); } catch (Exception ex) { Logger.WriteLog("AutoItX3_targetted.dll Creation Failure!", ex); MessageBox.Show("AutoItX3_targetted.dll Creation Failure!rnApplicaction will Exit"); Application.Exit(); } } Regards, John. Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 24, 2012 Share Posted January 24, 2012 The correct solution to your bitness problem is actually to compile your .Net assembly for specifically 32 or 64 bit and do a standard link to the proper dll file. You should only compile for ANYCPU when you know you are only using pure .Net assemblies and no native code. Link to comment Share on other sites More sharing options...
jcddcjjcd Posted January 24, 2012 Author Share Posted January 24, 2012 That may be "correct" and I thank you for the comment but the other way works very nicely in my experience and suits a particular need. I am open to extended reasoning however. Regards, John. Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 24, 2012 Share Posted January 24, 2012 I saw an statement from Microsoft somewhere saying the same thing I said. I can't find it right now as I'm heading out the door to work. Link to comment Share on other sites More sharing options...
AC130 Posted January 24, 2012 Share Posted January 24, 2012 How can I do this in vb.net. (Use AutoItX without registering) Link to comment Share on other sites More sharing options...
jcddcjjcd Posted February 14, 2012 Author Share Posted February 14, 2012 How can I do this in vb.net. (Use AutoItX without registering)I think that if you convert the declarations to vb using a free online conversion tool then it will be no different from using it in C#.Convert one declaration first to see if it works then you will know.Please let us know how you get on.Regards,John. Link to comment Share on other sites More sharing options...
thi Posted April 25, 2013 Share Posted April 25, 2013 If you want to avoid declaring StringBuilders in your main code and have it work more like the native AutoIt language you can add wrapper functions like this: static public string AU3_WinGetText(string Title, string Text) { StringBuilder OutText = new StringBuilder(65536); AutoItX.AU3_WinGetText(Title, Text, OutText, OutText.Capacity); return OutText.ToString(); } So your usage becomes: AutoItX.AU3_Run("notepad.exe", "", 1); AutoItX.AU3_WinWait("Untitled", "Something", 0); string WindowText = AutoItX.AU3_WinGetText("Untitled", ""); Console.WriteLine(WindowText); AutoItX.AU3_ProcessClose("notepad.exe"); Link to comment Share on other sites More sharing options...
Administrators Jon Posted August 23, 2013 Administrators Share Posted August 23, 2013 I'm updating AutoItX to include a DLLImport file and C# wrapper similar to that above and also a PowerShell CmdLet - so this should become much more fun soon Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
JohnOne Posted August 23, 2013 Share Posted August 23, 2013 I'm going to lie here and say that sounds great. Truth is I don't know what a dllimport file is or PowerShell CmdLet. Anyone care to elaborate? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
czardas Posted August 23, 2013 Share Posted August 23, 2013 It sounds great. jaberwacky 1 operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
JohnOne Posted August 23, 2013 Share Posted August 23, 2013 Is DLLImport file be the same as using it in C#? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Administrators Jon Posted August 24, 2013 Administrators Share Posted August 24, 2013 Yeah. I'm going to supply the C# file that contains all the required DllImports to use AutoItX3.dll in C# (someone posted a complete one in this thread). I'm also going add some wrapper functions around those so in C# you'll essentially only need this: using AutoIt; ... AutoItX.WinWaitActive("Some window"); AutoItX.Send("hello"); Part of that work also means it's fairly easy for me to make it available to PowerShell as a Cmdlet. Cmdlets are just standalone functions you can add to powershell. And then the equivalent will be: Import-Module .\AutoItX3_PS.dll Wait-WinActive -Title "some window" Send-Key -Key "Some keys" This is cool because you don't need admin rights to "register" the DLL which was a slight barrier when using the COM version to a lot of companies. Also Microsoft mandate that all the software they produce these days must have a PowerShell interface so a lot of companies are investing in it. It's an easy but effective way to allow some of the more important AutoIt features in those environments. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
guinness Posted August 24, 2013 Share Posted August 24, 2013 This is awesome, on the account I'm learning C#. Thanks. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JohnOne Posted August 24, 2013 Share Posted August 24, 2013 Ace. I did use this threads code when I first tried AutoItX in C#. Nice ideas, I'll have to look at powershell I don't even know what it is let alone know how to use it Are we likely to see any more native functions in dll after update? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Administrators Jon Posted August 24, 2013 Administrators Share Posted August 24, 2013 Are we likely to see any more native functions in dll after update? I imagine so. But I'm aiming it more at the sort of people who will use it in C# and PowerShell so I won't be added functions that are already very easy in those languages. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
iLuvAutolt Posted August 28, 2013 Share Posted August 28, 2013 Hi, Please correct me if my under standing is wrong. To use the Autolt in C# code I need to: 1. Make a class library AutoItX3Declarations.cs that converts the native Autolt.dll to the .NET .dll (Question: since my machine is x64 and i use x64 compile i should import the x64 Autolt DLLs? or it doesnt really matter.) 2. Make another class library 'AutootxTest' which is a wrapper class for the classes in AutoItX3Declarations.cs 3. Make use of Methods of the wrapper class 'AutootxTest' in the c# code to access the native Autolt functions. Link to comment Share on other sites More sharing options...
Administrators Jon Posted August 28, 2013 Administrators Share Posted August 28, 2013 Check out the beta download, I've been doing a lot of work on providing the DLLimport class and wrappers. Unfortunately it's nowhere near finished yet as I've only recently starting fixing it up. But it will show you how I've been handling the x86/x64 thing and also adding c# friendly wrappers for the DLLImport functions. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
iLuvAutolt Posted August 29, 2013 Share Posted August 29, 2013 I was able to run a C# progam by c&p the Autilt declration libray to my project as someone had suggested. It complains about some function as not being overloaded but the same overloaded functions work in the Autolt script editor. Anyways, this a good start. Thank u all for providing helpful information in various posts. Can't wait for the final DLL that can be directly used in the c#. Link to comment Share on other sites More sharing options...
GregH Posted September 25, 2013 Share Posted September 25, 2013 The ControlGetText returns void. I tried changing it to return string, but am not sure of the last 2 parameters needed. Could you show an example of getting the text from a combobox for me? 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