Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/10/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. Danyfirex

    Sort question in C++

    Change your compare function to: int compare(const void *x, const void *y) { double xx = *(double*)x, yy = *(double*)y; if (xx < yy) return -1; if (xx > yy) return 1; return 0; } Saludos
    2 points
  3. For the fun #Include <Array.au3> $txt = "Objects (id: bounding-box centroid area mean-color):" & @crlf & _ " 0: 280x80+0+0 140.8,39.4 20069 gray(0)" & @crlf & _ " 4: 25x27+136+26 148.4,38.9 342 gray(255)" & @crlf & _ " 5: 25x26+34+27 48.9,39.9 307 gray(255)" & @crlf & _ " " & @crlf & _ " 6: 26x25+65+27 77.5,39.3 292 gray(255)" & @crlf & _ " 11: 33x18+211+34 227.7,41.3 289 gray(255)" & @crlf & _ " 9: 23x26+111+34 122.1,44.3 254 gray(255)" & @crlf & _ "" & @crlf & _ " 7: 16x19+70+30 77.8,39.0 219 gray(0)" & @crlf & _ " 2: 25x27+163+25 172.0,36.5 199 gray(255)" & @crlf & _ " 10: 20x18+187+34 197.2,41.6 179 gray(255)" & @crlf & _ " 3: 15x26+95+26 101.2,37.1 153 gray(255)" & @crlf & _ " 13: 11x11+116+37 121.1,42.2 97 gray(0)" $txt = StringRegExpReplace($txt, '(^.+\R)|(?m)^(\s*\R)|(.*gray\(0\)\R?)', "") $stmp = Execute("'" & StringRegExpReplace($txt, "(?m)(^.*?)(?<=\h)(\d+)(?=\.)", "' & StringFormat('%04i', '$2') & ' $1$2' & '") & "'") $atmp = StringRegExp($stmp, '\N+', 3) _ArraySort($atmp, 1) $res = StringRegExpReplace(_ArrayToString($atmp, @crlf), '(?m)^\d{4}\h*', "") Msgbox(0,"", $res)
    2 points
  4. Recently somebody asked how it could possible to manage the new feature of Virtual Desktop under Windows 10. With the incentive of @KaFu I started to get something together that could be useful. Since this code was never released under AutoIt, I felt it could serve as a good example. Let me know what you think. Version 2021-09-19 * Added support to IApplicationView and IVirtualDesktopPinnedApps interfaces (see example 2) Example 1. The documented interface of IVirtualDesktopManager offers a very limited list of methods. Someone may ask WTF is it useful for ? Well, I don't have an answer for that. #include <Constants.au3> #include <GUIConstants.au3> If @OSVersion <> "WIN_10" Then Exit MsgBox($MB_SYSTEMMODAL, "", "This script only runs on Win 10") ; VirtualDesktopManager object Local $CLSID_VirtualDesktopManager = "{aa509086-5ca9-4c25-8f95-589d3c07b48a}" Local $IID_IVirtualDesktopManager = "{a5cd92ff-29be-454c-8d04-d82879fb3f1b}" Local $tagIVirtualDesktopManager = _ "IsWindowOnCurrentVirtualDesktop hresult(hwnd;bool*);" & _ "GetWindowDesktopId hresult(hwnd;clsid*);" & _ "MoveWindowToDesktop hresult(hwnd;clsid);" ; object creation Local $oVDM = ObjCreateInterface($CLSID_VirtualDesktopManager, $IID_IVirtualDesktopManager, $tagIVirtualDesktopManager) ConsoleWrite(IsObj($oVDM) & @CRLF) ; create process owned window Local $hWnd = GUICreate("Test"), $bActive GUISetState() ; check if window is on current desktop (not mandatory to own the window) Local $iHresult = $oVDM.IsWindowOnCurrentVirtualDesktop($hWnd, $bActive) ConsoleWrite($iHresult & "/" & $bActive & @CRLF) ; returns the CLSID of the desktop where the window resides Local $sCLSID $iHresult = $oVDM.GetWindowDesktopId($hWnd, $sCLSID) ConsoleWrite($iHresult & "/" & $sCLSID & @CRLF) Local $hNote = WinGetHandle("[CLASS:Notepad]") $iHresult = $oVDM.GetWindowDesktopId($hNote, $sCLSID) ; (not mandatory to own the window) ConsoleWrite($iHresult & "/" & $sCLSID & @CRLF) ; moves the window to a specific desktop (mandatory to own the window) $iHresult = $oVDM.MoveWindowToDesktop($hWnd, $sCLSID) ConsoleWrite($iHresult & @CRLF) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd To perform this example you need to work a bit. Create a second Desktop, start Notepad, go back to the first, and run this script: the GUI window will be transferred from the first desktop to the second. Warning : you cannot use this method if you do not own the window (process-wise). Example 2 : The "undocumented" interface of IVirtualDesktopManagerInternal has a lot more methods and resolves all the requests someone could have using Virtual Desktops. #include <Constants.au3> Opt("MustDeclareVars", True) If @OSVersion <> "WIN_10" Then Exit MsgBox($MB_SYSTEMMODAL, "", "This script only runs on Win 10") ; Instanciation objects Local $CLSID_ImmersiveShell = "{c2f03a33-21f5-47fa-b4bb-156362a2f239}" Local $IID_IUnknown = "{00000000-0000-0000-c000-000000000046}" Local $IID_IServiceProvider = "{6D5140C1-7436-11CE-8034-00AA006009FA}" Local $tIID_IServiceProvider = __uuidof($IID_IServiceProvider) Local $tagIServiceProvider = _ "QueryService hresult(struct*;struct*;ptr*);" ; VirtualDesktopManagerInternal object Const Enum $eLeftDirection = 3, $eRightDirection Local $CLSID_VirtualDesktopManagerInternal = "{C5E0CDCA-7B6E-41B2-9FC4-D93975CC467B}" Local $tCLSID_VirtualDesktopManagerInternal = __uuidof($CLSID_VirtualDesktopManagerInternal) Local $IID_IVirtualDesktopManagerInternal = "{F31574D6-B682-4CDC-BD56-1827860ABEC6}" Local $tIID_IVirtualDesktopManagerInternal = __uuidof($IID_IVirtualDesktopManagerInternal) Local $tagIVirtualDesktopManagerInternal = _ "GetCount hresult(int*);" & _ "MoveViewToDesktop hresult(ptr;ptr);" & _ "CanViewMoveDesktops hresult(ptr;bool*);" & _ "GetCurrentDesktop hresult(ptr*);" & _ "GetDesktops hresult(ptr*);" & _ "GetAdjacentDesktop hresult(ptr;int;ptr*);" & _ "SwitchDesktop hresult(ptr);" & _ "CreateDesktopW hresult(int*);" & _ "RemoveDesktop hresult(ptr;ptr);" & _ "FindDesktop hresult(struct*;ptr*);" ; ApplicationViewCollection object Local $CLSID_IApplicationViewCollection = "{1841C6D7-4F9D-42C0-AF41-8747538F10E5}" Local $tCLSID_IApplicationViewCollection = __uuidof($CLSID_IApplicationViewCollection) Local $IID_IApplicationViewCollection = "{1841C6D7-4F9D-42C0-AF41-8747538F10E5}" Local $tIID_IApplicationViewCollection = __uuidof($IID_IApplicationViewCollection) Local $tagIApplicationViewCollection = _ "GetViews hresult(struct*);" & _ "GetViewsByZOrder hresult(struct*);" & _ "GetViewsByAppUserModelId hresult(wstr;struct*);" & _ "GetViewForHwnd hresult(hwnd;ptr*);" & _ "GetViewForApplication hresult(ptr;ptr*);" & _ "GetViewForAppUserModelId hresult(wstr;int*);" & _ "GetViewInFocus hresult(ptr*);" ; ApplicationView object Local $IID_IApplicationView = "{372E1D3B-38D3-42E4-A15B-8AB2B178F513}" Local $tagIApplicationView = _ "GetIids hresult(ulong*;ptr*);" & _ "GetRuntimeClassName hresult(str*);" & _ "GetTrustLevel hresult(int*);" & _ "SetFocus hresult();" & _ "SwitchTo hresult();" & _ "TryInvokeBack hresult(ptr);" & _ "GetThumbnailWindow hresult(hwnd*);" & _ "GetMonitor hresult(ptr*);" & _ "GetVisibility hresult(int*);" & _ "SetCloak hresult(int;int);" & _ "GetPosition hresult(clsid;ptr*);" & _ "SetPosition hresult(ptr);" & _ "InsertAfterWindow hresult(hwnd);" & _ "GetExtendedFramePosition hresult(struct*);" & _ "GetAppUserModelId hresult(wstr*);" & _ "SetAppUserModelId hresult(wstr);" & _ "IsEqualByAppUserModelId hresult(wstr;int*);" & _ "GetViewState hresult(uint*);" & _ "SetViewState hresult(uint);" & _ "GetNeediness hresult(int*);" ; VirtualDesktopPinnedApps object Local $CLSID_VirtualDesktopPinnedApps = "{b5a399e7-1c87-46b8-88e9-fc5747b171bd}" Local $tCLSID_VirtualDesktopPinnedApps = __uuidof($CLSID_VirtualDesktopPinnedApps) Local $IID_IVirtualDesktopPinnedApps = "{4ce81583-1e4c-4632-a621-07a53543148f}" Local $tIID_IVirtualDesktopPinnedApps = __uuidof($IID_IVirtualDesktopPinnedApps) Local $tagIVirtualDesktopPinnedApps = _ "IsAppIdPinned hresult(wstr;bool*);" & _ "PinAppID hresult(wstr);" & _ "UnpinAppID hresult(wstr);" & _ "IsViewPinned hresult(ptr;bool*);" & _ "PinView hresult(ptr);" & _ "UnpinView hresult(ptr);" ; Miscellaneous objects Local $IID_IObjectArray = "{92ca9dcd-5622-4bba-a805-5e9f541bd8c9}" Local $tagIObjectArray = _ "GetCount hresult(int*);" & _ "GetAt hresult(int;ptr;ptr*);" Local $IID_IVirtualDesktop = "{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4}" Local $tIID_IVirtualDesktop = __uuidof($IID_IVirtualDesktop) Local $tagIVirtualDesktop = _ "IsViewVisible hresult(ptr;bool*);" & _ "GetId hresult(clsid*);" ; objects creation Local $pService Local $oImmersiveShell = ObjCreateInterface($CLSID_ImmersiveShell, $IID_IUnknown, "") ConsoleWrite("Immersive shell = " & IsObj($oImmersiveShell) & @CRLF) $oImmersiveShell.QueryInterface($tIID_IServiceProvider, $pService) ConsoleWrite("Service pointer = " & $pService & @CRLF) Local $oService = ObjCreateInterface($pService, $IID_IServiceProvider, $tagIServiceProvider) ConsoleWrite("Service = " & IsObj($oService) & @CRLF) Local $pApplicationViewCollection, $pVirtualDesktopManagerInternal, $pVirtualDesktopPinnedApps $oService.QueryService($tCLSID_IApplicationViewCollection, $tIID_IApplicationViewCollection, $pApplicationViewCollection) ConsoleWrite("View collection pointer = " & $pApplicationViewCollection & @CRLF) Local $oApplicationViewCollection = ObjCreateInterface($pApplicationViewCollection, $IID_IApplicationViewCollection, $tagIApplicationViewCollection) ConsoleWrite("View collection = " & IsObj($oApplicationViewCollection) & @CRLF) $oService.QueryService($tCLSID_VirtualDesktopManagerInternal, $tIID_IVirtualDesktopManagerInternal, $pVirtualDesktopManagerInternal) ConsoleWrite("Virtual Desktop pointer = " & $pVirtualDesktopManagerInternal & @CRLF) Local $oVirtualDesktopManagerInternal = ObjCreateInterface($pVirtualDesktopManagerInternal, $IID_IVirtualDesktopManagerInternal, $tagIVirtualDesktopManagerInternal) ConsoleWrite("Virtual Desktop = " & IsObj($oVirtualDesktopManagerInternal) & @CRLF) $oService.QueryService($tCLSID_VirtualDesktopPinnedApps, $tIID_IVirtualDesktopPinnedApps, $pVirtualDesktopPinnedApps) ConsoleWrite("Virtual Desktop Pinned Apps = " & $pVirtualDesktopPinnedApps & @CRLF) Local $oVirtualDesktopPinnedApps = ObjCreateInterface($pVirtualDesktopPinnedApps, $IID_IVirtualDesktopPinnedApps, $tagIVirtualDesktopPinnedApps) ConsoleWrite("Virtual Desktop Pinned Apps = " & IsObj($oVirtualDesktopPinnedApps) & @CRLF) Local $iCount, $pCurrent, $pLeft, $pNew, $iHresult, $hWnd, $pView, $pArray, $pDesktop, $oArray, $oView, $sView, $bValue ; gives the number of virtual desktops $iHresult = $oVirtualDesktopManagerInternal.GetCount($iCount) ConsoleWrite("Number of Desktop = " & $iCount & "/" & $iHresult & @CRLF) If $iCount > 1 Then Exit MsgBox($MB_SYSTEMMODAL, "", "Please close all additional Virtual Desktops") ; creates a new virtual desktop $iHresult = $oVirtualDesktopManagerInternal.CreateDesktopW($pNew) ConsoleWrite("Create = " & $pNew & "/" & $iHresult & @CRLF) $iHresult = $oVirtualDesktopManagerInternal.SwitchDesktop($pNew) ConsoleWrite("Switch = " & $iHresult & @CRLF) Run("Notepad.exe") WinWait("[CLASS:Notepad]") ; enumerates all desktops $iHresult = $oVirtualDesktopManagerInternal.GetDesktops($pArray) $oArray = ObjCreateInterface($pArray, $IID_IObjectArray, $tagIObjectArray) ConsoleWrite("Array = " & IsObj($oArray) & @CRLF) $oArray.GetCount($iCount) ConsoleWrite("Count = " & $iCount & @CRLF) $oArray.GetAt(0, DllStructGetPtr($tIID_IVirtualDesktop), $pDesktop) ConsoleWrite("Desktop 0 = " & $pDesktop & @CRLF) $oArray.GetAt(1, DllStructGetPtr($tIID_IVirtualDesktop), $pCurrent) ConsoleWrite("Desktop 1 = " & $pCurrent & @CRLF) ; gives the current desktop id $iHresult = $oVirtualDesktopManagerInternal.GetCurrentDesktop($pCurrent) ConsoleWrite("Current = " & $pCurrent & "/" & $iHresult & @CRLF) ; returns the adjacent desktop id $iHresult = $oVirtualDesktopManagerInternal.GetAdjacentDesktop($pCurrent, $eLeftDirection, $pLeft) ConsoleWrite("Get Left = " & $pLeft & "/" & $iHresult & @CRLF) ; switches to a specific desktop MsgBox ($MB_SYSTEMMODAL,"","Now it will return to previous desktop") Sleep(500) ; gives time for the msg box to close $iHresult = $oVirtualDesktopManagerInternal.SwitchDesktop($pLeft) ConsoleWrite("Switch = " & $iHresult & @CRLF) ; get pointer to a view based on hwnd and create an application view $hWnd = WinGetHandle("[CLASS:Notepad]") $iHresult = $oApplicationViewCollection.GetViewForHwnd($hWnd, $pView) ConsoleWrite("View from handle = " & $pView & "/" & $iHresult & @CRLF) $oView = ObjCreateInterface($pView, $IID_IApplicationView, $tagIApplicationView) ConsoleWrite("Application view = " & IsObj($oView) & @CRLF) $iHresult = $oView.GetAppUserModelId($sView) ConsoleWrite("Get App ID = " & $sView & "/" & $iHresult & @CRLF) ; verify if app is pinned with ptr and string $iHresult = $oVirtualDesktopPinnedApps.IsViewPinned($pView, $bValue) ConsoleWrite("Is View Pinned = " & $bValue & "/" & $iHresult & @CRLF) $iHresult = $oVirtualDesktopPinnedApps.IsAppIdPinned($sView, $bValue) ConsoleWrite("Is AppId Pinned = " & $bValue & "/" & $iHresult & @CRLF) ; move application to a specific desktop $iHresult = $oVirtualDesktopManagerInternal.MoveViewToDesktop($pView, $pDesktop) ConsoleWrite("Move = " & $iHresult & @CRLF) Sleep(2000) ; deletes an existing desktop $iHresult = $oVirtualDesktopManagerInternal.RemoveDesktop($pNew, $pDesktop) ConsoleWrite("Delete = " & $iHresult & @CRLF) Func __uuidof($sGUID) Local $tGUID = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]") DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sGUID, "struct*", $tGUID) If @error Then Return SetError(@error, @extended, 0) Return $tGUID EndFunc ;==>__uuidof Enjoy.
    1 point
  5. MrKm

    OCRSpace UDF

    AutoIT-OCRSpace-UDF1.3.zip This tiny yet powerful UDF will help you to convert Images to text with the help of OCRSpace API version 3.50 . Detect text from a local file. ; ========================================================= ; Example 2 : Gets text from an image from a local path reference ; : Searchable PDF is not requested by default. ; : Processes it using a basic OCR logic. ; ========================================================= $b_Create_Searchable_PDF = True ; Use a table logic for receipt OCR $b_Table = True ; Set your key here. $v_OCRSpaceAPIKey = "" $OCROptions = _OCRSpace_SetUpOCR($v_OCRSpaceAPIKey, 1, $b_Table, True, "eng", True, Default, Default, $b_Create_Searchable_PDF) $sText_Detected = _OCRSpace_ImageGetText($OCROptions, @scriptdir & "\receipt.jpg", 0, "SEARCHABLE_URL") ConsoleWrite( _ " Detected text : " & $sText_Detected & @CRLF & _ " Error Returned : " & @error & @CRLF & _ " PDF URL : " & Eval("SEARCHABLE_URL") & @CRLF) Detect text from a URL reference. ; ========================================================= ; Example 1 : Gets text from an image using a url reference ; : Searchable PDF is not requested. ; : Processes it using a basic OCR logic. ; ========================================================= $v_OCRSpaceAPIKey = "" ; SetUp some preferences.. $OCROptions = _OCRSpace_SetUpOCR($v_OCRSpaceAPIKey, 1, False, True, "eng", True, Default, Default, False) ; Make the request.. $sText_Detected = _OCRSpace_ImageGetText($OCROptions, "https://i.imgur.com/vbYXwJm.png", 0) ConsoleWrite( _ " Detected text : " & $sText_Detected & @CRLF & _ " Error Returned : " & @error & @CRLF)   Detect text from a URL reference to an array #include "OCRSpaceUDF\_OCRSpace_UDF.au3" #include <array.au3> ; Set your key here. $v_OCRSpaceAPIKey = "" $OCROptions = _OCRSpace_SetUpOCR($v_OCRSpaceAPIKey, 1, $b_Table, True, "eng", True, Default, Default, False) ; Below, the return type is set to 1 to return an array containing the coordinates of the bounding boxes for each word detected, ; in the format : #WordDetected , #Left , #Top , 3Height, #Width $aText_Detected = _OCRSpace_ImageGetText($OCROptions, "https://i.imgur.com/Z1enogD.jpeg", 1) _ArrayDisplay($aText_Detected, "") Download Latest Version : https://github.com/MurageKabui/AutoIT-OCRSpace-UDF
    1 point
  6. Scratching my head for a while on: $stmp = Execute("'" & StringRegExpReplace($txt, "(?m)(^.*?)(?<=\h)(\d+)(?=\.)", "' & StringFormat('%04i', '$2') & ' $1$2' & '") & "'") But after a while I understood what was happening 😉 Depending on expressiveness, flexibility and further needs I would probably do this in powershell #$data=get-content result.txt -Encoding utf8 $data = @" Objects (id: bounding-box centroid area mean-color): 0: 280x80+0+0 140.8,39.4 20069 gray(0) 4: 25x27+136+26 148.4,38.9 342 gray(255) 5: 25x26+34+27 48.9,39.9 307 gray(255) 6: 26x25+65+27 77.5,39.3 292 gray(255) 11: 33x18+211+34 227.7,41.3 289 gray(255) 9: 23x26+111+34 122.1,44.3 254 gray(255) 7: 16x19+70+30 77.8,39.0 219 gray(0) 2: 25x27+163+25 172.0,36.5 199 gray(255) 10: 20x18+187+34 197.2,41.6 179 gray(255) 3: 15x26+95+26 101.2,37.1 153 gray(255) 13: 11x11+116+37 121.1,42.2 97 gray(0) "@ $MyArrayList = [System.Collections.ArrayList]@() #Lets first split it $datalines=$data -split "`r`n" #Create the arraylist foreach($dataline in $datalines) { $tline =$dataline.trimstart() $dataColumns=$tline.split(" ,") $MyArrayList.add([pscustomobject]@{ "dataline" = $dataLine "id" = $datacolumns[0] "boundingbox" = $datacolumns[1] "centroid a" = [double]$datacolumns[2] "centroid b" = [double]$datacolumns[3] "area" = $datacolumns[4] "meancolor" = $datacolumns[5] }) } #Format, sort, filter, reshuffle $myArraylist | format-table -autosize $myArraylist | where meancolor -notin @('gray(0)','mean-color)') | sort "centroid a" -Descending | select dataline Output dataline id boundingbox centroid a centroid b area meancolor -------- -- ----------- ---------- ---------- ---- --------- 0: 280x80+0+0 140.8,39.4 20069 gray(0) 0: 280x80+0+0 140,8 39,4 20069 gray(0) 4: 25x27+136+26 148.4,38.9 342 gray(255) 4: 25x27+136+26 148,4 38,9 342 gray(255) 5: 25x26+34+27 48.9,39.9 307 gray(255) 5: 25x26+34+27 48,9 39,9 307 gray(255) 6: 26x25+65+27 77.5,39.3 292 gray(255) 6: 26x25+65+27 77,5 39,3 292 gray(255) 11: 33x18+211+34 227.7,41.3 289 gray(255) 11: 33x18+211+34 227,7 41,3 289 gray(255) 9: 23x26+111+34 122.1,44.3 254 gray(255) 9: 23x26+111+34 122,1 44,3 254 gray(255) 7: 16x19+70+30 77.8,39.0 219 gray(0) 7: 16x19+70+30 77,8 39 219 gray(0) 2: 25x27+163+25 172.0,36.5 199 gray(255) 2: 25x27+163+25 172 36,5 199 gray(255) 10: 20x18+187+34 197.2,41.6 179 gray(255) 10: 20x18+187+34 197,2 41,6 179 gray(255) 3: 15x26+95+26 101.2,37.1 153 gray(255) 3: 15x26+95+26 101,2 37,1 153 gray(255) 13: 11x11+116+37 121.1,42.2 97 gray(0) 13: 11x11+116+37 121,1 42,2 97 gray(0) dataline -------- 11: 33x18+211+34 227.7,41.3 289 gray(255) 10: 20x18+187+34 197.2,41.6 179 gray(255) 2: 25x27+163+25 172.0,36.5 199 gray(255) 4: 25x27+136+26 148.4,38.9 342 gray(255) 9: 23x26+111+34 122.1,44.3 254 gray(255) 3: 15x26+95+26 101.2,37.1 153 gray(255) 6: 26x25+65+27 77.5,39.3 292 gray(255) 5: 25x26+34+27 48.9,39.9 307 gray(255)
    1 point
  7. When you get some spare time you can check: https://github.com/DanysysTeam/UWPOCR/pulls I did some PR In the next steps, I will try to provide functions such as: _UWPOCR_GetTextFromFile() _UWPOCR_GetTextFromScreen() _UWPOCR_GetTextFromWindow() _UWPOCR_GetTextFromMemory()
    1 point
  8. The issues with OCR are becuase I had zoomed out PDF (68%)
    1 point
  9. So I checked: #include <ScreenCapture.au3> #include <GDIPlus.au3> #include "..\UWPOCR.au3" _Example() Func _Example() #Region - create example bitmap - take a screenshot _GDIPlus_Startup() ;hImage/hBitmap GDI Local $hTimer = TimerInit() ;~ Local $hHBitmap = _ScreenCapture_CaptureWnd("", WinWait("[REGEXPTITLE:(?i)(.*SciTE.*)]")) ;~ Local $hHBitmap = _ScreenCapture_CaptureWnd("", WinWait("[CLASS:SciTEWindow]")) ;~ Local $hHBitmap = _ScreenCapture_CaptureWnd("", WinWait("[CLASS:AVL_AVView]")) Local $hHBitmap = _ScreenCapture_CaptureWnd("", WinWait("[CLASS:AcrobatSDIWindow]")) Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) #EndRegion - create example bitmap - take a screenshot #Region - do the OCR Stuff ;Get OCR Text From hImage/hBitmap ;~ _UWPOCR_Log(__UWPOCR_Log) ;Enable Log Local $sOCRTextResult = _UWPOCR_GetText($hBitmap, Default, True) MsgBox(0, "Time Elapsed: " & TimerDiff($hTimer), $sOCRTextResult) #EndRegion - do the OCR Stuff #Region - bitmap clean up _WinAPI_DeleteObject($hHBitmap) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() #EndRegion - bitmap clean up EndFunc ;==>_Example and: and it is taken from:
    1 point
  10. @mLipok I think it's not needed you just need to use _GDIPlus_BitmapCreateFromMemory Saludos
    1 point
  11. If you have luck you can type in your addressbar javascript:alert(document.body.innerText) "I'm sorry to say, goes right over my head..." Nice moment to start with example 1-10 in the examples section on IUIAutomation. The alternative is the WebDriver examples but also that will have a steep learning curve.
    1 point
  12. I'd check the double-to-integer conversion you are doing in the compare function, floating math may not function like you'd expect. An unrelated suggestion: You might wanna start with C first as it's the basis of C++ but it's a lot simpler in concept, nailing the fundamentals will really help you later in your C/C++ journey
    1 point
×
×
  • Create New...