Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/15/2021 in all areas

  1. Try this: ;Coded by UEZ build 2021-05-14 beta #include <GDIPlus.au3> #include <WinAPIFiles.au3> Global $sImageFile = FileOpenDialog("Select an GDI+ supported image", "", "Images (*.jpg;*.bmp;*.png;*.gif;*.tif;*.tiff)") If @error Then Exit _GDIPlus_Startup() Global $hImage = _GDIPlus_ImageLoadFromFile($sImageFile) $sImageFile = StringMid($sImageFile, StringInStr($sImageFile, "\", 0, -1) + 1) $sImageFile = @ScriptDir & "\" & StringMid($sImageFile, 1, StringLen($sImageFile) - 4) & ".cur" _GDIPlus_CreateCursorFileFromImage($hImage, $sImageFile, 32, 32) If @error Then MsgBox($MB_ICONERROR, "Error", "Something went wrong!", 10) Else MsgBox($MB_ICONINFORMATION, "Information", "Cursor file has been created. Check out: " & $sImageFile, 10) EndIf _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GDIPlus_CreateCursorFileFromImage ; Version .......: v0.15 build 2021-05-14 beta ; Description ...: Converts a GDI+ support image to a windows cursor format and saves it to disk. ; Syntax ........: _GDIPlus_CreateCursorFileFromImage($hImage[, $sFilename = ""[, $iWidth = 32[, $iHeight = 32]]]) ; Parameters ....: $hImage - a handle value. ; $sFilename - [optional] a string value. Default is "". ; $iWidth - [optional] an integer value. Default is 32. ; $iHeight - [optional] an integer value. Default is 32. ; $iSpotX - [optional] an integer value. Default is 0. ; $iSpotY - [optional] an integer value. Default is 0. ; Return values .: True if file has been created ; Author ........: UEZ ; Modified ......: ; Remarks .......: If $sFilename is empty then the handle of the cursor will be returned instead. No animated cursor possible yet! ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _GDIPlus_CreateCursorFileFromImage($hImage, $sFilename = "", $iWidth = 32, $iHeight = 32, $iSpotX = 0, $iSpotY = 0) If $hImage = 0 Then Return SetError(1, 0, 0) Local $aDim = _GDIPlus_ImageGetDimension($hImage) If @error Then Return SetError(2, 0, 0) ;create image with scaled size $iWidth = $iWidth > 255 ? 255 : $iWidth < 1 ? 1 : $iWidth $iHeight = $iHeight > 255 ? 255 : $iHeight < 1 ? 1 : $iHeight Local Const $hImage_scaled = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $GDIP_PXF32ARGB) Local Const $hCanvas = _GDIPlus_ImageGetGraphicsContext($hImage_scaled) _GDIPlus_GraphicsSetInterpolationMode($hCanvas, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $iWidth, $iHeight) Local Const $hIcon = _GDIPlus_HICONCreateFromBitmap($hImage_scaled) _GDIPlus_GraphicsDispose($hCanvas) _GDIPlus_ImageDispose($hImage_scaled) If $hIcon = 0 Then Return SetError(3, 0, 0) Local $iErr = 0 If $sFilename <> "" Then If _WinAPI_SaveHICONToFile($sFilename, $hIcon) = 0 Then $iErr += 1 _WinAPI_DestroyIcon($hIcon) If $iErr Then Return SetError(4, $iErr, 0) Else Local $aIcon = _WinAPI_GetIconInfo($hIcon) Local $hCursor = _WinAPI_CreateIconIndirect($aIcon[5], $aIcon[4], $iSpotX, $iSpotY, False) If $hCursor = 0 Then $iErr += 1 _WinAPI_DestroyIcon($hIcon) If $iErr Then Return SetError(5, $iErr, 0) Return $hCursor EndIf Local $tagCur = "align 1;word;word ImageType;word NumberOfImgs;", $tagImgHeader = "byte Width;byte Height;byte PaletteColors;byte;word Format1;word Format2;dword Size;dword OffsetImg;" Local $tHeader = DllStructCreate($tagCur & $tagImgHeader), $iSize = DllStructGetSize($tHeader) ;read the header to the struct Local $nBytes Local $hFile = _WinAPI_CreateFile($sFilename, 2, 2) _WinAPI_ReadFile($hFile, $tHeader, $iSize, $nBytes) _WinAPI_CloseHandle($hFile) If $nBytes <> $iSize Then Return SetError(6, 0, 0) ;generate the file $nBytes = 0 $tHeader.ImageType = 2 $tHeader.Format1 = $iSpotX $tHeader.Format2 = $iSpotY $hFile = _WinAPI_CreateFile($sFilename, 2, 4) _WinAPI_SetFilePointer($hFile, 0) _WinAPI_WriteFile($hFile, $tHeader, $iSize, $nBytes) _WinAPI_CloseHandle($hFile) If $nBytes <> $iSize Then Return SetError(7, 0, 0) Return 1 EndFunc ;==>_GDIPlus_CreateCursorFileFromImage Almost, you must change 1 entry within the header of the cursor struct to become a cursor file.
    2 points
  2. p.s. I respect and try to learn from any form of coding, from anyone it comes from. I just wanted to "tease" a little with a little humor and with no intention of offending anyone, just a little healthy humor and possibly even stimulate some creative antagonism. I find satire amusing in general, without problems even if and when it is directed toward me .. grazie
    1 point
  3. Sure, this is fair swipe at my staid work. But no such criticism can be lodged against @mikell‘s creation. Take a look at the self-mulching action of the $res array! Capped off with the delightfully unexpected, if trenchant truncation: ReDim $res[$i+1][2] Bravissimi to you both!
    1 point
  4. Add this code and you'll see that everything works normally except column resizing: ; No listview column resizing by dragging header dividers Local $hHeader = _GUICtrlListView_GetHeader( $idListView ) ;_WinAPI_SetWindowLong( $hHeader, $GWL_STYLE, _WinAPI_GetWindowLong( $hHeader, $GWL_STYLE ) + $HDS_NOSIZING ) ; AutoIt 3.3.14.5 issue DllCall( "user32.dll", "long_ptr", @AutoItX64 ? "SetWindowLongPtrW" : "SetWindowLongW", "hwnd", $hHeader, "int", $GWL_STYLE, "long_ptr", _ DllCall( "user32.dll", "long_ptr", @AutoItX64 ? "GetWindowLongPtrW" : "GetWindowLongW", "hwnd", $hHeader, "int", $GWL_STYLE )[0] + $HDS_NOSIZING )
    1 point
  5. Use the separate SciTE4AutoIt3 installer and this issue will be resolved (is configurable) #restore last session when selecting Open file from Explorer - Only available in SciTE4AutoIt3 version save.session.advanced=1 Jos
    1 point
  6. I was needing to enable and disable a network connection. I google and find a good C++ example using interfaces. so I ported to Autoit (ObjCreateInterface ) Global Const $NCME_DEFAULT = 0 Global Const $S_OK = 0 Global Const $sCLSID_ConnectionManager = '{BA126AD1-2166-11D1-B1D0-00805FC1270E}' Global Const $sIID_INetConnectionManager = '{C08956A2-1CD3-11D1-B1C5-00805FC1270E}' Global Const $sIID_IEnumNetConnection = '{C08956A0-1CD3-11D1-B1C5-00805FC1270E}' Global Const $sIID_INetConnection = '{C08956A1-1CD3-11D1-B1C5-00805FC1270E}' Global Const $sINetConnectionManager = "EnumConnections hresult(int;ptr*)" Global Const $sTag_IEnumNetConnection = "Next hresult(int;ptr*;ulong*)" Global Const $sTag_INetConnection = "Connect hresult();Disconnect hresult();Delete hresult();Duplicate hresult(wstr;ptr*);GetProperties hresult(ptr)" Global Const $sTag_NETCON_PROPERTIES = "byte guidId[16];ptr pszwName;ptr pszwDeviceName;dword Status;dword MediaType;dword dwCharacter;byte clsidThisObject[16];byte clsidUiObject[16]" Func NetWorkEnableDisable($sNetWorkName, $bEnable_Disable = true) Local $hResult = 0 Local $iCount = 0 Local $pIEnumNetConnection = 0 Local $oIEnumNetConnection = 0 Local $pConnection = 0 Local $tNETCON_PROPERTIES = 0 Local $tName = 0 Local $sNetName = "" Local $tDeviceName = 0 Local $oConnection = 0 Local $pPROPERTIES = 0 Local $tPtr = 0 Local $iState=0 Local $oNetCManager = ObjCreateInterface($sCLSID_ConnectionManager, $sIID_INetConnectionManager, $sINetConnectionManager) If IsObj($oNetCManager) Then ConsoleWrite("$oNetCManager:" & IsObj($oNetCManager) & @CRLF) $oNetCManager.EnumConnections($NCME_DEFAULT, $pIEnumNetConnection) If $pIEnumNetConnection Then ConsoleWrite("$pIEnumNetConnection: " & $pIEnumNetConnection & @CRLF) $oIEnumNetConnection = ObjCreateInterface($pIEnumNetConnection, $sIID_IEnumNetConnection, $sTag_IEnumNetConnection) If IsObj($oIEnumNetConnection) Then ConsoleWrite("$oIEnumNetConnection: " & IsObj($oIEnumNetConnection) & @CRLF) While ($oIEnumNetConnection.Next(1, $pConnection, $iCount) = $S_OK) ConsoleWrite("$pConnection: " & $pConnection & " $iCount: " & $iCount & @CRLF) $oConnection = ObjCreateInterface($pConnection, $sIID_INetConnection, $sTag_INetConnection) If IsObj($oConnection) Then $tNETCON_PROPERTIES = DllStructCreate($sTag_NETCON_PROPERTIES) $tPtr = DllStructCreate("ptr Pointer") ConsoleWrite("$oConnection: " & IsObj($oConnection) & @CRLF) $hResult = $oConnection.GetProperties(DllStructGetPtr($tPtr)) If SUCCEEDED($hResult) Then $tNETCON_PROPERTIES = DllStructCreate($sTag_NETCON_PROPERTIES, $tPtr.Pointer) $tName = DllStructCreate("wchar[260]", $tNETCON_PROPERTIES.pszwName) $sNetName = DllStructGetData($tName, 1) If $bEnable_Disable Then If $sNetName = $sNetWorkName Then If SUCCEEDED($oConnection.Connect()) Then DllCall("netshell.dll", "none", "NcFreeNetconProperties", "ptr", DllStructGetPtr($tNETCON_PROPERTIES)) Return True EndIf EndIf Else If $sNetName = $sNetWorkName Then If SUCCEEDED($oConnection.Disconnect()) Then DllCall("netshell.dll", "none", "NcFreeNetconProperties", "ptr", DllStructGetPtr($tNETCON_PROPERTIES)) Return True EndIf EndIf EndIf DllCall("netshell.dll", "none", "NcFreeNetconProperties", "ptr", DllStructGetPtr($tNETCON_PROPERTIES)) $tPtr = 0 $tName = 0 $tNETCON_PROPERTIES = 0 $oConnection = 0 Else Return False EndIf Else Return False EndIf WEnd Else Return False EndIf Else Return False EndIf Else Return False EndIf EndFunc ;==>NetWorkEnableDisable Func SUCCEEDED($hr) Return ($hr >= 0) EndFunc ;==>SUCCEEDED Saludos
    1 point
  7. Jos

    Parsing Command-line Args

    This is a portion of a utility i use to install/configure SUS and it takes several commandline options.. maybe it give s you some food for thought.. $install = 0 ; switch for client install $Force = 0 ; switch for forcing download of patches and installation/reboot $Batch = 0 ; indicator for asking confirmation $Status = 0 ; indicator for Showing SUS status $Susserver = ""; Sus server name $Password = ""; PSW for autologon after reboot ; $V_Arg = "Valid Arguments are:" & @LF $V_Arg = $V_Arg & " /batch - don't prompt for anything.. fail is something is missing." & @LF $V_Arg = $V_Arg & " /install - Install the Client and Update Registry." & @LF $V_Arg = $V_Arg & " /force - Force Software downloads and installation/reboot." & @LF $V_Arg = $V_Arg & " /s NAME - Target Susserver." & @LF $V_Arg = $V_Arg & " /p Password for userid " & EnvGet("USERNAME") & ", used for autologon after reboot." & @LF $V_Arg = $V_Arg & " /reset - Removes the local SUS information, pc will go to microsoft for updates." & @LF ; retrieve commandline parameters For $x = 1 to $CmdLine[0] Select Case $CmdLine[$x] = "/batch" $Batch = 1 writelog(" -- Running in Batch mode.") Case $CmdLine[$x] = "/install" $install = 1 Case $CmdLine[$x] = "/force" $Force = 1 Case $CmdLine[$x] = "/reset" RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate", "") MsgBox( 1, "SUS Utility", "Windows Update setting are reset.", 5) Exit Case $CmdLine[$x] = "/s" $x = $x + 1 $Susserver = $CmdLine[$x] Case $CmdLine[$x] = "/p" $x = $x + 1 $Password = $CmdLine[$x] Case $CmdLine[$x] = "/?" Or $CmdLine[$x] = "/h" Or $CmdLine[$x] = "/help" MsgBox( 1, "SUS Utility", "" & $v_Arg,) Exit Case Else MsgBox( 1, "SUS Utility", "Wrong commandline argument: " & $CmdLine[$x] & @LF & $v_Arg,) Exit EndSelect Next
    1 point
×
×
  • Create New...