Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/13/2022 in all areas

  1. Hello guys. I recently saw some posts that Windows 10 provides OCR API. So I decided to create a UDF. What's UWPOCR? UWPOCR UDF is a simple library to use Universal Windows Platform Optical character recognition API. Features. Get Text From Image File. Get Text From GDI+ Bitmap. Easy to use. Usage: #include "..\UWPOCR.au3" _Example() Func _Example() Local $sOCRTextResult = _UWPOCR_GetText(FileOpenDialog("Select Image", @ScriptDir & "\", "Images (*.jpg;*.bmp;*.png;*.tif;*.gif)")) MsgBox(0,"",$sOCRTextResult) EndFunc Get Words Rect(Example): More examples here. Check UWPOCR UDF on GitHub. Saludos
    3 points
  2. I've ported some of the JavaScript 140 Bytes demos from dwitter.net to FreeBasic. Download AiO with 1000 examples (7-Zip archive): The beauty - magic of math Vol. 1 - 23 build 2024-01-14.7z (5.09 mb with source code and Windows x64 compiled executables) or have a look to my 1drive folder: _dwitter.net Some screenshots: ... Autoit is too slow for almost all of these examples. Happy watching.
    1 point
  3. This forum (Au3 Technical) is inhabited by luminaries whose posts frequently demonstrate understanding far beyond my capabilities. For that reason, and at Jon's suggestion, I am reaching out to tap into your wisdom for a project that I have been working on a for a while. I was looking for a way to give back to AutoIt. As a self-taught programmer I have learned an incredible amount from this forum and the help file. It has been very rewarding. Over the course of my personal experiences I have wished, at times, that even though the materials and support are truly incredible - that someone could explain some of the more basic concepts. At the same time, I saw the creation of code.org and I started to think that AutoIt would be a perfect learning tool for people starting out (because of the simplicity, the incredible help file, and the best forum I have ever seen). All of that led to the creation of this text: https://www.autoitscript.com/forum/files/file/351-learn-to-program-using-free-tools-with-autoit/. It is the first draft of a basic introduction to programming using AutoIt. Nobody has reviewed it. Accordingly, I seek the collective constructive feedback of anyone willing to offer opinion as to content, spot any errors, and make any suggestions to improve it. My goal was always to donate it to the AutoIt forum when it was done. I think it could be a good addition to fill the gap for neophytes who may crave to see how everything fits together. The last thought I will leave you with - similar to the first - is that I am not the world's greatest coder (this may be a case of those who can do and those who can't teach). That said, I am hoping that the issues you will undoubtedly spot are not huge or threatening to the overall effort and that you appreciate the fact that this took some time to pull together. I look forward to hearing your thoughts.
    1 point
  4. Hmm, what game is this for ?
    1 point
  5. Here you have the findthemall function which you can tweak to get more/less properties printed. Below example just dumps name and class you can just extend this line with your properites ConsoleWrite( "Title is: " & _UIA_getPropertyValue($oUIElement, $UIA_NamePropertyId) & @TAB & "Class=" & _UIA_getPropertyValue($oUIElement, $uia_classnamepropertyid) & @TAB & "Value=" & _UIA_getPropertyValue($oUIElement, $UIA_ValueValuePropertyId) & @TAB & "Accessible name=" & _UIA_getPropertyValue($oUIElement, $UIA_LegacyIAccessibleNamePropertyId) & @TAB & "Accessible value=" & _UIA_getPropertyValue($oUIElement, $UIA_LegacyIAccessibleValuePropertyId) & @TAB & @CRLF) With UIA_DumpThemAll you get all properties which is overkill so you have to tweak When the class or controltype is different it could be you have to look for other properties to get the text thats relevant for you Func findThemAll($oElementStart, $TreeScope) Local $hTimer = TimerInit() ;~ Get result with findall function alternative could be the treewalker Dim $pCondition, $pTrueCondition Dim $pElements, $iLength $UIA_oUIAutomation.CreateTrueCondition($pTrueCondition) $oCondition = ObjCreateInterface($pTrueCondition, $sIID_IUIAutomationCondition, $dtagIUIAutomationCondition) ;~ $oCondition1 = _AutoItObject_WrapperCreate($aCall[1], $dtagIUIAutomationCondition) ;~ Tricky to search all descendants on html objects or from desktop/root element $oElementStart.FindAll($TreeScope, $oCondition, $pElements) $oAutomationElementArray = ObjCreateInterface($pElements, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray) $oAutomationElementArray.Length($iLength) For $i = 0 To $iLength - 1; it's zero based $oAutomationElementArray.GetElement($i, $UIA_pUIElement) $oUIElement = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) ConsoleWrite("Title is: " & _UIA_getPropertyValue($oUIElement, $UIA_NamePropertyId) & @TAB & "Class=" & _UIA_getPropertyValue($oUIElement, $uia_classnamepropertyid) & @CRLF) ;~ if _UIA_getPropertyValue($oUIElement, $UIA_NamePropertyId)="<your object of interest name>" then ;~ $t = StringSplit(_UIA_getPropertyValue($oUIElement, $UIA_BoundingRectanglePropertyId), ";") ;~ _UIA_DrawRect($t[1], $t[3] + $t[1], $t[2], $t[4] + $t[2]) ;~ consolewrite(_UIA_getAllPropertyValues($UIA_oUIElement) & @CRLF) ;~ endif Next Local $fDiff = TimerDiff($hTimer) Consolewrite("Findthemall took: " & $fDiff & " milliseconds" & @CRLF & @CRLF) EndFunc ;==>findThemAll
    1 point
  6. $PropertyConditionFlags_MatchSubstring It's true that wildcards aren't supported. On the other hand, it's possible to search for substrings in string properties through the Windows 10 1809 update: ; enum PropertyConditionFlags Global Const $PropertyConditionFlags_None = 0 Global Const $PropertyConditionFlags_IgnoreCase = 1 Global Const $PropertyConditionFlags_MatchSubstring = 2 ; Windows 10-1809 To use the $PropertyConditionFlags_MatchSubstring constant, it's necessary to use a version of the UIA code that includes this Windows update. To do this, select the correct Windows Mode in UIASpy: Now the code generated automatically by UIASpy will look like this: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=n ; If target application is running as 32 bit code ;#AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code #include "UIA_Constants.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_SafeArray.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_Variant.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation6, $dtag_IUIAutomation6 ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) EndFunc ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Notepad", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Children, $pCondition0, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Element Properties --- ConsoleWrite( "--- Element Properties ---" & @CRLF ) Local $sName1 $oWindow1.GetCurrentPropertyValue( $UIA_NamePropertyId, $sName1 ) ConsoleWrite( "$sName1 = " & $sName1 & @CRLF ) In UIASpy, you generate the above code as follows: Sample code menu | Initial code | Complete code Click Notepad window in treeview to switch to info listview Right-click the $UIA_ClassNamePropertyId line | Create sample code Sample code menu | Properties ... | Right-click the $UIA_NamePropertyId line | Create sample code Right click code listview | Copy all items Paste the code into your editor Edit the code to make it runnable. And replace CreatePropertyCondition() with CreatePropertyConditionEx() to apply PropertyConditionFlags: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=n ; If target application is running as 32 bit code ;#AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code #include "UIA_Constants.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_SafeArray.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_Variant.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation6, $dtag_IUIAutomation6 ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0 ;$oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Notepad", $pCondition0 ) $oUIAutomation.CreatePropertyConditionEx( $UIA_ClassNamePropertyId, "Note", $PropertyConditionFlags_MatchSubstring, $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Children, $pCondition0, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Element Properties --- ConsoleWrite( "--- Element Properties ---" & @CRLF ) Local $sName1 $oWindow1.GetCurrentPropertyValue( $UIA_NamePropertyId, $sName1 ) ConsoleWrite( "$sName1 = " & $sName1 & @CRLF ) EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pCondition0 OK $oWindow1 OK --- Element Properties --- $sName1 = Untitled - Notepad Example 16 Example 16 includes the original CUIAutomation2.au3 created by junkew, which contains all the Windows 7 constants. In newer versions of the UIA code I use UIA_Constants.au3 which contains all Windows 7 constants as well as all constants added in Windows 8, 8.1 and 10. The reason for the error in your code is that both CUIAutomation2.au3 and UIA_Constants.au3 is included. Only UIA_Constants.au3 should be included. Example 16 is an old example from March 9, 2019. Unfortunately, it's not possible for me to update all examples every time I update the UIA code. And the Windows 7 code still works, unless you need the newer code added in later Windows versions. To close a window with UIA code, use the Close method of the IUIAutomationWindowPattern interface. See examples 2 and 3 in Patterns (actions). Note that these are also old examples from March 9, 2019. If the Close method doesn't work, you can e.g. try using the UIA_MouseClick() function, which almost always works. UIA_MouseClick() is found in two different UDFs: UIA_Functions.au3, which is the new version based on UIA_Constants.au3, and UIA_Functions-a.au3, which is the old version based on CUIAutomation2.au3. Use the new version. An obvious error in your code is that you use the UIA_MouseClick() function with a pattern (action) object as input parameter. The correct input parameter is a window or control (a UIA element) object. Only UIA elements can be clicked. Not patterns (actions).
    1 point
  7. You need UI Automation code to automate such a window
    1 point
  8. Gianni

    String to 2D array

    or even this (copy your data to the clipboard before run this listing) #include <array.au3> ; just to show result Local $aArray1 = StringSplit(StringStripCR(ClipGet()), @LF), $aArray2, $aResult[$aArray1[0]][1] For $i = 1 To $aArray1[0] $aArray2 = StringSplit($aArray1[$i], @TAB) If $aArray2[0] > UBound($aResult, 2) Then ReDim $aResult[$aArray1[0]][$aArray2[0]] For $i2 = 1 To $aArray2[0] $aResult[$i-1][$i2-1] = $aArray2[$i2] Next Next _ArrayDisplay($aResult) edit: skin as Function #include <array.au3> ; just to show result ; $sMyVar = ClipGet() ; from Clipboard to a variable _ArrayDisplay(_VarTo2D($sMyVar)) ; Func _VarTo2D($var, $sSeparator = @TAB) Local $aRows = StringSplit(StringStripCR($var), @LF), $aColumns, $aResult[$aRows[0]][1] For $iRow = 1 To $aRows[0] $aColumns = StringSplit($aRows[$iRow], $sSeparator) If $aColumns[0] > UBound($aResult, 2) Then ReDim $aResult[$aRows[0]][$aColumns[0]] For $iColumn = 1 To $aColumns[0] $aResult[$iRow - 1][$iColumn - 1] = $aColumns[$iColumn] Next Next Return $aResult EndFunc ;==>_VarTo2D
    1 point
  9. funkey

    StringSplitToStruct

    I am always looking for the fastest way to put a lot of data into DLLs. My new try is with a small DLL to split a data string and get a pointer to the new data array. I hope this could be useful for someone else. Please tell me if there is a faster way to do this! Thanks! #AutoIt3Wrapper_UseX64=n ; Set the data Global $sData, $sDelim = ";" For $i = 1 To 43200 $sData &= Random(0, 100) & $sDelim Next $sData &= Random(0, 100) #region Float array to struct: Version 1 without DLL Global $iStart = TimerInit() Global $aData = StringSplit($sData, $sDelim, 2) Global $tData = DllStructCreate("float[" & UBound($aData) & "]") For $i = 0 To UBound($aData) - 1 DllStructSetData($tData, 1, $aData[$i], $i + 1) Next ConsoleWrite("Version 1 lasts: " & TimerDiff($iStart) & " ms" & @CRLF) ConsoleWrite("First: " & DllStructGetData($tData, 1, 1) & @CRLF) ConsoleWrite("Last : " & DllStructGetData($tData, 1, UBound($aData)) & @CRLF) $tData = 0 #endregion Float array to struct: Version 1 without DLL ConsoleWrite(@CRLF) #region Float array to struct: Version 2 with DLL Global $sDLL_StringSplit = "StringSplitToStruct.dll" Global $hDLL_StringSplit = DllOpen($sDLL_StringSplit) Global $iStart = TimerInit() Global $iCount = 0 Global $tData2 = _StringSplitToStruct($sData, $sDelim, "float", $iCount) ConsoleWrite("Version 2 lasts: " & TimerDiff($iStart) & " ms" & @CRLF) ConsoleWrite("First: " & DllStructGetData($tData2, 1, 1) & @CRLF) ConsoleWrite("Last : " & DllStructGetData($tData2, 1, $iCount) & @CRLF) _StringSplitFree($tData2) DllClose($hDLL_StringSplit) #endregion Float array to struct: Version 2 with DLL Func _StringSplitToStruct($sString, $sDelim, $sType, ByRef $iCount) Local $aRet = DllCall($hDLL_StringSplit, "ptr:cdecl", "StringSplitToStruct", "str", $sString, "str", $sDelim, "str", $sType, "int*", $iCount) $iCount = $aRet[4] Local $tStruct = DllStructCreate($sType & "[" & $iCount & "]", $aRet[0]) Return $tStruct EndFunc ;==>_StringSplitToStruct Func _StringSplitFree(ByRef $tStruct) DllCall("msvcrt.dll", "none:cdecl", "free", "ptr", DllStructGetPtr($tStruct)) $tStruct = 0 EndFunc ;==>_StringSplitFree PVOID DLL_EXPORT StringSplitToStruct(LPSTR datastring, LPCSTR delim, LPCSTR type, int* iCount) { char* p; int i; if(*iCount == 0) { *iCount = 0; for(i = 0; datastring[i]; i++) { if(datastring[i] == delim[0]) { (*iCount)++; } } (*iCount)++; } i = 0; p = strtok(datastring, delim); if(stricmp(type, "float") == 0) { float* buffer = (float*)malloc(*iCount * sizeof(float)); while ((p != NULL) && (i < *iCount)) { buffer[i] = atof(p); p = strtok (NULL, delim); i++; } return buffer; } else if(stricmp(type, "int") == 0) { int* buffer = (int*)malloc(*iCount * sizeof(int)); while ((p != NULL) && (i < *iCount)) { buffer[i] = atoi(p); p = strtok (NULL, delim); i++; } return buffer; } return NULL; }StringSplitToStruct.rar
    1 point
×
×
  • Create New...