Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/17/2022 in all areas

  1. Hmm, 2 years ago, first character was a # and now it is a ; Total new challenge !
    2 points
  2. pixelsearch, What an interesting discovery that you seem to need to hide/show BOTH scrollbars using $SB_BOTH to get it to work properly. Good detective work on your behalf. But I notice that, just as with GUIScrollbarsEx, the RESTORE is not correct when using Win-D or the taskbar "hide all" button. I may have to register WM_SIZE as I did a couple of months ago with the GUIScrollbarsEx code. Needs a bit of thought first. I sometime wish I had written UDFs for less flaky controls than scrollbars and ListViews are both are real pains to work with - although that is probably why there were no complex UDFs for them beforehand. M23 Edit: I think it might be a good idea to write a 3rd UDF for the package which will deal with MINIMIZE/RESTORE cycles for initiated GUIs - that way the _SIZE UDF retains its current stand-alone form. Something to keep me occupied over the next few days.....
    2 points
  3. Nine

    Screen scraping

    Screen scraping means a way to read / write on the representation of the current screen. You can, with this UDF, read the actual foreground of the screen or a background window. Hidden or minimized window are not supported. I tried to optimize the use of AutoIt as much as I could, but some actions require the performance of a DLL. I have found multiple threads and others UDF discussing this subject but never found an optimized approach to this issue without gathering everything inside a large DLL. The examples I am providing show how to use a background window (even if it is in the foreground when you run it directly with Scite) or use the current screen. Reading current screen is faster (about 20-30 ms faster) than reading a background window. You need to first initialize the structure based on width and height. You can reuse the structure as long as you want if the dimensions do not change. You will need to make a new initialize if dimensions are changing. You do not need (this way) to have the actual size of a window. You can decide to reduce the dimensions to increase performance. Supports x86 and x64. The following functions are included in the UDF : _GetScreen_Initialize($iWidth, $iHeight) _GetScreen_GetScreen() _GetScreen_GetWindow($hWnd, $iFlag = 0) _GetScreen_GetPixel($iX, $iY) _GetScreen_SetPixel($iX, $iY, $iValue) _GetScreen_SearchArea($iLeft, $iTop, $iRight, $iBottom, $iColor, $iStart = 1) _GetScreen_SearchAll($iColor, $iStart = 1) _GetScreen_PixelReplaceArea($iColorFrom, $iColorTo, $iLeft, $iTop, $iRight, $iBottom) _GetScreen_PixelReplaceAll($iColorFrom, $iColorTo) _GetScreen_CheckSumArea($iLeft, $iTop, $iRight, $iBottom) _GetScreen_SaveFile($sFileName) _GetScreen_GetBitMap() Version 2022-04-17 * Added new optional parameter $iFlag to _GetScreen_GetWindow 0 = full window for Win 7 and over 1 = client area for Win 7 and over 2 = full window for Win 10 and over (this can be used with applications (like Chrome) that do not support WM_PRINT or WM_PRINTCLIENT messages) Version 2021-11-28 * Corrected a bug in SearchArea Version 2021-08-30 * Fixed bugs related to areas * Added support to repetitive searches in the same area * Added a function to make a CheckSum of an area * Added an additional example Version 2021-08-24 * Removed unused structure * Harmonized code Example 1 : show various functions using the _GetScreen_GetWindow (background support) Example 2 : show new functions using _GetScreen_GetScreen() (foreground only but faster) All comments are very much welcome. GetScreen.zip
    1 point
  4. I'd first like to thank Jon for creating AutoIt. Also, thank you to all the developers for the countless hours they selflessly devote to keeping it going. And lastly thank you to all the people of this forum who offer their guidance to people like me. I've been using AutoIt since 2005 and owe my IT career to all these people. The "GUIScrollbars_Ex.au3" UDF, developed by Melba23, has opened the door to many possibilities for me. Melba23 has been one of the best, all time, at contributing to AutoIt and this forum. For a number of days, I've been trying to resolve what I believe is my logic issue. I'm creating a script which can be dynamically resized, depending on the size of the controls. My issue is I can't get the buttons to space evenly at the bottom of the gui. I'm using AutoIt v3.3.16.0 and the "GUIScrollbars_Ex.au3" UDF I downloaded again on April 4th. The below script is only dealing with the number of rows changing. But once this is resolved, I'd like to apply it to the number of columns changing also. Thank you for the direction anyone may have to offer. taurus905 ; Resizing Gui with Scrollbar Example.au3 #include <WindowsConstants.au3> ; $WS_EX_TOOLWINDOW #include <GUIScrollbars_Ex.au3> ; _GUIScrollbars_Generate #include <GUIConstantsEx.au3> ; $GUI_EVENT_CLOSE HotKeySet("{PAUSE}", "_Increment_Row") ; Increment Row HotKeySet("{ESC}", "_Exit") ; Exit ; _Create_Gui() ; Create Gui Global $h_Gui Global $i_Key_Width = 40 Global $i_Key_Height = 20 Global $i_Row_Increment = 2 Global $i_Rows = 8 Global $i_Cols = 4 Global $i_Gui_Width = $i_Key_Width * $i_Cols Global $i_Gui_Height ; _Create_Schrollbars() ; Create Schrollbars Global $i_Gui_Titlebar_Height = 27 Global $i_Gui_Boarder = 3 Global $i_Aperture_Width = $i_Key_Width * $i_Cols + _ 2 * $i_Gui_Boarder Global $i_Aperture_Height Global $i_Scrollbar_Size = 17 Global $f_Scrollbar_Horz = 0 Global $f_Scrollbar_Vert = 1 ; _Create_Keys() ; Create Keys Global $s_Key_Name MsgBox(262208, _ ; $MB_TOPMOST + $MB_ICONINFORMATION "Resizing Gui with Scrollbar Example", _ "Use the 'Pause' key to increment Gui rows" & @CRLF & @CRLF & _ "and the 'Escape' key to exit script." & @CRLF & @CRLF & _ "Scroll to end of Gui to see row of keys" & @CRLF & _ "which shows inconsistent spacing.") _Increment_Row() ; Increment Row While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Exit Func _Increment_Row() ; Increment Row GUIDelete($h_Gui) $i_Rows += $i_Row_Increment $i_Gui_Height = $i_Key_Height * $i_Rows _Create_Gui() ; Create Gui $i_Aperture_Height = $i_Key_Height * $i_Rows * .5 + _ $i_Gui_Titlebar_Height + _ $i_Gui_Boarder _Create_Schrollbars() ; Create Schrollbars _Create_Keys() ; Create Keys GUISetState(@SW_SHOW, $h_Gui) EndFunc ; ==> _Increment_Row Func _Create_Gui() ; Create Gui $h_Gui = GUICreate("Resizing Gui", _ $i_Gui_Width, _ $i_Gui_Height, _ Default, _ Default, _ Default, _ BitOR($WS_EX_TOOLWINDOW, _ $WS_EX_TOPMOST)) GUISetBkColor(0x000000) ; Black EndFunc ; ==> _Create_Gui Func _Create_Schrollbars() ; Create Schrollbars WinMove($h_Gui, "", _ Default, _ Default, _ $i_Aperture_Width + $i_Scrollbar_Size, _ $i_Aperture_Height) _GUIScrollbars_Generate($h_Gui, _ $i_Gui_Width, _ $i_Gui_Height - $i_Scrollbar_Size, _ 0, _ 0, _ Default, _ 7) ; Number of lines/chars moved by a single cursor key press - default 0 _GUIScrollBars_ShowScrollBar($h_Gui, $SB_HORZ, $f_Scrollbar_Horz) _GUIScrollBars_ShowScrollBar($h_Gui, $SB_VERT, $f_Scrollbar_Vert) EndFunc ; ==> _Create_Schrollbars Func _Create_Keys() ; Create Keys For $row = 0 To $i_Rows - 1 For $col = 0 To $i_Cols - 1 $s_Key_Name = $row + 1 & "." & $col + 1 GUICtrlCreateButton($s_Key_Name, _ ($col) * $i_Key_Width, _ ($row) * $i_Key_Height, _ $i_Key_Width, _ $i_Key_Height) GUICtrlSetTip(-1, _ $i_Key_Width & "w x " & _ $i_Key_Height & "h x " & _ $i_Rows & " rows") GUICtrlSetBkColor(-1, _ 0xFFFFFF) ; White GUICtrlSetFont(-1, _ Default, _ 900) ; Bold Next Next EndFunc ; ==> _Create_Keys Func _Exit() ; Exit Exit EndFunc ; ==> _Exit
    1 point
  5. Glad you liked the scripts, taurus905 In a few minutes, I'm gonna amend the While...Wend loop of 2 other scripts above (the vertical one and the horizontal one) to get a more robust loop, so all 3 scripts will behave correctly when the gui is restored after it was minimized using Win-D or "hide all" button from taskbar, as Melba23 indicated in this link
    1 point
  6. Try “fa-IR”? Also check if it is supported by your OS and install additional language pack if required (and available).
    1 point
  7. How does this differ from the question you already asked nearly 2 years ago ? https://www.autoitscript.com/forum/topic/203486-file-read/?do=findComment&comment=1461145
    1 point
  8. @taurus905 You'll find below the code that manages 2 scrollbars : ; Resizing Gui with both Scrollbars Example.au3 #include <Array.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPISys.au3> #include "GUIScrollbars_Size.au3" Opt("MustDeclareVars", 1) HotKeySet("{PAUSE}", "_Increment") ; Increment HotKeySet("{ESC}", "_Exit") ; Exit ; Get 1 character height & width (before creating GUI, as it will be used to calculate controls size) Global $aCharSize = _GSB_Size_Text(GUICreate("")) ; M23's internal function in GUIScrollbars_Size.au3 GUIDelete() Global $iCharWidth = $aCharSize[0], $iCharHeight = $aCharSize[1] ; ConsoleWrite($iCharWidth & " " & $iCharHeight & @crlf) ; 7 & 16 on my PC ; _Create_Gui() ; Create Gui Global $h_Gui Global $i_Increment = 2 Global $i_Rows = 8 Global $i_Cols = 8 Global $i_Key_Width = $iCharWidth * 6 ; 42 on my PC (7 * 6) Global $i_Key_Height = $iCharHeight * 2 ; 32 on my PC (16 * 2) Global $i_Gui_Width Global $i_Gui_Height Global $nH_Pos, $nV_Pos, $iIncMini = 0 ; _Create_Schrollbars() ; Create Schrollbars Global $iScroll_Width = _WinAPI_GetSystemMetrics(2) ; Width of VScrollbar: SM_CXVSCROLL Global $iScroll_Height = _WinAPI_GetSystemMetrics(3) ; Height of HScrollbar: SM_CYHSCROLL ; ConsoleWrite($iScroll_Width & " " & $iScroll_Height & @crlf) ; 17 & 17 on my PC ; _Create_Keys() ; Create Keys Global $s_Key_Name MsgBox(262208, _ ; $MB_TOPMOST + $MB_ICONINFORMATION "Resizing Gui with both Scrollbars Example", _ "Use the 'Pause' key to increment Gui rows & cols" & @CRLF & @CRLF & _ "and the 'Escape' key to exit script." & @CRLF & @CRLF & _ "Scroll to end of Gui to see row & cols of keys" & @CRLF & _ "which shows consistent spacing.") GUIRegisterMsg($WM_HSCROLL, "_Scrollbars_WM_HSCROLL") GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") _Increment() ; Increment While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch If BitAND(WinGetState($h_GUI), $WIN_STATE_MINIMIZED) Then ; Minimize button, Win-D, hide all $iIncMini += 1 If $iIncMini = 1 Then _GUIScrollBars_ShowScrollBar($h_GUI, $SB_BOTH, False) $nH_Pos = _GUIScrollBars_GetScrollPos($h_GUI, $SB_HORZ) $nV_Pos = _GUIScrollBars_GetScrollPos($h_GUI, $SB_VERT) _GUIScrollBars_SetScrollInfoPos($h_GUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoPos($h_GUI, $SB_VERT, 0) EndIf Else ; not Minimized If $iIncMini Then $iIncMini = 0 _GUIScrollBars_ShowScrollBar($h_GUI, $SB_BOTH, True) _GUIScrollBars_SetScrollInfoPos($h_GUI, $SB_HORZ, $nH_Pos) _GUIScrollBars_SetScrollInfoPos($h_GUI, $SB_VERT, $nV_Pos) EndIf EndIf WEnd ;============================================== Func _Increment() ; Increment GUIDelete($h_Gui) ; As the script deletes the GUI for each increment, no need to keep useless rows... ; ... in the GLOBAL array $__g_aSB_WindowInfo[][] declared in GuiScrollBars.au3 ; But it's also a good idea to keep the "useless" rows to check the changed values. ; Global $__g_aSB_WindowInfo[1][8] ; reset, exactly as found in GuiScrollBars.au3 ; _ArrayDisplay($__g_aSB_WindowInfo, "$__g_aSB_WindowInfo", Default, $ARRAYDISPLAY_NOROW) $i_Rows += $i_Increment $i_Gui_Height = $i_Key_Height * $i_Rows $i_Cols += $i_Increment $i_Gui_Width = $i_Key_Width * $i_Cols _Create_Gui() ; Create Gui _Create_Schrollbars() ; Create Schrollbars _Create_Keys() ; Create Keys GUISetState(@SW_SHOW, $h_Gui) EndFunc ; ==> _Increment ;======================================================== Func _Create_Gui() ; Create Gui $h_Gui = GUICreate("Resizing Gui", _ $i_Gui_Width / 2 + $iScroll_Width, _ $i_Gui_Height / 2 + $iScroll_Height, _ Default, _ Default, _ Default, _ $WS_EX_TOPMOST) EndFunc ; ==> _Create_Gui ;======================================================== Func _Create_Schrollbars() ; Create Schrollbars Local $aRet = _GUIScrollbars_Size($i_Gui_Width - $iScroll_Width / 2, $i_Gui_Height - $iScroll_Height / 2, _ $i_Gui_Width / 2 + $iScroll_Width, $i_Gui_Height / 2 + $iScroll_Height) ; ConsoleWrite("$aRet[0] = " & $aRet[0] & " $aRet[1] = " & $aRet[1] & _ ; " $aRet[2] = " & $aRet[2] & " $aRet[3] = " & $aRet[3] & @crlf) ; _GUIScrollBars_Init($h_GUI) ; phantom scrollbar + gap when no 2nd / 3rd param. _GUIScrollBars_Init($h_GUI, 1500, 100) ; 2nd & 3rd parameter to increase the values _GUIScrollBars_ShowScrollBar($h_GUI, $SB_HORZ, True) _GUIScrollBars_SetScrollInfoPage($h_GUI, $SB_HORZ, $aRet[0]) _GUIScrollBars_SetScrollInfoMax($h_GUI, $SB_HORZ, $aRet[1] + 1) ; (+ 1 after test) _GUIScrollBars_ShowScrollBar($h_GUI, $SB_VERT, True) _GUIScrollBars_SetScrollInfoPage($h_GUI, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($h_GUI, $SB_VERT, $aRet[3]) EndFunc ; ==> _Create_Schrollbars ;======================================================== Func _Create_Keys() ; Create Keys For $row = 0 To $i_Rows - 1 For $col = 0 To $i_Cols - 1 $s_Key_Name = $row + 1 & "." & $col + 1 GUICtrlCreateLabel($s_Key_Name, _ ($col) * $i_Key_Width, _ ($row) * $i_Key_Height, _ $i_Key_Width, _ $i_Key_Height, _ BitOr($SS_CENTERIMAGE, $SS_CENTER, $SS_SUNKEN), _ $GUI_WS_EX_PARENTDRAG) GUICtrlSetTip(-1, _ $i_Key_Width & "w x " & _ $i_Key_Height & "h x " & _ $i_Rows & " rows") GUICtrlSetBkColor(-1, _ 0xFFFFFF) ; White GUICtrlSetFont(-1, _ Default, _ 900) ; Bold Next Next EndFunc ; ==> _Create_Keys ;======================================================== Func _Exit() ; Exit Exit EndFunc ; ==> _Exit ;======================================================== Func _Scrollbars_WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $xChar, $xPos Local $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $xChar = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Page = DllStructGetData($tSCROLLINFO, "nPage") $xPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $xPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_LINELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_HSCROLL ;======================================================== Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $yChar = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_VSCROLL So this is the end of our "scrollbar journey". Thank you for this interesting challenge and to Melba23 for his continuous help. Have a great sunday
    1 point
  9. Hi Melba23, I'm facing a problem with your function _GUIScrollbars_Restore() found in GUIScrollbars_Size.au3 and I found a solution to fix it. The issue doesn't appear when there is only 1 scrollbar to restore. For example, the script GUIScrollbars_Size_Example_2.au3 works fine because it only got a vertical scrollbar, so its code restores the scrollbar & the content of the GUI at their correct position, after the vertical scrollbar had been moved and the GUI minimized : Case $GUI_EVENT_RESTORE     _GUIScrollbars_Restore($hGUI, True, False) The issue happens when there are 2 scrollbars to restore, for example in the 3rd script you shared a few days ago (now found in this thread) and you introduced it with these words "And here is an example which is dynamic in both directions" : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include <WinAPISys.au3> #include "GUIScrollbars_Size.au3" HotKeySet("^+R", "_Increase_Rows") HotKeySet("^+C", "_Increase_Cols") ; Get size of scrollbars Global $iScroll_Width = _WinAPI_GetSystemMetrics(2) ; Width of VScrollbar: SM_CXVSCROLL Global $iScroll_Height = _WinAPI_GetSystemMetrics(3) ; Height of HScrollbar: SM_CYHSCROLL ; Set key parameters Global $i_Key_Width = 40 Global $i_Key_Height = 20 Global $i_Rows = 12 Global $i_Cols = 8 ; Calculate the size of the full GUI to be scrolled Global $i_Gui_Width = $i_Key_Width * $i_Cols Global $i_Gui_Height = $i_Key_Height * $i_Rows ; Create the GUI with the size of the aperture to be used Global $hGUI = GUICreate("Test", 200, 200) GUISetState() $aRet = _GUIScrollbars_Size($i_Gui_Width, $i_Gui_Height, 200, 200) ; Parameters: $i_Gui_Width - Width of underlying GUI ; $i_Gui_Height - Vertical size of underlying GUI ; 200 - Width of aperture GUI ; 200 - Height of aperture GUI ; Register the handlers GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") GUIRegisterMsg($WM_HSCROLL, "_Scrollbars_WM_HSCROLL") ; Create scrollbars _GUIScrollBars_Init($hGUI) ;Show and set parameters for horizontal scrollbar _GUIScrollBars_ShowScrollBar($hGUI, $SB_HORZ, True) _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_HORZ, $aRet[0]) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, $aRet[1]) ; And then for vertical _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, True) _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $aRet[3]) ; Create keys _Create_Keys() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_RESTORE ; Still needed if you use the _Size UDF ; _GUIScrollbars_Restore($hGUI, True, False) ; personal note : probably a typo... _GUIScrollbars_Restore($hGUI, True, True) ; ...as there are 2 scrollbars EndSwitch WEnd Func _Increase_Cols() ; Save scrollbar positions and set to 0 Local $iHorz = _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_HORZ) Local $iVert = _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_VERT) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 0) ; Save current final col Local $iCurrCols = $i_Cols ; Add rows $i_Cols += 4 ; Create the new keys _Create_Keys(0, $iCurrCols) ; Calculate the new height $i_Gui_Width = $i_Key_Width * $i_Cols ; Use the UDF to get the new scrollbar parameters $aRet = _GUIScrollbars_Size($i_Gui_Width + $iScroll_Width, 0, 200, 200) ; And set them _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_HORZ, $aRet[0]) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, $aRet[1]) ; Reset positions _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, $iHorz) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, $iVert) EndFunc Func _Increase_Rows() ; Save scrollbar positions and set to 0 Local $iHorz = _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_HORZ) Local $iVert = _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_VERT) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 0) ; Save current final row Local $iCurrRows = $i_Rows ; Add rows $i_Rows += 4 ; create the new keys _Create_Keys($iCurrRows) ; Calculate the new height $i_Gui_Height = $i_Key_Height * $i_Rows ; Use the UDF to get the new scrollbar parameters $aRet = _GUIScrollbars_Size(0, $i_Gui_Height + $iScroll_Height, 200, 200) ; And set them _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $aRet[3]) ; Reset positions _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, $iHorz) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, $iVert) EndFunc Func _Create_Keys($iCurrRows = 0, $iCurrCols = 0) ; Create Keys For $row = $iCurrRows To $i_Rows - 1 For $col = $iCurrCols To $i_Cols - 1 $s_Key_Name = $row + 1 & "." & $col + 1 GUICtrlCreateButton($s_Key_Name, ($col) * $i_Key_Width, ($row) * $i_Key_Height, $i_Key_Width, $i_Key_Height) GUICtrlSetFont(-1, Default, 900) ; Bold Next Next EndFunc ; ==> _Create_Keys Func _Scrollbars_WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $xChar, $xPos Local $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $xChar = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Page = DllStructGetData($tSCROLLINFO, "nPage") $xPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $xPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_LINELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_HSCROLL Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $yChar = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_VSCROLL The solution I found is the one below, where some instructions are executed while the scrollbars are hidden. The code should be completed to cover all cases (when only a scrollbar is needed) but well... you got the idea. Case $GUI_EVENT_RESTORE ; Still needed if you use the _Size UDF _GUIScrollBars_ShowScrollBar($hGUI, $SB_BOTH, False) Local $nH_Pos = _GUIScrollBars_GetScrollPos($hGUI, $SB_HORZ) Local $nV_Pos = _GUIScrollBars_GetScrollPos($hGUI, $SB_VERT) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 0) _GUIScrollBars_ShowScrollBar($hGUI, $SB_BOTH, True) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, $nH_Pos) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, $nV_Pos) Thanks for sharing your thoughts about this and I apologize if something I wrote is incorrect. For the record, I tested your good example GUIScrollbars_Ex_Example_2.au3 , based on GUIScrollbars_Ex.au3 and _GUIScrollbars_EventMonitor() : everything goes well with its 2 scrollbars after minimize & restore, but as you wrote elsewhere : "To have correctly-sized scrollbars in a fixed size GUI with a dynamic number of internal controls you need to use _GUIScrollbars_Size, not _GUIScrollbarsEx" Have a great sunday everybody Edit: splitting the Minimize-Restore code in both Case(s) seem to display faster when restoring (variables Local $nH_Pos & Local $nV_Pos to be scripted better but enough for today) Case $GUI_EVENT_MINIMIZE _GUIScrollBars_ShowScrollBar($hGUI, $SB_BOTH, False) Local $nH_Pos = _GUIScrollBars_GetScrollPos($hGUI, $SB_HORZ) Local $nV_Pos = _GUIScrollBars_GetScrollPos($hGUI, $SB_VERT) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 0) Case $GUI_EVENT_RESTORE _GUIScrollBars_ShowScrollBar($hGUI, $SB_BOTH, True) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, $nH_Pos) _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, $nV_Pos)
    1 point
  10. Since you're only overwriting the values you can just use IniWrite without the IniRead or use the function more efficiently, for example: _SaveIni("Key1", "ExpectedValue1") _SaveIni("Key2", "ExpectedValue2") _SaveIni("Key3", "ExpectedValue3") Func _SaveIni($_sKey, $_sValue) Local $sFilePath = @ScriptDir & "\FilePath.ini" Local $sSection = "Section" Local $sIniRead = IniRead($sFilePath, $sSection, $_sKey, "") If $sIniRead = $_sValue Then Return IniWrite($sFilePath, $sSection, $_sKey, $_sValue) EndFunc
    1 point
  11. Thank you, let's have both Ok, my preceding post tested a vertical scrollbar and showed a possible issue in the function _GUIScrollBars_Init() found in GuiScrollBars.au3, because of a constant = 27, when the function is called with only 1 argument : Func _GUIScrollBars_Init($hWnd, $iMaxH = -1, $iMaxV = -1)     ...     If $iMaxV = -1 Then $__g_aSB_WindowInfo[$iIndex][7] = 27     ... EndFunc Now let's start some tests with an horizontal scrollbar, which will show a similar issue : The code corresponding to the pic above will be found below. Meanwhile : * 1st & 2nd gui are correct : no vertical phantom scrollbar, no gap. * 3rd gui shows a non-draggable vertical phantom scrollbar. * 4th gui shows a gap at the right, which would increase indefinitely when you add columns. Starting with 3rd gui, the issue appears because of the following line : Func _GUIScrollBars_Init($hWnd, $iMaxH = -1, $iMaxV = -1)     ...     If $iMaxH = -1 Then $__g_aSB_WindowInfo[$iIndex][1] = 48 * $iXAmount + 12 * $iUpperX     ... EndFunc Do you notice this value of 462 in Col1 of all preceding ArrayDisplay's ? This is the value of $__g_aSB_WindowInfo[$iIndex][1] on my computer. As soon as the value in Col4 (cxClient) becomes superior to 462, then a vertical non-draggable phantom scrollbar & gap will appear. A possible solution is to increase this value of 462 when calling _GUIScrollBars_Init(), like this : ; _GUIScrollBars_Init($h_GUI) ; phantom scrollbar + gap when no 2nd / 3rd param. _GUIScrollBars_Init($h_GUI, 1500) ; 2nd parameter passed to avoid phantom scrollbar + gap Then everything comes back to normal : Code corresponding to these pics : ; Resizing Gui with Horizontal Scrollbar Example.au3 #include <Array.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPISys.au3> #include "GUIScrollbars_Size.au3" Opt("MustDeclareVars", 1) HotKeySet("{PAUSE}", "_Increment") ; Increment HotKeySet("{ESC}", "_Exit") ; Exit ; Get 1 character height & width (before creating GUI, as it will be used to calculate controls size) Global $aCharSize = _GSB_Size_Text(GUICreate("")) ; M23's internal function in GUIScrollbars_Size.au3 GUIDelete() Global $iCharWidth = $aCharSize[0], $iCharHeight = $aCharSize[1] ; ConsoleWrite($iCharWidth & " " & $iCharHeight & @crlf) ; 7 & 16 on my PC ; _Create_Gui() ; Create Gui Global $h_Gui Global $i_Increment = 2 Global $i_Rows = 6 Global $i_Cols = 8 Global $i_Key_Width = $iCharWidth * 10 ; 70 on my PC (7 * 10) Global $i_Key_Height = $iCharHeight * 1 ; 16 on my PC (16 * 1) Global $i_Gui_Width Global $i_Gui_Height = $i_Key_Height * $i_Rows Global $nH_Pos, $iIncMini = 0 ; _Create_Schrollbars() ; Create Schrollbars Global $iScroll_Width = _WinAPI_GetSystemMetrics(2) ; Width of VScrollbar: SM_CXVSCROLL Global $iScroll_Height = _WinAPI_GetSystemMetrics(3) ; Height of HScrollbar: SM_CYHSCROLL ; ConsoleWrite($iScroll_Width & " " & $iScroll_Height & @crlf) ; 17 & 17 on my PC ; _Create_Keys() ; Create Keys Global $s_Key_Name MsgBox(262208, _ ; $MB_TOPMOST + $MB_ICONINFORMATION "Resizing Gui with Horizontal Scrollbar Example", _ "Use the 'Pause' key to increment Gui cols" & @CRLF & @CRLF & _ "and the 'Escape' key to exit script." & @CRLF & @CRLF & _ "Scroll to end of Gui to see cols of keys" & @CRLF & _ "which shows consistent spacing.") GUIRegisterMsg($WM_HSCROLL, "_Scrollbars_WM_HSCROLL") _Increment() ; Increment While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch If BitAND(WinGetState($h_GUI), $WIN_STATE_MINIMIZED) Then ; Minimize button, Win-D, hide all $iIncMini += 1 If $iIncMini = 1 Then _GUIScrollBars_ShowScrollBar($h_GUI, $SB_HORZ, False) $nH_Pos = _GUIScrollBars_GetScrollPos($h_GUI, $SB_HORZ) _GUIScrollBars_SetScrollInfoPos($h_GUI, $SB_HORZ, 0) EndIf Else ; not Minimized If $iIncMini Then $iIncMini = 0 _GUIScrollBars_ShowScrollBar($h_GUI, $SB_HORZ, True) _GUIScrollBars_SetScrollInfoPos($h_GUI, $SB_HORZ, $nH_Pos) _GUIScrollBars_ShowScrollBar($h_GUI, $SB_VERT, False) ; keep that line EndIf EndIf WEnd ;============================================== Func _Increment() ; Increment GUIDelete($h_Gui) ; As the script deletes the GUI for each increment, no need to keep useless rows... ; ... in the GLOBAL array $__g_aSB_WindowInfo[][] declared in GuiScrollBars.au3 ; But it's also a good idea to keep the "useless" rows to check the changed values. ; Global $__g_aSB_WindowInfo[1][8] ; reset, exactly as found in GuiScrollBars.au3 ; _ArrayDisplay($__g_aSB_WindowInfo, "$__g_aSB_WindowInfo", Default, $ARRAYDISPLAY_NOROW) $i_Cols += $i_Increment $i_Gui_Width = $i_Key_Width * $i_Cols _Create_Gui() ; Create Gui _Create_Schrollbars() ; Create Schrollbars _Create_Keys() ; Create Keys GUISetState(@SW_SHOW, $h_Gui) EndFunc ; ==> _Increment ;======================================================== Func _Create_Gui() ; Create Gui $h_Gui = GUICreate("Resizing Gui", _ $i_Gui_Width / 2, _ $i_Gui_Height + $iScroll_Height, _ Default, _ Default, _ Default, _ $WS_EX_TOPMOST) EndFunc ; ==> _Create_Gui ;======================================================== Func _Create_Schrollbars() ; Create Schrollbars Local $aRet = _GUIScrollbars_Size($i_Gui_Width - $iScroll_Width / 2, 0, _ $i_Gui_Width / 2, $i_Gui_Height + $iScroll_Height) ; ConsoleWrite("$aRet[0] = " & $aRet[0] & " $aRet[1] = " & $aRet[1] & @crlf) ;~ _GUIScrollBars_Init($h_GUI) ; phantom scrollbar + gap when no 2nd / 3rd param. _GUIScrollBars_Init($h_GUI, 1500) ; 2nd parameter changed to avoid phantom scrollbar + gap _GUIScrollBars_ShowScrollBar($h_GUI, $SB_VERT, False) _GUIScrollBars_ShowScrollBar($h_GUI, $SB_HORZ, True) _GUIScrollBars_SetScrollInfoPage($h_GUI, $SB_HORZ, $aRet[0]) _GUIScrollBars_SetScrollInfoMax($h_GUI, $SB_HORZ, $aRet[1] + 1) ; (+ 1 after test) EndFunc ; ==> _Create_Schrollbars ;======================================================== Func _Create_Keys() ; Create Keys For $row = 0 To $i_Rows - 1 For $col = 0 To $i_Cols - 1 $s_Key_Name = $row + 1 & "." & $col + 1 GUICtrlCreateLabel($s_Key_Name, _ ($col) * $i_Key_Width, _ ($row) * $i_Key_Height, _ $i_Key_Width, _ $i_Key_Height, _ BitOr($SS_CENTERIMAGE, $SS_CENTER, $SS_SUNKEN), _ $GUI_WS_EX_PARENTDRAG) GUICtrlSetTip(-1, _ $i_Key_Width & "w x " & _ $i_Key_Height & "h x " & _ $i_Rows & " rows") GUICtrlSetBkColor(-1, _ 0xFFFFFF) ; White GUICtrlSetFont(-1, _ Default, _ 900) ; Bold Next Next EndFunc ; ==> _Create_Keys ;======================================================== Func _Exit() ; Exit Exit EndFunc ; ==> _Exit ;======================================================== Func _Scrollbars_WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $xChar, $xPos Local $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $xChar = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Page = DllStructGetData($tSCROLLINFO, "nPage") $xPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $xPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_LINELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_HSCROLL I'll try to add in a further post some tests results when both scrollbars are present.
    1 point
  12. Here is a script to compare UWPOCR vs Tesseract. (it just load image process and show result in editboxes and display the processed image to compare visually. #include <WinAPISys.au3> #include <WinAPIsysinfoConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <FileConstants.au3> #include "..\..\UWPOCR.au3" Global $g_sTesseractPath = @ScriptDir & "\tesseract-ocr-w64-setup-v5.0.0-alpha.20210811\tesseract.exe" ;change me _TestUWPOCRvsTesseractOCR() Func _TestUWPOCRvsTesseractOCR() Local $sFileOpenDialog = FileOpenDialog("Select images to process", @ScriptDir & "\", "Images (*.jpg;*.png;*.gif;*.tif;*.bmp)", BitOR($FD_FILEMUSTEXIST, $FD_MULTISELECT)) Local $aFiles = StringSplit($sFileOpenDialog, "|", 1) Local $sImagePath = "" For $i = 2 To $aFiles[0] $sImagePath = $aFiles[$i] _GUIComparation($sImagePath, _UWPOCR_GetText($sImagePath), _GetTesseractOCRText($sImagePath)) Next EndFunc ;==>_TestUWPOCRvsTesseractOCR Func _GUIImageProcessed($sTitle, $sImagePath) _GDIPlus_Startup() Local Const $iW = @DesktopWidth, $iH = @DesktopHeight Local $hImage = _GDIPlus_ImageLoadFromFile($sImagePath) ;create a GDI bitmap by capturing full screen of the desktop Local $iWImage = _GDIPlus_ImageGetWidth($hImage) Local $iHImage = _GDIPlus_ImageGetHeight($hImage) If $iWImage > $iW Or $iHImage > $iH Then $iWImage = Int($iWImage / 1.5) $iHImage = Int($iHImage / 1.5) EndIf Local $hBitmap_Scaled = _GDIPlus_ImageResize($hImage, $iWImage, $iHImage) ;resize image Local $hGUI = GUICreate($sTitle, $iWImage, $iHImage, -1, -1) ;create a test gui to display the resized image GUISetState(@SW_SHOW) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, 0, 0) ;display scaled image ;cleanup resources _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_ImageDispose($hImage) _GDIPlus_BitmapDispose($hBitmap_Scaled) _GDIPlus_Shutdown() Return $hGUI EndFunc ;==>_GUIImageProcessed Func _GUIComparation($sTitle, $sUWPOCRText, $sTesseractText) Local $hGUIImage = _GUIImageProcessed($sTitle, $sTitle) GUIRegisterMsg($WM_NCHITTEST, _WM_NCHITTEST) Local $iWidth = @DesktopWidth - 100 Local $iHeight = @DesktopHeight - 100 Local $hWindow = GUICreate($sTitle, $iWidth, $iHeight) GUISetBkColor(0x000000) Local $idtxtUWPOCR = GUICtrlCreateEdit($sUWPOCRText, 0, 30, ($iWidth / 2) - 5, $iHeight - 30, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUICtrlSetFont(-1, 11) Local $idtxtTesseract = GUICtrlCreateEdit($sTesseractText, ($iWidth / 2) + 5, 30, ($iWidth / 2) - 5, $iHeight - 30, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUICtrlSetFont(-1, 11) GUICtrlCreateLabel("UWPOCR Output", 1, 5, ($iWidth / 2) - 5, 25, $SS_CENTER) GUICtrlSetColor(-1, 0xffffff) GUICtrlSetFont(-1, 15) GUICtrlCreateLabel("Tesseract Output", ($iWidth / 2) + 5, 5, ($iWidth / 2) - 5, 25, $SS_CENTER) GUICtrlSetColor(-1, 0xffffff) GUICtrlSetFont(-1, 15) GUISetState(@SW_SHOW, $hWindow) WinActivate($hGUIImage) WinMove($hGUIImage, "", Default, $iHeight / 2) MsgBox(0, "Info", "Click to continue...") GUIDelete($hWindow) GUIDelete($hGUIImage) EndFunc ;==>_GUIComparation Func _WM_NCHITTEST($hWnd, $uMsg, $wParam, $lParam) Return $HTCAPTION EndFunc ;==>_WM_NCHITTEST Func _GetTesseractOCRText($sImagePath) Local $sFileOutText = @ScriptDir & "\output" RunWait('"' & $g_sTesseractPath & '" "' & $sImagePath & '" "' & $sFileOutText & '"', "", @SW_HIDE) Local $sOutText = FileRead($sFileOutText & ".txt") FileDelete($sOutText) Return $sOutText EndFunc ;==>_GetTesseractOCRText Saludos
    1 point
  13. Melba23

    Show Password box

    SeverMessage, There certainly is an easier way: #include <GUIConstantsEx.au3> #include <EditConstants.au3> Global $PassStart = IniRead("Config.ini", "Config", "Password", "Default Value") $hGUI = GUICreate("Test", 500, 500) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD)) $cCheck = GUICtrlCreateCheckbox("Show Password", 10, 50, 150, 20) GUICtrlSetData($cInput, $PassStart) GUISetState() ;Retrieve the ASCII value of the default password char $sDefaultPassChar = GUICtrlSendMsg($cInput, $EM_GETPASSWORDCHAR, 0, 0) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cCheck If GUICtrlRead($cCheck) = $GUI_CHECKED Then GUICtrlSendMsg($cInput, $EM_SETPASSWORDCHAR, 0, 0) GUICtrlSetData($cCheck, "Show Password") Else GUICtrlSendMsg($cInput, $EM_SETPASSWORDCHAR, $sDefaultPassChar, 0) GUICtrlSetData($cCheck, "Hide Password") EndIf GUICtrlSetState($cInput, $GUI_FOCUS) EndSwitch WEndPlease ask if you have any questions. M23
    1 point
  14. #Include <GUIConstantsEx.au3> #Include <WinAPI.au3> Global $Over = False $Form1 = GUICreate('Form1', 230, 297, 303, 543) $Button1 = GUICtrlCreateButton('detect pointer', 80, 100, 75, 25) $Button2 = GUICtrlCreateButton('FREEZE', 80, 128, 75, 25) GUISetState(@SW_SHOW) $hWnd = ControlGetHandle(WinGetHandle('Form1'), '', '[CLASS:Button; INSTANCE:1]') While 1 $tPoint = _WinAPI_GetMousePos() If _WinAPI_WindowFromPoint($tPoint) = $hWnd Then If Not $Over Then ; Do something ConsoleWrite('Over' & @CR) $Over = 1 EndIf Else If $Over Then ; Do something ConsoleWrite('Lost' & @CR) $Over = 0 EndIf EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEndBut if it's AutoIt window, you need to use GUIGetCursorInfo().
    1 point
×
×
  • Create New...