Leaderboard
Popular Content
Showing content with the highest reputation on 04/29/2024 in all areas
-
Push the power button? .. or is your question about something else?2 points
-
first of all i would like to thank @Danyfirex for this wonderful UWPOCR UDF that he offers us I noticed that when you perform OCR from a small area of the screen, it doesn't recognize it normally and can't read from it. and so I proceeded to these functions. Which work as I expected, However, I have no experience with GDIPlus. I post them, to share it with the community, and to get some hint, advice. In the example below I'm targeting the date on the bottom right of the taskbar, I have a 1920*1080 screen and 100% scale ; https://www.autoitscript.com/forum/topic/211521-ocr-from-a-small-area/?do=findComment&comment=1530475 #AutoIt3Wrapper_Run_Debug_Mode=Y #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WindowsConstants.au3> #include "UWPOCR.au3" ; * <-"https://www.autoitscript.com/forum/topic/207324-uwpocr-windows-platform-optical-character-recognition-api-implementation" _Example() ;-------------------------------------------------------------------------------------------------------------------------------- Func _Example() Local $sImageResult, $sOCRTextResult ; 1) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; From my monitor capture the date of the tskbar = 1808, 1062, 1862, 1074 $sImageResult = _ScreenCapture(@ScriptDir & "\tmp_OCR_image.png", 1808, 1062, 1862, 1074) ConsoleWrite("$sImageResult=" & $sImageResult & @CRLF) ; reading text from $sImageResult $sOCRTextResult = _UWPOCR_GetText($sImageResult) ConsoleWrite("- 1) OCR Result=" & $sOCRTextResult & @CRLF) ShellExecuteWait($sImageResult) ; 2) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; capture the date and give a border with 20 pixels = 1808, 1062, 1862, 1074, 0, 20 $sImageResult = _ScreenCapture(@ScriptDir & "\tmp_OCR_image.png", 1808, 1062, 1862, 1074, 0, 20) ; reading text from $sImageResult $sOCRTextResult = _UWPOCR_GetText($sImageResult) ConsoleWrite("- 2) OCR Result=" & $sOCRTextResult & @CRLF) ShellExecuteWait($sImageResult) ; 3) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; capture the date, give a border with 20 pixels, and invert colors = 1808, 1062, 1862, 1074, 1, 20 $sImageResult = _ScreenCapture(@ScriptDir & "\tmp_OCR_image.png", 1808, 1062, 1862, 1074, 1, 20) ; reading text from $sImageResult $sOCRTextResult = _UWPOCR_GetText($sImageResult) ConsoleWrite("- 3) OCR Result=" & $sOCRTextResult & @CRLF) ShellExecuteWait($sImageResult) ; 4) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; and the same from memory ConsoleWrite("Delete tmp_OCR_image=" & FileDelete($sImageResult) & @CRLF) $sOCRTextResult = _GetText(1808, 1062, 1862, 1074, 1, 20) ConsoleWrite("- 4) OCR Result=" & $sOCRTextResult & @CRLF) EndFunc ;==>_Example ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _ScreenCapture ; Description ...: Captures a region of the screen ; Syntax.........: _ScreenCapture($sFileName [, $iLeft = 0 [, $iTop = 0 [, $iRight = -1 [, $iBottom = -1 [, $iNegative = 0 [, $iBorder = 0 [, $dScale = 1 [, $iBrightness = 0 [, $iContrast = 0]]]]]]]]]) ; Parameters ....: $sFileName Full path and extension of the image file ; $iLeft [optional] X coordinate of the upper left corner of the rectangle ; $iTop [optional] Y coordinate of the upper left corner of the rectangle ; $iRight [optional] X coordinate of the lower right corner of the rectangle. If this is -1, the current screen width will be used ; $iBottom [optional] Y coordinate of the lower right corner of the rectangle. If this is -1, the current screen height will be used. ; $iNegative [optional] 1 = Negative color, 0 = Normal color ; $iBorder [optional] Draw a border araunt, The color is taken from first pixel ; $dScale [optional] Scale factor ; $iBrightness [optional] Integer in the range -255 through 255 that specifies the brightness level. ; $iContrast [optional] Integer in the range -100 through 100 that specifies the contrast level. ; Return value...: Filepath of the image If the image is successfully saved. ; False If the image is Not successfully saved. ; ; Author ........: ; Notes .........: ;-------------------------------------------------------------------------------------------------------------------------------- Func _ScreenCapture($sFileName, $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $iNegative = 0, $iBorder = 0, $dScale = 1, $iBrightness = 0, $iContrast = 0) Local $hHBitmap, $hBitmap, $hGDIPlusBitmap, $hImage, $hImageCtxt, $vRet, $iBmpW, $iBmpH, $iBorderColor _GDIPlus_Startup() $hHBitmap = _ScreenCapture_Capture("", $iLeft, $iTop, $iRight, $iBottom, False) If @error Then Return SetError(1, 0, False) Local $tSIZE = _WinAPI_GetBitmapDimension($hHBitmap) $iBmpW = $dScale * DllStructGetData($tSIZE, 'X') $iBmpH = $dScale * DllStructGetData($tSIZE, 'Y') ;Default ;$iFlags=0,$iIlluminant=0,$iGammaR=10000,$iGammaG=10000,$iGammaB=10000,$iBlack=0,$iWhite=10000,$iContrast=0,$iBrightness=0,$iColorfulness=0,$iTint=0 Local $iIlluminant = 0, $iGammaR = 10000, $iGammaG = 10000, $iGammaB = 10000, $iBlack = 0, $iWhite = 10000, $iColorfulness = 0, $iTint = 0 Local $tAdj = 0 $tAdj = _WinAPI_CreateColorAdjustment($iNegative, $iIlluminant, $iGammaR, $iGammaG, $iGammaB, $iBlack, $iWhite, $iContrast, $iBrightness, $iColorfulness, $iTint) $hBitmap = _WinAPI_AdjustBitmap($hHBitmap, $iBmpW, $iBmpH, $HALFTONE, $tAdj) If @error Then Return SetError(2, 0, False) $hGDIPlusBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) ; Add Border If $iBorder > 0 Then $iBorderColor = _GDIPlus_BitmapGetPixel($hGDIPlusBitmap, 1, 1) ;get pixel color from 1,1 $hImage = _GDIPlus_BitmapCreateFromScan0($iBmpW + (2 * $iBorder), $iBmpH + (2 * $iBorder)) ;create an empty bitmap If @error Then Return SetError(3, 0, False) $hImageCtxt = _GDIPlus_ImageGetGraphicsContext($hImage) ;get the graphics context of the bitmap _GDIPlus_GraphicsSetSmoothingMode($hImageCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsClear($hImageCtxt, $iBorderColor) ;clear bitmap with color white _GDIPlus_GraphicsDrawImage($hImageCtxt, $hGDIPlusBitmap, $iBorder, $iBorder) _GDIPlus_ImageDispose($hGDIPlusBitmap) Else $hImage = $hGDIPlusBitmap EndIf $vRet = _GDIPlus_ImageSaveToFile($hImage, $sFileName) ;save bitmap to disk If @error Then Return SetError(4, 0, False) If $vRet Then $vRet = $sFileName ; Cleanup resources _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_BitmapDispose($hImage) _GDIPlus_BitmapDispose($hGDIPlusBitmap) _GDIPlus_GraphicsDispose($hImageCtxt) _GDIPlus_Shutdown() Return $vRet EndFunc ;==>_ScreenCapture ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _GetText ; Description ...: reading text from a region of the screen ; Syntax.........: _GetText([$iLeft = 0 [, $iTop = 0 [, $iRight = -1 [, $iBottom = -1 [, $iNegative = 0 [, $iBorder = 0 [, $dScale = 1 [, $iBrightness = 0 [, $iContrast = 0 [, $sLanguageTagToUse = Default [, $bUseOcrLine = False]]]]]]]]]]]) ; Parameters ....: $iLeft [optional] X coordinate of the upper left corner of the rectangle ; $iTop [optional] Y coordinate of the upper left corner of the rectangle ; $iRight [optional] X coordinate of the lower right corner of the rectangle. If this is -1, the current screen width will be used ; $iBottom [optional] Y coordinate of the lower right corner of the rectangle. If this is -1, the current screen height will be used. ; $iNegative [optional] 1 = Negative color, 0 = Normal color ; $iBorder [optional] Draw a border araunt, The color is taken from first pixel ; $dScale [optional] Scale factor ; $iBrightness [optional] Integer in the range -255 through 255 that specifies the brightness level. ; $iContrast [optional] Integer in the range -100 through 100 that specifies the contrast level. ; $sLanguageTagToUse [optional] Gets the language being used for text recognition ; $bUseOcrLine [optional] Represents a single line of text recognized by the OCR engine and returned as part of the OcrResult. ; Return value...: Success: Contains the results of Optical Character Recognition (OCR). ; Failure: "" Empty String otherwise. ; On Error: false ; ; Author ........: ; Notes .........: ;-------------------------------------------------------------------------------------------------------------------------------- Func _GetText($iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $iNegative = 0, $iBorder = 0, $dScale = 1, $iBrightness = 0, $iContrast = 0, $sLanguageTagToUse = Default, $bUseOcrLine = False) Local $hHBitmap, $hBitmap, $hGDIPlusBitmap, $hImage, $hImageCtxt, $sOCRTextResult, $iBmpW, $iBmpH, $iBorderColor _GDIPlus_Startup() $hHBitmap = _ScreenCapture_Capture("", $iLeft, $iTop, $iRight, $iBottom, False) If @error Then Return SetError(1, 0, False) Local $tSIZE = _WinAPI_GetBitmapDimension($hHBitmap) $iBmpW = $dScale * DllStructGetData($tSIZE, 'X') $iBmpH = $dScale * DllStructGetData($tSIZE, 'Y') ;Default ;$iFlags=0,$iIlluminant=0,$iGammaR=10000,$iGammaG=10000,$iGammaB=10000,$iBlack=0,$iWhite=10000,$iContrast=0,$iBrightness=0,$iColorfulness=0,$iTint=0 Local $iIlluminant = 0, $iGammaR = 10000, $iGammaG = 10000, $iGammaB = 10000, $iBlack = 0, $iWhite = 10000, $iColorfulness = 0, $iTint = 0 Local $tAdj = 0 $tAdj = _WinAPI_CreateColorAdjustment($iNegative, $iIlluminant, $iGammaR, $iGammaG, $iGammaB, $iBlack, $iWhite, $iContrast, $iBrightness, $iColorfulness, $iTint) $hBitmap = _WinAPI_AdjustBitmap($hHBitmap, $iBmpW, $iBmpH, $HALFTONE, $tAdj) If @error Then Return SetError(2, 0, False) $hGDIPlusBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) ; Add Border If $iBorder > 0 Then $iBorderColor = _GDIPlus_BitmapGetPixel($hGDIPlusBitmap, 1, 1) ;get pixel color from 1,1 $hImage = _GDIPlus_BitmapCreateFromScan0($iBmpW + (2 * $iBorder), $iBmpH + (2 * $iBorder)) ;create an empty bitmap If @error Then Return SetError(3, 0, False) $hImageCtxt = _GDIPlus_ImageGetGraphicsContext($hImage) ;get the graphics context of the bitmap _GDIPlus_GraphicsSetSmoothingMode($hImageCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsClear($hImageCtxt, $iBorderColor) ;clear bitmap with color white _GDIPlus_GraphicsDrawImage($hImageCtxt, $hGDIPlusBitmap, $iBorder, $iBorder) _GDIPlus_ImageDispose($hGDIPlusBitmap) Else $hImage = $hGDIPlusBitmap EndIf $sOCRTextResult = _UWPOCR_GetText($hImage, $sLanguageTagToUse, $bUseOcrLine) If @error Then Return SetError(4, 0, False) ; Cleanup resources _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_BitmapDispose($hImage) _GDIPlus_BitmapDispose($hGDIPlusBitmap) _GDIPlus_GraphicsDispose($hImageCtxt) _GDIPlus_Shutdown() Return $sOCRTextResult EndFunc ;==>_GetText ;-------------------------------------------------------------------------------------------------------------------------------- Thank you very much1 point
-
Simple calculator Perform basic arithmetic operations directly from the numeric keypad. Easy copy and paste (data transfer) between different applications. Advanced Features (and the reason I did it) The calculator also includes an checkbox that enables you to apply offsets to your calculations. For instance, using the "+23" offset will add 23 to your result, making it perfect for scenarios where you need to adjust the position of graphical elements in a user interface (GUI). Imagine you want to reposition existing elements by 23 pixels on the Y-axis, you can easily recalculate the new coordinates by adding an offset. SimpleCalculator.au3 ; https://www.autoitscript.com/forum/topic/211838-simple-calculator/ ;---------------------------------------------------------------------------------------- ; Title...........: SimpleCalculator.au3 ; Description.....: Simple Calculator GUI ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Description=Simple Calculator GUI #AutoIt3Wrapper_Res_Fileversion=0.0.0.1 #AutoIt3Wrapper_Res_ProductName=SimpleCalculator.au3 #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> #include <EditConstants.au3> _CalcGUI() ;-------------------------------------------------------------------------------------------------------------------------------- Func _CalcGUI() #Region ### START Koda GUI section ### Local $hCalcGui = GUICreate("🧮 Simple Calculator", 355, 75, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) Local $Cmd_Get = GUICtrlCreateButton(">>", 3, 4, 30, 30, $BS_ICON) GUICtrlSetTip(-1, "Get") Local $Id_Input = GUICtrlCreateInput("", 35, 5, 285, 28) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") Local $Cmd_PasteIn = GUICtrlCreateButton("", 322, 4, 30, 30, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", -261) GUICtrlSetTip(-1, "Paste") Local $Cmd_Set = GUICtrlCreateButton("<<", 3, 39, 30, 30, $BS_ICON) GUICtrlSetTip(-1, "Set") Local $Id_Output = GUICtrlCreateLabel("", 35, 40, 265, 28) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xE1E1E1) Local $Cmd_CopyOut = GUICtrlCreateButton("", 322, 39, 30, 30, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", -135) GUICtrlSetTip(-1, "Copy") Local $Id_AutoCalc = GUICtrlCreateInput("", 186, 40, 115, 28) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUICtrlSetState(-1, $GUI_HIDE) Local $id_Checkbox = GUICtrlCreateCheckbox("", 305, 40, 17, 17) GUICtrlSetTip(-1, "Auto Calc") ; Set focus to the $Id_Input control. GUICtrlSetState($Id_Input, $GUI_FOCUS) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $nMsg, $hActiveWin, $sActiveTitle, $sOut, $sAuto, $ClipBack Local $iSlp = 10 ;Sleep between copy-paste, increase if necessary * <- ;********************************** While 1 If WinGetHandle("[ACTIVE]") <> $hActiveWin And WinGetHandle("[ACTIVE]") <> $hCalcGui Then $hActiveWin = WinGetHandle("[ACTIVE]") $sActiveTitle = WinGetTitle($hActiveWin) ConsoleWrite("$sActiveTitle=" & $sActiveTitle & @CRLF) ;*** EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $id_Checkbox $sOut = GUICtrlRead($Id_Input) If _IsChecked($id_Checkbox) Then GUICtrlSetState($Id_AutoCalc, $GUI_SHOW) GUICtrlSetPos($Id_Output, 35, 40, 145, 28) $sAuto = GUICtrlRead($Id_AutoCalc) $sOut = GUICtrlRead($Id_Input) GUICtrlSetData($Id_Output, Execute("(" & $sOut & ") " & $sAuto)) ControlFocus($hCalcGui, "", $Id_AutoCalc) Else GUICtrlSetState($Id_AutoCalc, $GUI_HIDE) GUICtrlSetPos($Id_Output, 35, 40, 265, 28) $sOut = Execute($sOut) GUICtrlSetData($Id_Output, $sOut) ControlFocus($hCalcGui, "", $Id_Input) EndIf Case $Id_Input, $Id_AutoCalc $sOut = GUICtrlRead($Id_Input) If GUICtrlRead($id_Checkbox) = $GUI_CHECKED Then $sAuto = GUICtrlRead($Id_AutoCalc) $sOut = GUICtrlRead($Id_Input) GUICtrlSetData($Id_Output, Execute("(" & $sOut & ") " & $sAuto)) Else $sOut = Execute($sOut) GUICtrlSetData($Id_Output, $sOut) EndIf GUICtrlSetState($Cmd_Set, $GUI_FOCUS) Case $Cmd_PasteIn GUICtrlSetData($Id_Input, ClipGet()) Case $Cmd_CopyOut ClipPut(GUICtrlRead($Id_Output)) Case $Cmd_Get $ClipBack = ClipGet() ; backup clip data ; Add new data to the clipboard. Sleep($iSlp) WinActivate($hActiveWin) Send("^c") ; copy Sleep($iSlp) GUICtrlSetData($Id_Input, ClipGet()) ClipPut($ClipBack) ; restore clip data GUICtrlSetData($Id_Output, "") If GUICtrlRead($id_Checkbox) = $GUI_CHECKED Then $sAuto = GUICtrlRead($Id_AutoCalc) $sOut = GUICtrlRead($Id_Input) GUICtrlSetData($Id_Output, Execute("(" & $sOut & ") " & $sAuto)) GUICtrlSetState($Cmd_Set, $GUI_FOCUS) Else ControlFocus($hCalcGui, "", $Id_Input) WinActivate($hCalcGui) EndIf Case $Cmd_Set $sOut = GUICtrlRead($Id_Output) If $sOut Then $ClipBack = ClipGet() ; backup clip data ; Add new data to the clipboard. ClipPut($sOut) Sleep($iSlp) WinActivate($hActiveWin) Send("^v") ; paste ClipPut($ClipBack) ; restore clip data EndIf EndSwitch ;~ Sleep(50) WEnd ;********************************** EndFunc ;==>_CalcGUI ;-------------------------------------------------------------------------------------------------------------------------------- Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked ;-------------------------------------------------------------------------------------------------------------------------------- Please, every comment is appreciated! leave your comments and experiences here! Thank you very much1 point
-
ePUB Reader
argumentum reacted to Andreik for a topic
New version available. Fixed an issue that occur when reading books with incorrect guides.1 point -
Silent Configuration - AutoITv3
SOLVE-SMART reacted to Nine for a topic
I do not see any attempt in your posts that demonstrate you tried anything. In fact, it looks like you are waiting for someone to code it for you. Unless you start showing some initiative, I am afraid that you will not get much more help that we already gave you.1 point -
How to choose printing single-sided or duplex in SciTe on Windows 10
argumentum reacted to c.haslam for a topic
I have already stated what I find in printer preferences, that what is offered for printing from SciTE differs from what is offered from Chrome. Printing from Chrome does offer sing-sided; printing from SciTE doesn't. Why print? My eyesight isn't what it once was.1 point -
SMF - The fastest duplicate files finder... [Updated 2024-Oct-20]
goodmanjl531 reacted to KaFu for a topic
Yes, SMF can do that. Select the folders to search, do a search and open the report. Go to the yellow filter box above the "FileName Long" column and enter this: filename1234.txt|filename1235.txt|filename1247.txt|filename1248.txt|filename2240.txt The "|" sign is a delimiter for an OR condition in the LIKE statement. You can also select "LIKE Expressions" in the drop-down above the yellow field and enter the filenames one per line. Select all required files in the report and either Ctrl+C copy them or use the right mouse click menu for more complex copy operations (e.g. "Copy to...").1 point -
You can also do something like this (again through vSphere): Do Sleep(50) Until WinExists("Error Applying Security") WinActivate("Error Applying Security") Sleep(100) Send("{TAB}") Send("{SPACE}") Sleep(100) Assuming it only takes 1 TAB to highlight the OK button, if not use additional Send commands. Ian1 point