Leaderboard
Popular Content
Showing content with the highest reputation on 12/12/2013 in all areas
-
In Defence of Magic Numbers
toasterking and 2 others reacted to trancexx for a topic
No way. ...that's magic number too, but the value should be 2.3 points -
Automate all windows and browser applications with one UDF function library. Based on the microsoft automation API this library high level supports Recognition of conttrols from EDGE, Chrome, FF, Opera, Safari and Windows native apps Small testing framework to split object repository from coding away Introduction Quickstart - Getting started quickly Simple scripts With this module you can automate all applications/programs that support ui automation and/or accesibility api from microsoft you can recognize more controls than AutoIT can recognize "out of the box" you can use concepts from other testing frameworks like http://download.freedesktop.org/ldtp/doc/ldtp-tutorial.pdf http://safsdev.sourceforge.net/Default.htm coded ui testing from microsoft Some of those controls / applications are chrome browser (partly mainwindow has to be done with MSAA for navigating) chrome://accessibility in the adress bar of chrome or start with "--force-renderer-accessibility" silverlight controls Ribbon control controlbars of Excel/Word IE and FF browsers Windows Media Player Windows clock AFX .. controls (partly) .... Based on the initial AIO Object I now have made the interface file to work with objCreateInterface function which is in the latest beta's automate clicking and querying basic information It gives you a lot of basic information to be able to automate clicking, querying basic information where it goes further in certain situations than AutoIt is identifying Starting threads for background on the ui automation api of microsoft (not for starters) http://en.wikipedia.org/wiki/Microsoft_UI_Automation http://msdn.microsoft.com/en-us/library/ms747327.aspx Previous threads in general help/support Interface AutoItObject IUIAutomation ObjCreateInterface and struct tagPoint in method ElementFromPoint Be aware that API is not allways installed under XP/Vista see http://support.microsoft.com/kb/971513 Within Windows 7 and Windows 8 it should be preinstalled by default. Be aware on 32 and 64 bits way of running your script #AutoIt3Wrapper_UseX64=Y or N Basic example of usage / showing and retrieving the default information, will post multiple examples later Hover your mouse to an area of interest and press ctrl+w and information will be shown in the edit box of the form Simple spy demo (see simplespy.au3 or use latest ZIP attachment for latest version) Main features Recognize windows and html controls for the major browsers Logical and physical description for controls (UI mapping, Application map) Simple repository logic to abstract logical and physical descriptions Store Runtime Type Information in RTI. variables Rubberbanding/highlighting of objects Simple spy to help in making / identifying the physical description Support of regular expression(s) in identifying objects recognize objects on multiple properties supported properties: name ,title, automationid, classname, class, iaccessiblevalue, iaccessiblechildId, controltype, processid, acceleratorkey The actions provided so far "leftclick", "left", "click", "leftdoubleclick", "leftdouble", "doubleclick", _ "rightclick", "right", "rightdoubleclick", "rightdouble", _ "middleclick", "middle", "middledoubleclick", "middledouble", "mousemove", "movemouse" "setvalue","settextvalue" "setvalue using keys" "setValue using clipboard" "getvalue" "sendkeys", "enterstring", "type", "typetext" "invoke" "focus", "setfocus", "activate" "close" "move","setposition" "resize" "minimize", "maximize", "normal", "close", "exist", "exists" "searchcontext", "context" "highlight" "getobject","object" "attach" "capture","screenshot", "takescreenshot" "dump", "dumpthemall" "propertyvalue", "property" match on multiple properties like: name:=((Zoeken.*)|(Find.*)); ControlType:=Button; acceleratorkey:=Ctrl+F Support for 117 different properties see $UIA_propertiesSupportedArray in uiawrappers like for example title, regexptitle, class, regexpclass, iaccessiblevalue, iaccessiblechildid, name, accesskey, automationid, classname IAccessible, IAccessible2, ISimpleDom interfaces debuglogging to a file log.txt (no output in scitewindow) Examples Example 1 Iterating thru the different ways of representing the objects in the tree (#comment-1105548) Example 2 Finding the taskbar and clicking on the start menu button (#comment-1105680) Example 3 Clicking a litlle more and in the end displaying all items from the clock (thats not directly possible with AU3Info) (#comment-1108849) Example 4 that demonstrates the calculator Example 5 Automating chrome Example 6 Demonstrates all stuff within chrome to navigate html pages, find hyperlink, click hyperlink, find picture, click picture, enter data in inputbox Example 7 The chrome example modified to a firefox example Example 8 The other major browser Internet Explorer automated (made on Example 6 and 7) Example 9 Windows media player Example 10 Automating mach 3 (AFX windows and other hard to get recognized by AutoIT) Lot of links are broken due to forum upgrade just search for the text like "Example 11 Demonstrate Word, Notepad and Calculator actions" Example 11 Demonstrate Word, Notepad and Calculator actions ... Example 13 Details 1 about the right pane of the windows explorer Example 14 Details 2 about the right pane of the windows explorer Example 15 Details 3 about the right pane of the windows explorer Example 16 Details 4 about the right pane of the windows explorer Example 17 Details 5 about the right pane of the windows explorer WITH CACHING Example 18 Details 6 about the right pane of the windows explorer WITH VIRTUAL ITEMS Example 19 Eventhandling examples Example 20 Eventhandling examples Example 21a Eventhandling examples Internet Explorer Example 21b Eventhandling examples Internet Explorer Example 22 Eventhandling examples Follow focus Example 23 Eventhandling examples structure changed Example 24 Eventhandling examples IUIAutomationEventHandler Example 25 SAFEARRAYS Example 26 IACCESSIBLE / MSAA Example 27 IACCESSIBLE2 / MSAA Example 28 IACCESSIBLE / MSAA events Example 29 IACCESSIBLE2 events Example 30 ISimpleDOM Example 31 Notepad window move, maximize, minimize Example 32 Three browsers doing the same stuff with small differences in scripting only .. TODO Build recorder Enhance the spy with a nicer UI UI for the repository (now in the script with dot notation) Enhance mapping / identifying on multiple properties instead of 1 combined with index If speed becomes an issue use the caching logic of the MS UIA framework Add the other patterns later Generalize the concept of System Under Test of starting the SUT (for testing framework purposes) Remote running of scripts Fix issue on finding within dynamic context ... edit august 18th 2013 initial post Only zip files are needed to download , just unzip in 1 directory edit july 2016 Made V0_63 and examples works with AutoIt v3.3.14 Windows 10 tested Simple spy gives some basic code as a present Chrome latest versions seems to be having issues with IUIAutomation on tabs/buttons of mainwindow use MSAA for accessing tabsheets / buttons more cleanup to be in UDF style More comments in the source see changelog.txt for previous changes edit september 2017 All examples fixed for the IE, Firefox and Chrome browser Some small but essential fixes in UIAWrappers edit april 2018 Enhanced logic on fallback / dynamic search, still not perfect, to slow Retested with latest Chrome, FF, Edge and IE11 and some extensions to show how to get text from the webpage (examples 5,6,7) Some small bugfixes Some comments as given in forum incorporated edit may 2019 Speed enhancements on especially fallback searching UIA.CFG works now in a better way to turn on/off debug, highlighting, debug2file More stable and consistent behavior Internal cleanup and refactoring of bigger functions Checked with W10 (not tested on W7) Added some W10 properties Run with 3.3.14.5 on W10 UIA_V0_51.zip EXAMPLES_V0_5.zip UIA_V0_63.zip EXAMPLES_V0_63.zip UIA_V0_64.zip EXAMPLES_V0_64.zip EXAMPLES_V0_66.zip UIA_V0_66.zip EXAMPLES_V0_70.zip UIA_V0_70.zip1 point
-
That's called a CLSID and there are several of them for certain folders that can be used in the File* functions in AutoIt and Windows. There's a list in the help file under the appendix.1 point
-
FileCreateShortcut("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", @DesktopDir & "\My Computer")1 point
-
Did you know you can create excel spread sheets without excel installed? You won't be able to view them, but just throwing that out there. I have a sample in my sig, and pleanty more are out there. So if you farm out work, as long as the end results of the logging are on a station with excel, there is no need to differentiate with what app to create the logging.1 point
-
A comparison of methods...
Wombat reacted to JLogan3o13 for a topic
I tend to favor a mix of approaches, just because I have seen the volume of crap that can be left behind in the registry should the person have had MS Office at one time and then uninstalled. You might combine a look in the registry's Uninstall key, a look under the Explorer key for a specific extension to see what it is set to open with (is .doc set to open with MSWord or the LibreOffice equiv. for example), and then I might do something like this to grab from WMI. You could easily change the msgbox into an "If MS Office Then..." statement: $WMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2") $aItems = $WMI.ExecQuery("SELECT * FROM Win32_Product") For $element In $aItems MsgBox(0, "", $element.Name) Next1 point -
I have interpretated the above as you wanting to have this returned. 3022 5 3023 5 3024 5 3025 5 3026 5 3027 5 3028 5 3029 5 3030 5 3031 5 And this example returns the above from the posted testinputfile.txt file. Local $file = "testinputfile.txt" ; This .txt file is in same directory as this .au3 script. Otherwise, use full path .txt filename. Local $sFileContents = FileRead($file) Local $sOutput = "" Local $sFirstLine, $iNum While $sFileContents <> "" ; Next 2 command lines assume the newline characters used in the file is @LF only. Sometimes @CRLF is used. ; Therefore, @CRLF is to replace @LF in the commands in these following 2 lines. ;$sFirstLine = StringMid($sFileContents, 1, StringInStr($sFileContents, @LF) - 1) ; First line in string. ;$sFileContents = StringReplace($sFileContents, $sFirstLine & @LF, "") ; Deletes all occurrences of first line in string. ; --- Use either above 2 lines, Or, use next 2 lines ----- $sFirstLine = StringRegExpReplace($sFileContents, "(?s)^(\V+).*$", "\1") ; First line in string. $sFileContents = StringRegExpReplace($sFileContents, $sFirstLine & "\v*", "") ; Deletes all occurrences of first line in string. $iNum = @extended ; Number of replacements in above StringRegExpReplace command. $sOutput &= $sFirstLine & " " & $iNum & @LF WEnd ConsoleWrite($sOutput & @LF) ; Or write $sOutput to a file if needed.1 point
-
Meh, for styles and things like that there is pretty much no chance of them ever changing, so go for it and it's not too bad. Magic numbers should be avoided like the plague as soon as it gets into things that could possibly change in the future. So things like using hard coded constants for the size of data types for example. If it's a number of your own devising then also avoid magic numbers, so if your program accepts a password that should be a minimum of 6 characters it's very important you don't just use the number 6. As the code grows you'll be using the same value in lots of places, and you get a mess. Guinness and myself have said many times that in your personal code you do what you want and we won't judge you. For code that has to be maintained by others, or code that will be used by less experienced programmers for learning from, use the constants. And finally, all of your arguments are very good reasons for using a lower level compiled language. So the question remains, why use AutoIt?1 point
-
Ah okay. (Edit - I thought you meant something else). I no longer use Dim and I wasn't aware it had this property.1 point
-
It's straight from the help file. By adding the slight effort of declaring scope, you can save tons of debugging issues in the long run...this is the only point I'm trying to make: By default when variables are declared using Dim or assigned in a function they have Local scope unless there is a global variable of the same name (in which case the global variable is reused). This can be altered by using the Local and Global keywords to declare variables and force the scope you want.1 point
-
esahtar90, As a new user it is beneficial to understand what went wrong with the code you are having a problem with. _FileWriteToLine expects a file name, you gave it a file handle. So let's change you code as follows: #include <File.au3> ;-------------------------------------------------------------------------------- ; create test file filecopy(@scriptdir & '\testinputfile.txt',@scriptdir & '\testinputfile2.txt',1) ;-------------------------------------------------------------------------------- Global $count = 0 $file = @scriptdir & "\testinputfile2.txt" $po_number = FileReadLine($file, 1) $file_count = _FileCountLines($file) For $i = 1 To $file_count $line = FileReadLine($file, $i) If StringInStr($po_number, $line) > 0 Then if _FileWriteToLine($file, $i, "", 1) <> 1 Then ConsoleWrite(@error & @LF) ; added an error check with console output $count += 1 Else ExitLoop EndIf Next MsgBox(0, "Information:", "Count is " & $count & " PO number " & $po_number) If you run this it will return "Count is 3 PO number is 3022". The output file is left with two lines of 3022. This is because you are deleting the line that matches your number with _FileWriteToLine($file, $i, "", 1) while using an increment variable to read the file line by line. 1ST read in loop - file has 5 lines = 3022 2ND read in loop - file has 4 lines = 3022 and you start testing at line 2 skipping line 1 (which is 3022) 3RD read in loop - file has 3 lines = 3022 skipping line 1 and 2... Not only is this a logical error but it is terribly inefficient (see HELP file doc for FileReadLine). Let's say that we change the _FileWriteLine to _FileWriteToLine($file, $i, " ", 1) to write a blank space rather than delete the line. Now the message is "Count is 5 PO number is 3022" and there are 5 blank lines in the output file (as we expect). Probably not what you want but logically correct. Given all of the above it is better to read the file to either a string or an array, process the string/array and write the file back from the string/array. A couple of examples of this have been posted in previous replies. I hope this helps. Right now your best friend is the HELP file. kylomas edit: spelling1 point
-
File Name: AutoIt v3.3.9.23 Beta File Submitter: Jon File Submitted: 28 Nov 2013 File Category: Beta 3.3.9.23 (28th November, 2013) (Beta) AutoIt: - Fixed #2518: Static keyword not working correctly. - Fixed #2541: Accessing object methods or properties on a non-object when error handler is installed. - Fixed: StringStripCR() and StringAddCR() not working with strings that contain nulls. UDFs: - Changed: $INTERNET_FLAG_NO_CACHE_WRITE default value for _FTP_ListToArray*(). - Added #2540: _ArrayDisplay() can copy Header and Row. - Added: _GDIPlusTextureCreateIA(). - Fixed #2539: _ArrayUnique() doc precision. - Fixed #2521: Removed _IEFormElementSetValue[5].au3 example. - Fixed: _SQLite_...() running in X64 Mode. - Fixed: _SQLite_Startup() parameter checking and doc. AutoIt3Help: - Changed: Version number to 1.0.0.5. - Fixed #2519: Wrong page opening if launch without parameter. Click here to download this file1 point