Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/19/2017 in all areas

  1. SmOke_N

    strange error

    That's true, it will still work, any variable outside of a function is declared global and any inside a local. But, it's bad practice in many eyes to just make yourself or others assume, plus other languages aren't so lenient. It wasn't the declaration that fixed the issue, it was putting the variable above the function that called the function that used the variable. eg. Your hotkey calls "due()", due() uses the global variable $a, because the code works from the top down, due() was checked before the global variable $a was declared
    1 point
  2. @rayane888 Look at FileGetAttrib in the help file
    1 point
  3. mikell

    extract XML

    Very basically it could be this #Include <Array.au3> $s = FileRead("test.xml") Local $res[0][9] $s = StringStripWS(StringRegExpReplace(StringReplace(StringReplace($s, "</v><v>", "|"), "<v /><v>", @crlf), "<.*?>", ""), 3) _ArrayAdd($res, $s) _ArrayDisplay($res)
    1 point
  4. Thanks. I didn't realize that the JSON Arrays were "just arrays." Solution provided below for others. #Include "JSon.au3" Local $Json = '{"name":"John","cars":[ "Ford", "BMW", "Fiat", "Chevy" ]}' ;Correctly returns a count of 2 elements (name and cars) Local $Obj = JSon_Decode($Json) ConsoleWrite("count root: " & Json_ObjGetCount($Obj) & @CRLF) ;Returns error Variable must be of type "Object" ;Local $Cars = Json_ObjGet($Obj, '["cars"][0]') ;ConsoleWrite("count cars: " & Json_ObjGetCount($aCars) & @CRLF) ;Solution from TheDcoder Local $aCars = Json_Get($Obj, '["cars"]') ConsoleWrite("count cars: " & UBound($aCars) & @CRLF) ;Walking the array For $iCurrentCar = 0 To UBound($aCars) - 1 ;zero-based array ConsoleWrite("Car '" & $iCurrentCar & "' of '" & UBound($aCars) & "' is '" & _ Json_Get($Obj, '["cars"][' & $iCurrentCar & ']') & "'" & @CRLF) Next
    1 point
  5. Personaly I do not must to imagine this, this is my daily work route EDIT: in AutoIt of course,
    1 point
  6. Hi, Give you some solution for tab control from me. FlatTab.au3 #include-once #include <GDIPlus.au3> #include <Array.au3> #include "GUICtrlOnHover.au3" Global $FlatUIColor = DllStructCreate("struct;float back;float fore;float frame;endstruct;") $FlatUIColor.back = 0x3C4649 $FlatUIColor.fore = 0x23A86D ;0x3498db $FlatUIColor.frame = 0x2D2F31 Global Const $tObjTabEx = "hwnd hwnd;byte ctrl;byte ctab;" & _ "byte count;byte current;int next;" & _ "int width;int x;int y;" Global Const $tObjTabBtnEx = "byte ctrl;byte ctab;byte idtab;" & _ "wchar text[255];" Global $____aTabList[1] = [0] Global $____aTabBtnList[1] = [0] Func FlatTab_Create($hWnd, $Left, $Top, $Width, $Height) GUISwitch($hWnd) Local $oObj = DllStructCreate($tObjTabEx) _ArrayAdd($____aTabList, $oObj) $____aTabList[0] += 1 $oObj.hwnd = $hWnd $oObj.ctrl = GUICtrlCreatePic("", $Left, $Top+25, $Width, $Height-50) GUICtrlSetResizing($oObj.ctrl, 802) GUICtrlSetState($oObj.ctrl, 128) $oObj.ctab = GUICtrlCreateTab(-99, -99, 1, 1) GUICtrlSetState($oObj.ctab, 128) Local $aBmp = _GDIPlus_BitmapCreateFromScan0($Width, $Height-50) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($aBmp) Local $hPen = _GDIPlus_PenCreate($FlatUIColor.frame+0xFF000000, 4) Local $hBrush = _GDIPlus_BrushCreateSolid($FlatUIColor.frame+0xFF000000) _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $Width, $Height-50, $hPen) _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $Width, $Height-50, $hBrush) _GDIPlus_GraphicsClear($hGfx, $FlatUIColor.frame+0xFF000000) Local $hBmp = _GDIPlus_BitmapCreateDIBFromBitmap($aBmp) _GDIPlus_BitmapDispose($aBmp) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_PenDispose($hPen) _WinAPI_DeleteObject(GUICtrlSendMsg($oObj.ctrl, 0x0172, 0, $hBmp)) _WinAPI_DeleteObject($hBmp) $oObj.width = $Width $oObj.x = $Left $oObj.y = $Top $oObj.current = "" $oObj.count = 0 $oObj.next = $Left Return $oObj EndFunc Func FlatTab_AddTab($Ctrl, $Text) GUISwitch($Ctrl.hwnd) GUICtrlCreateTabItem("") Local $oObj = DllStructCreate($tObjTabBtnEx) _ArrayAdd($____aTabBtnList, $oObj) $____aTabBtnList[0] += 1 $oObj.ctrl = GUICtrlCreatePic("", $Ctrl.next, $Ctrl.y, 80, 25) GUICtrlSetResizing($oObj.ctrl, 802) _GUICtrl_OnHoverRegister($oObj.ctrl, 'FlatTab_EventHover', 'FlatTab_EventHover', 'FlatTab_EventClick', 'FlatTab_EventClick') $oObj.count +=1 $oObj.idtab = GUICtrlCreateTabItem($oObj.count) $oObj.text = $Text If $Ctrl.current <> "" Then Local $Prev = FlatTab_GetObjTabBtnFromCtrl($Ctrl.current) FlatTab_Draw($Prev.ctrl, $Prev.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000) EndIf FlatTab_Draw($oObj.ctrl, $Text, 0xFFFFFFFF, $FlatUIColor.frame+0xFF000000) $Ctrl.current = $oObj.ctrl $oObj.ctab = $Ctrl.ctab $Ctrl.next += 80 GUICtrlSetState($oObj.idtab, 16) Return $oObj.idtab EndFunc Func FlatTab_EventHover($Ctrl, $Mode) Local $Obj1 = FlatTab_GetObjTabFromCtrl($Ctrl) If $Obj1.current = $Ctrl Then Return Local $Obj2 = FlatTab_GetObjTabBtnFromCtrl($Ctrl) Switch $Mode Case 1 FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF151515) Case 2 FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000) EndSwitch EndFunc Func FlatTab_EventClick($Ctrl, $Mode) If $Mode = 2 Then Local $Obj1 = FlatTab_GetObjTabFromCtrl($Ctrl) If $Obj1.current = $Ctrl Then Return Local $Obj2 = FlatTab_GetObjTabBtnFromCtrl($Ctrl) Local $Obj3 = FlatTab_GetObjTabBtnFromCtrl($Obj1.current) FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.frame+0xFF000000) FlatTab_Draw($Obj3.ctrl, $Obj3.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000) GUICtrlSetState($Obj2.idtab, 16) $Obj1.current = $Ctrl EndIf EndFunc Func FlatTab_GetObjTabFromCtrl($Ctrl) Local $Obj2, $Index Local $Obj = FlatTab_GetObjTabBtnFromCtrl($Ctrl) If $____aTabList[0] = 0 Then Return False For $Index = $____aTabList[0] To 1 Step -1 $Obj2 = $____aTabList[$Index] If $Obj2.ctab == $Obj.ctab Then Return $____aTabList[$Index] Next Return False EndFunc Func FlatTab_GetObjTabBtnFromCtrl($Ctrl) Local $Obj, $Index If $____aTabBtnList[0] = 0 Then Return False For $Index = $____aTabBtnList[0] To 1 Step -1 $Obj = $____aTabBtnList[$Index] If $Obj.ctrl == $Ctrl Then Return $____aTabBtnList[$Index] Next Return False EndFunc Func FlatTab_Draw($iCtrl, $Text, $Color = 0xFFFFFFFF, $BgColor = 0x00FFFFFF) Local $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iCtrl)) Local $aPos = ControlGetPos($hWnd, "", $iCtrl) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI Semibold") Local $hFont = _GDIPlus_FontCreate($hFamily, 10, 0) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $aPos[2], $aPos[3]) _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) Local $aBitmaps = _GDIPlus_BitmapCreateFromScan0($aPos[2], $aPos[3]) Local $aGfxCtxt = _GDIPlus_ImageGetGraphicsContext($aBitmaps) _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt, 2) _GDIPlus_GraphicsSetTextRenderingHint($aGfxCtxt, 5) _GDIPlus_GraphicsClear($aGfxCtxt, $BgColor) Local $hBrushColor = _GDIPlus_BrushCreateSolid($Color) _GDIPlus_GraphicsDrawStringEx($aGfxCtxt, $Text, $hFont, $tLayout, $hFormat, $hBrushColor) Local $aHBitmaps = _GDIPlus_BitmapCreateDIBFromBitmap($aBitmaps) _GDIPlus_BrushDispose($hBrushColor) _GDIPlus_FontDispose($hFont) _GDIPlus_BitmapDispose($aBitmaps) _GDIPlus_GraphicsDispose($aGfxCtxt) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _WinAPI_DeleteObject(GUICtrlSendMsg($iCtrl, 0x0172, 0, $aHBitmaps)) _WinAPI_DeleteObject($aHBitmaps) EndFunc FlatTab_Example.au3 #include "FlatTabEx.au3" #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup(); Global $hGUI = GUICreate("FlatTab Example", 450, 290); GUISetBkColor(0x3C4649, $hGUI); GUISetFont(10, 400, 0, "Segoe UI", $hGUI, 5); Global $Tab = FlatTab_Create($hGUI, 10, 10, 430, 290); ;================================================= FlatTab_AddTab($Tab, "Tab 1"); GUICtrlCreateLabel("This is Tab 1", 30, 50); GUICtrlSetColor(-1, 0xFFFFFF); GUICtrlCreateButton("Button 1", 30, 100, 75, 25); GUICtrlCreateButton("Button 2", 120, 100, 75, 25); ;================================================= FlatTab_AddTab($Tab, "Tab 2"); GUICtrlCreateLabel("This is Tab 2", 30, 50); GUICtrlSetColor(-1, 0xFFFFFF); GUICtrlCreateButton("Button 3", 210, 100, 75, 25); GUICtrlCreateButton("Button 4", 30, 150, 75, 25); ;================================================= FlatTab_AddTab($Tab, "Tab 3"); GUICtrlCreateLabel("This is Tab 3", 30, 50); GUICtrlSetColor(-1, 0xFFFFFF); GUICtrlCreateButton("Button 5", 120, 150, 75, 25); GUICtrlCreateButton("Button 6", 210, 150, 75, 25); ;================================================= GUICtrlCreateTabItem(""); GUISetState(); Do Sleep(10); Until GUIGetMsg() = -3;
    1 point
  7. Yes, but this is not really the place to ask. Send me a PM and we can discuss a little further. I make no guarantees I will do it and the money would be donated to AutoIt instead.
    1 point
  8. The best way to think of this forum is simple. It is a classroom. Not a take away restaurant. You came in here to order food, not learn. We don't have food here. We teach people.
    1 point
  9. BrewManNH

    ListView Delete

    _GUICtrlListView_GetItemCount = Find out how many rows are in the listview For...Next = Loop through the listview using the count obtained from above, the list view should be traversed in reverse ($Count to 0 Step -1) _GUICtrlListView_GetItemText = retrieve the text of the listview row you're looking for If...Endif = compare the text from above to a blank string, if blank then... _GUICtrlListView_DeleteItem = Delete the listview row
    1 point
  10. Here is an example #include <ClipBoard.au3> #include <GDIPlus.au3> OnAutoItExitRegister("_EXITLib") Opt("GUIONEVENTMODE", True) Global $avi, $user, $Startcap, $startwebcam, $RecordSt, $Dirsv, $lastGetport, $listeDrivercapt, $Sav, $i, $Exittest __Webcamini() _GDIPlus_Startup() $Dirsv = @ScriptDir & "\Webcam_Snap" If Not FileExists($Dirsv) Then DirCreate($Dirsv) $Dirsv = FileGetShortName($Dirsv) Global $Form1 = GUICreate("Form1", 473, 376) GUISetOnEvent(-3, "_EXIT") Global $Combo1 = GUICtrlCreateCombo("", 89, 8, 273, 25, 2097155) Global $Button1 = GUICtrlCreateButton("Start", 377, 6, 82, 25) GUICtrlSetOnEvent($Button1, "__Start") GUICtrlCreateLabel("Select camera", 14, 10, 72, 17) Global $Checkbox1 = GUICtrlCreateCheckbox("Save Pic", 331, 37, 65, 17) Global $Checkbox2 = GUICtrlCreateCheckbox("Record", 401, 37, 57, 17) GUICtrlSetOnEvent($Checkbox2, "__RecordSt") GUICtrlCreateGraphic(9, 64, 455, 304) GUICtrlSetColor(-1, 0x000000) Global $Inputtext = GUICtrlCreateInput(" By Celtic88 !", 14, 35, 297, 21) GUISetState() $listeDrivercapt = __GetlisteDrivercapt() _Cheklist() While 1 If BitAND(GUICtrlRead($Checkbox1), 1) Then $i += 1 $Sav = $Dirsv & "\Snap_" & $i & "_.jpg" Else $Sav = "" EndIf Send('{PRINTSCREEN}') __SaveImage("", 455, 304, GUICtrlRead($Inputtext) & @CRLF & " Test", 0, 0, 20, $Sav, $Form1) Sleep(100) If $Exittest Then ExitLoop WEnd While 1 If $Startcap Then __Snapwebcam() Else Sleep(100) EndIf WEnd Func __Snapwebcam() If BitAND(GUICtrlRead($Checkbox1), 1) Then $i += 1 $Sav = $Dirsv & "\Snap_" & $i & "_.jpg" Else $Sav = "" EndIf ;__SenToFile($startwebcam, $Dirsv & "\Snap.bmp") ;__SaveImage($Dirsv & "\Snap.bmp", 455, 304, GUICtrlRead($Inputtext) & @CRLF & _Date(), 0, 0, 20, $Sav, $Form1) ;FileDelete($Dirsv & "\Snap.bmp") __SenTobmpclip($startwebcam) __SaveImage("", 455, 304, GUICtrlRead($Inputtext) & @CRLF & _Date(), 0, 0, 20, $Sav, $Form1) EndFunc ;==>__Snapwebcam Func _Date() Return " [" & @MDAY & "\" & @MON & "\" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & "] " EndFunc ;==>_Date Func __Start() $Exittest = 1 If $Startcap Then If $RecordSt Then _WebcamRecordStop($startwebcam) $RecordSt = 0 GUICtrlSetState($Checkbox2, 4) EndIf __Stopwebcam($startwebcam) $Startcap = 0 GUICtrlSetData($Button1, "Start") Else Local $Getport = _Cheklist(GUICtrlRead($Combo1)) If @error Then Return If $startwebcam <> "" And $Getport = $lastGetport Then __Starttwebcam($startwebcam) Else $startwebcam = __startwebcam($Getport) If @error Then $startwebcam = "" MsgBox(16, "Error", "Failed to connect to device!", 0, $Form1) Return EndIf $lastGetport = $Getport EndIf $Startcap = 1 GUICtrlSetData($Button1, "Stop") EndIf EndFunc ;==>__Start Func _Cheklist($op = "") For $i = 1 To $listeDrivercapt[0] If $op = "" Then GUICtrlSetData($Combo1, $listeDrivercapt[$i], $listeDrivercapt[1]) Else If $op = $listeDrivercapt[$i] Then Return $i - 1 EndIf EndIf Next Return SetError(2) EndFunc ;==>_Cheklist Func __RecordSt() If $Startcap = 0 Then MsgBox(16, "Error", "Click Start, prior to using video recording !", 0, $Form1) GUICtrlSetState($Checkbox2, 4) Return EndIf If $RecordSt Then _WebcamRecordStop($startwebcam) $RecordSt = 0 Else Local $sPath = FileSaveDialog('Save to...', @WorkingDir, 'Record (*.Avi)', 24, '', $Form1) If @error Then Return WinSetTitle($Form1, '', 'Wait..') _WebcamRecordStart($startwebcam, $sPath) MsgBox(0, '', 'Start webcam video recording...' & @CRLF & 'Click "OK" !', 0, $Form1) $RecordSt = 1 EndIf EndFunc ;==>__RecordSt Func _EXIT() Exit EndFunc ;==>_EXIT Func _EXITLib() If $RecordSt Then _WebcamRecordStop($startwebcam) If $Startcap Then __Stopwebcam($startwebcam) __Disconwebcam($startwebcam) __Dllclose() _GDIPlus_Shutdown() EndFunc ;==>_EXITLib Func __startwebcam($Port = 0) Local Const $WS_CHILD = 0x40000000 Local Const $WM_CAP_DRIVER_CONNECT = 1024 + 10 Local $cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", $WS_CHILD, "int", 0, _ "int", 0, "int", 0, "int", 0, "hwnd", GUICreate("", 0, 0), "int", 1) $cap = $cap[0] Local $wb_connect $wb_connect = DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_DRIVER_CONNECT, "int", $Port, "int", 0) ;;Here If $wb_connect[0] = 0 Then For $p = 1 To 20 $wb_connect = DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_DRIVER_CONNECT, "int", $Port, "int", 0) If $wb_connect[0] = 1 Then ExitLoop If $p = 20 Then WinKill(HWnd($cap)) ; Error connecting to device close window Return SetError(1) EndIf Next EndIf GUISetState(@SW_DISABLE) Return $cap EndFunc ;==>__startwebcam Func __SenTobmpclip($cap) Local Const $WM_CAP_GRAB_FRAME_NOSTOP = 1024 + 61 Local Const $WM_CAP_EDIT_COPY = 1024 + 30 DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_EDIT_COPY, "int", 0, "int", 0) EndFunc ;==>__SenTobmpclip Func __SenToFile($cap, $savto) Local Const $WM_CAP_GRAB_FRAME_NOSTOP = 1024 + 61 Local Const $WM_CAP_FILE_SAVEDIBA = 1024 + 25 DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $savto) EndFunc ;==>__SenToFile Func _WebcamRecordStart($cap, $savto) Local Const $WM_CAP_FILE_SET_CAPTURE_FILEA = 1024 + 20 Local Const $WM_CAP_SEQUENCE = 1024 + 62 DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_FILE_SET_CAPTURE_FILEA, "int", 0, "str", $savto) DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_SEQUENCE, "int", 0, "int", 0) EndFunc ;==>_WebcamRecordStart Func _WebcamRecordStop($cap) Local Const $WM_CAP_STOPRC = 1024 + 68 DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_STOPRC, "int", 0, "int", 0) EndFunc ;==>_WebcamRecordStop Func __Starttwebcam($cap) Local Const $WM_CAP_STArt = 1024 DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_STArt, "int", 0, "int", 0) EndFunc ;==>__Starttwebcam Func __Stopwebcam($cap) Local Const $WM_CAP_STOP = 1024 + 181 DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_STOP, "int", 0, "int", 0) EndFunc ;==>__Stopwebcam Func __Disconwebcam($cap) Local Const $WM_CAP_DRIVER_DISCONNECT = 1024 + 11 DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0) WinKill(HWnd($cap)) EndFunc ;==>__Disconwebcam Func __Webcamini() $avi = DllOpen("avicap32.dll") $user = DllOpen("user32.dll") EndFunc ;==>__Webcamini Func __Dllclose() DllClose($user) DllClose($avi) EndFunc ;==>__Dllclose Func __GetlisteDrivercapt() Local $StructName = DllStructCreate("char[1024]") Local $aRslt, $Arrymdriv[1] For $i = 0 To 99 $aRslt = DllCall($avi, "bool", "capGetDriverDescriptionA", "dword", $i, "ptr", DllStructGetPtr($StructName), "dword", DllStructGetSize($StructName), "int", 0, "int", 0) If @error Then Return SetError(1) If $aRslt[0] Then ReDim $Arrymdriv[$i + 2] $Arrymdriv[0] = $i + 1 $Arrymdriv[$i + 1] = DllStructGetData($StructName, 1) Else ExitLoop EndIf Next $StructName = 0 Return $Arrymdriv EndFunc ;==>__GetlisteDrivercapt Func __SaveImage($sFilePath, $Width, $Height, $stext, $_X, $_Y, $_Z, $sFile, $hGUI) Local $Result, $ret, $sCLSID, $hImage, $hBitmap = 0 If $sFilePath = "" Then _ClipBoard_Open(0) $hBitmap = _ClipBoard_GetDataEx($CF_BITMAP) _ClipBoard_Close() If Not $hBitmap Then Return 0 EndIf $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) _WinAPI_DeleteObject($hBitmap) Else $hImage = _GDIPlus_ImageLoadFromFile($sFilePath) EndIf $hImage = _GDIPlus_ScaleImage($hImage, $Width, $Height) If $stext <> "" Then Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) Local $hFamily = _GDIPlus_FontFamilyCreate("Arial") Local $hFont = _GDIPlus_FontCreate($hFamily, $_Z, 1) Local $hFormat = _GDIPlus_StringFormatCreate(0x4000) Local $hBrush2 = _GDIPlus_BrushCreateSolid(0xffffffff) Local $hPen = _GDIPlus_PenCreate(0xC4000000, 1) Local $tLayout = _GDIPlus_RectFCreate($_X, $_Y, $Width, $Height) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $stext, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGraphic, $stext, $hFont, $aInfo[0], $hFormat, $hBrush2) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush2) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_GraphicsDispose($hGraphic) EndIf If $hGUI <> "" Then $hGraphicGui = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphicGui, $hImage, 0, 0) _GDIPlus_GraphicsDispose($hGraphicGui) EndIf If $sFile <> "" Then $sCLSID = _GDIPlus_EncodersGetCLSID("JPG") $Result = _GDIPlus_ImageSaveToFileEx($hImage, $sFile, $sCLSID, 0) EndIf _GDIPlus_ImageDispose($hImage) ClipPut('') Return $Result EndFunc ;==>__SaveImage Func _GDIPlus_ScaleImage($hImage, $iW, $iH) ;coded by UEZ 2012 Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) $hBitmap = $hBitmap[6] Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsDrawImageRect($hBmpCtxt, $hImage, 0, 0, $iW, $iH) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hBmpCtxt) Return $hBitmap EndFunc ;==>_GDIPlus_ScaleImage
    1 point
×
×
  • Create New...