AutoSmitty Posted October 2, 2008 Share Posted October 2, 2008 I am receiving this below message from autoIt and I'm not sure why I'm getting it._WinAPI_ CopyIcon: The operation completed successfullyThe code below is a snippet from my script. The script runs in a While 1 loop any runs 24hours 7 days a week. The script normally runs without any problems but maybe once or twice a week I recevie the above message. The message is followed by a OK button and the script stops running. The script is design to rotate through applications running on a workstation and capture the application images and save them to a jpeg file.$ovoatm_cics = WinGetHandle("HP OpenView Operations for UNIX [hpovo1] [cics_prod]") _ScreenCapture_CaptureWnd(@MyDocumentsDir & "\GDIPlus_Image" & $cnt & ".jpg", $ovoatm_cics) Sleep(2000) ;resize image for Samsung bigscreen _ImageResize("C:\Documents and Settings\Magic_Net\My Documents\GDIPlus_Image" & $cnt & ".jpg", "C:\SnagImage\SNAG-conveyor" & $cnt & ".jpg", 1300, 600); MagicNet.htmlWend ;Define all functions ;Resize image funtion Func _ImageResize($sInImage, $sOutImage, $iW, $iH) Local $hWnd, $hDC, $hBMP, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0 ;OutFile path, to use later on. Local $sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1)) ;OutFile name, to use later on. Local $sOF = StringMid($sOutImage, StringInStr($sOutImage, "\", 0, -1) + 1) ;OutFile extension , to use for the encoder later on. Local $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1)) ; Win api to create blank bitmap at the width and height to put your resized image on. $hWnd = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($hWnd) $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) _WinAPI_ReleaseDC($hWnd, $hDC) ;Start GDIPlus _GDIPlus_Startup() ;Get the handle of blank bitmap you created above as an image $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP) ;Load the image you want to resize. $hImage2 = _GDIPlus_ImageLoadFromFile($sInImage) ;Get the graphic context of the blank bitmap $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1) ;Draw the loaded image onto the blank bitmap at the size you want _GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iW) ;Get the encoder of to save the resized image in the format you want. $CLSID = _GDIPlus_EncodersGetCLSID($Ext) $sOutImage = $sOP & $sOF ;Save the new resized image. _GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID) ;Clean up and shutdown GDIPlus. _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _GDIPlus_GraphicsDispose ($hGraphic) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown()EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now