Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/09/2022 in all areas

  1. 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
    2 points
  2. Add #RequireAdmin at the beginning so that the script runs as Administrator, OSK seems to be a privileged process so a non-admin process can't interact with it.
    1 point
  3. You can use a quicker approach where you keep previous value and compare with new value. I personally prefer a more "elegant" solution using WM_NOTIFY. Following both ways in same example : #include <GUIConstants.au3> #include <Constants.au3> #include <StructureConstants.au3> Global Const $UDN_DELTAPOS = -722 Global Const $tagNMUPDOWN = $tagNMHDR & ";int iPos;int iDelta" Global $hUpDown Example() Func Example() GUICreate("My GUI UpDown", -1, -1, -1, -1, $WS_SIZEBOX) Local $iStart = 2 Local $idInput = GUICtrlCreateInput($iStart, 10, 10, 100, 20) Local $idUpDown = GUICtrlCreateUpdown($idInput) $hUpDown = GUICtrlGetHandle($idUpDown) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idUpDown ConsoleWrite(GUICtrlRead($idInput) - $iStart & @CRLF) $iStart = GUICtrlRead($idInput) EndSwitch WEnd EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam), $tNMUPDOWN If $tNMHDR.hWndFrom = $hUpDown And $tNMHDR.Code = $UDN_DELTAPOS Then $tNMUPDOWN = DllStructCreate($tagNMUPDOWN, $lParam) ConsoleWrite($tNMUPDOWN.iPos & "/" & $tNMUPDOWN.iDelta & @CRLF) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
    1 point
  4. Yes it now uses the True condition as match all. You can create many more complex condition like the not condition. It will be more complicated. Take a look in the forum for more complex condition for filtering.
    1 point
×
×
  • Create New...