27 posts in this topic
I am busy with building a solution for change monitoring of VOIP call program and to be properly automated means among others need for some limited OCR functionality. Current works of others are way too much overkill for this case what makes the need to build it myself. But to do it properly I significantly have to increase my knowledge about digital graphics management.
For now I already have discovered here and there some mind blowing Autoit miracles what can be achieved with Windows own possibilities to manipulate that what is output to the monitor. And as far I can judge there are 2 options to process graphics without use of any external libraries like ImageMagick, FreeImage and so on. These are:
WinAPI GDIPlus It is for me quite obvious to have various holes in general understanding of graphics and it is once more very clear what advantages gives consistent general study in 1 or another official institutions like University. Cause there you are introduced into certain domain of knowledge in a way which usually has been perfected over long period of time. So you are not overloaded by stuff which requires a certain amount of information to be initially clear for you. For example, before starting to solve physics you first learn to read, count and so on and then move to subjects like physics.
Though in my case opportunity to study in such educational system I had only for 8 years, from my 7th to 15th year of age in the country that was falling apart now Ukraine but used to be USSR, was all what it was. After have immigrated to Netherlands possibilities to study further haven't occur. And this therefor causes often various implications when going deep in that or another field of practical knowledge acquiring for any needed physical result, like programming to perform enormous amount of tasks. In this particular case automating VOIP call program.
Anyway, right now I think the best direction to move is to concentrate on as basic as possible image management and if someone would maybe explain in general what is a pixel will definitely help. Particularly I am very curious about how to do picture manipulations in Autoit. Especially would help a lot to produce eventually following functions:
createImage($imageFileName, $width, $height, $color) readImagePixel($imageFileName, $x, $y) writeImagePixel($imageFileName, $x, $y) I do not know exactly how image is handled in computer but preferably above mentioned functions should deal with so far possible origin of graphics creation on computer. But nevertheless I definitely would love to hear any proposition for solution.
The problem with explaining screenshots:
VOIPConnect full Window Part of Window with control to monitor for changes Exact location of area where actual changes occur and have to be processed It comes down to a rectangle of approximately 51 pixel wide and 7 pixel high. In fact if I get to learn as far as to be able exactly read, write and compare 2 images consistently across different computers I could narrow down then even further the area to watch as little as a square of 2-5 pixels wide.
To finish here is last detail about particularly no need for ultra fast solution at all. This because it is needed only once when it is first run on a new computer and to have to wait few minutes while it is being set instead of just a few seconds make no sence.
This is it and what I too think to do beside this very particular case is to purify out beautiful generic Autoit functions for core image manipulation by using WinAPI or/and GDIPlus.
I'm trying to find how to draw an image (create a label in mspaint) and save it as .bmp. And set it to be a wallpaper
I also need to know what wallpaper is use now, for restore it when the script is closed.
What is the best way to do it? Do I need Gdi+ for it? I use this code (which I found here in forum) to set a .bmp file as wallpaper:
Func _ChangeWallpaper($sFile,$iType) ; Changes the wallpaper to $sFilename using $iType as: ; 1 Tiled ; 2 Centered ; 3 Stretched ; any other value (usually 0) unchanged ; ; Returns ; 0 if everything is allright. ; -1 if $sFile does not exist. @error is set to 1 ; -2 if £sFile is not a .bmp file. @error is set to 2 If Not FileExists($sFile) Then SetError(1) Return -1 EndIf If StringTrimLeft($sFile,StringInStr($sFile,'.',0,-1)) <> 'bmp' Then SetError(2) Return -2 EndIf Select Case $iType = 1 RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','1') RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','0') Case $iType = 2 RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','0') RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','0') Case $iType = 3 RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','0') RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','2') Case Else EndSelect RegWrite('HKCU\Control Panel\Desktop','Wallpaper','reg_sz',$sFile) DllCall("User32.dll","int","SystemParametersInfo","int",20,"int",0,"str",$sFile,"int",0) Return 0 EndFunc
The flow that I understand should be:
1) Check what wallpaper is in use now. I can find the path to it by going to registry key named "wallpaper" here :[HKEY_CURRENT_USER\Control Panel\Desktop]
2) Create a file mspaint
3) Create a label with its properties (size,color) in this file
3) Save this file in some temporary directory
4) Set a created file as a wallpaper using the above code
5) When the script is closed restore the old wallpaper.
So again, my question is how to create a .bmp file with label in it?
how can I fit the image when the GUI is maximized? I would like to always measure the 50% height and width of the GUI and is always in the bottom right poistion, and does not lose its quality.
#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Array.au3> #include <WinAPI.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124,BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_TABSTOP)) _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir&"\img.jpg") $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form1) $resimg = _GDIPlus_ImageResize($hImage,200,300) _GDIPlus_GraphicsDrawImage($hGraphics, $resimg, 0, 0) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") ;GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUISetState(@SW_SHOW,$Form1) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func MY_WM_PAINT($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _WinAPI_RedrawWindow($Form1, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphics, $resimg, 300, 0) _WinAPI_RedrawWindow($Form1, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_PAINT ;Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) ; #forceref $hWnd, $iMsg, $iwParam, $ilParam ; Local $xClient, $yClient ; $xClient = BitAND($ilParam, 0x0000FFFF) ; $yClient = BitShift($ilParam, 16) ; _WinAPI_RedrawWindow($Form1, 0, 0, $RDW_UPDATENOW) ; _GDIPlus_GraphicsDrawImage($hGraphics, $resimg, $xClient/2, $yClient/2) ; _WinAPI_RedrawWindow($Form1, 0, 0, $RDW_VALIDATE) ; ConsoleWrite($xClient & " "&$yClient&@CR) ; Return $GUI_RUNDEFMSG ;EndFunc
plz help explain between GDI+ and Winapi, is it desktop inside another desktop, 3 layer dimension?
i can't get the picture
1. u get desktop u can visual see
2. then u create GDI+ startup another desktop screen dimension?
3. then u have Winapi command inside GDI+, is this another desktop screen dimension? cuz GDI+ could create bitmap that is one dimension? Winapi get windowDC also another dimension?
plz help and explain, with picture would be nice, im not good with visualize ("dumb newbie"), still learning
newbie to programming world
I'm attempting to cobble together a replacement for the 64bit version of BGInfo that will run within WinPE 10/64. I've located a couple useful threads:
Between the two, they get me close (see code below), but for some reason GDI+ is not working the same within WinPE as it does in Windows 10. Bottomline is that the "Text" never get's written to WallPaper.
Here is what I have thus far. Any thoughts if any of the GDI commands might not work within WinPE? Any other way to achieve the same result (system information on the wallpaper in WinPE 10)?
#include <GDIPlus.au3> #include <Date.au3> _GDIPlus_Startup() $image = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\WallPaper.bmp") $imagegraphics = _GDIPlus_ImageGetGraphicsContext($image) $w = _GDIPlus_ImageGetWidth($image) $h = _GDIPlus_ImageGetHeight($image) $whitebrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $fontfamily = _GDIPlus_FontFamilyCreate("Arial") $font = _GDIPlus_FontCreate($fontfamily, 16) $stringformat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($stringformat, 2) $rect = _GDIPlus_RectFCreate(0, $h - $h + 100, $w - 25, $h) ;$rect = _GDIPlus_RectFCreate(100, 100, 200, 200) _GDIPlus_GraphicsDrawStringEx($imagegraphics, _Now() & @CRLF & @UserName & @CRLF & @ComputerName & @CRLF & @IPAddress1, $font, $rect, $stringformat, $whitebrush) _GDIPlus_ImageSaveToFile($image, @ScriptDir & "\NewWallPaper.bmp") _GDIPlus_ImageDispose($image) _GDIPlus_GraphicsDispose($imagegraphics) _GDIPlus_BrushDispose($whitebrush) _GDIPlus_FontFamilyDispose($fontfamily) _GDIPlus_FontDispose($font) _GDIPlus_StringFormatDispose($stringformat) _GDIPlus_Shutdown() _ChangeDesktopWallpaper(@ScriptDir & "\NewWallPaper.bmp", 2) Func _ChangeDesktopWallpaper($bmp, $style = 0) ;=============================================================================== ; ; Function Name: _ChangeDesktopWallPaper ; Description: Update WallPaper Settings ; Usage: _ChangeDesktopWallPaper(@WindowsDir & '\' & 'zapotec.bmp',1) ; Parameter(s): $bmp - Full Path to BitMap File (*.bmp) ; [$style] - 0 = Centered, 1 = Tiled, 2 = Stretched ; Requirement(s): None. ; Return Value(s): On Success - Returns 0 ; On Failure - -1 ; Author(s): FlyingBoz ; Thanks: Larry - DllCall Example - Tested and Working under XPHome and W2K Pro ; Excalibur - Reawakening my interest in Getting This done. ; ;=============================================================================== If Not FileExists($bmp) Then Return -1 ;The $SPI* values could be defined elsewhere via #include - if you conflict, ; remove these, or add if Not IsDeclared "SPI_SETDESKWALLPAPER" Logic Local $SPI_SETDESKWALLPAPER = 20 Local $SPIF_UPDATEINIFILE = 1 Local $SPIF_SENDCHANGE = 2 Local $REG_DESKTOP = "HKEY_CURRENT_USER\Control Panel\Desktop" If $style = 1 Then RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 1) RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 0) Else RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0) RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", $style) EndIf DllCall("user32.dll", "int", "SystemParametersInfo", _ "int", $SPI_SETDESKWALLPAPER, _ "int", 0, _ "str", $bmp, _ "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE)) Return 0 EndFunc ;==>_ChangeDesktopWallpaper Thanks for your time,