Leaderboard
Popular Content
Showing content with the highest reputation on 06/07/2022 in Posts
-
GuiBuilderPlus [updated March 24, 2024]
yahaosoft reacted to kurtykurtyboy for a topic
GuiBuilderPlus GuiBuilderPlus is a small, easy to use GUI designer for AutoIt. Originally created long ago as AutoBuilder by the user CyberSlug, enhanced as GuiBuilder by TheSaint, and further enhanced and expanded as GuiBuilderNxt by jaberwacky, GuiBuilderPlus is a continuation of their great work, with a focus on increased stability and usability followed by new features. ------ Yes, I have decided to bring back our old friend the GuiBuilder. This utility has a long history, which you can read about in TheSaint's Gui Creators topic, starting all the back back with CyberSlug's AutoBuilder. Even though I've hacked the original code to pieces in order to document and better understand what is going on, the essence of GuiBuilder still lives on! I am using the awesome updates from GuiBuilderNxt by jaberwacky as a starting point since he already did a lot of the hard work of parsing and updating the original code, plus I really like the layout that came about from that update. Unfortunately development seems to have stopped in 2016. Not sure how much interest there is in this, but suggestions and bug reports are welcome. See Full Changelog: Download the latest version: v1.3.0 (2024-03-24) GuiBuilderPlus v1.3.0 - 2024-03-24.zip FIXED: Wrong line endings when copying from code preview window FIXED: Issue changing properties when Obect Explorer window is not open FIXED: Issue when selecting controls under certain other conditions FIXED: SaveAs keyboard shortcut FIXED: Undo/Redo for Global property ADDED: Auto-size property for Labels, Buttons, and Inputs GitHub Repository: https://github.com/KurtisLiggett/GuiBuilderPlus1 point -
1 point
-
GUICtrlSetLimit only limits the horizontal scrolling. You have to use GUICtrlSetData to fill the list. Simply stop adding new entries when your limit has been reached.1 point
-
fraizor, Read the number of items in the list with _GUICtrlListBox_GetCount and, if it is over the required maximum, use _GUICtrlListBox_DeleteString to delete the early lines. M231 point
-
To add icon beside each menu item, use _GUICtrlMenu_GetItemBmp. If you need to convert Icon to Bmp, you can use _WinAPI_Create32BitHBITMAP. Now, if you want to add a vertical bar before the icons or change color, you will need use Owner-Draw mechanism which is not trivial. But I recall seeing a very old UDF to register WM_DRAWITEM and WM_MEASUREITEM notifications. It should get you started, although I cannot say if it is still working on recent OS.1 point
-
Looks like a context menu control. Not sure how to get the left side graphic, but you look at the _GUICtrlMenu_CreatePopup function to get started. Also, search for ContextMenu on the forum for more sophisticated examples (images and such). Let us know where you get stuck.1 point
-
@mLipokI googled and found this site. It describes the flatpickr object's methods, their parameters, etc. After that, it was simply some trial and error testing from the browser console.1 point
-
Altor, The simple way... #include <GUIConstantsEx.au3> #include <Array.au3> #include <GuiComboBox.au3> Local $Clients = ['Bobby', 'Joe', 'Susan', 'Alex', 'Yoda'] ;Create simple GUI $Form1 = GUICreate("Example", 150, 200) $List_Clients = GUICtrlCreateCombo("", 10, 10, 130, 200) GUICtrlSetData($List_Clients, _ArrayToString($Clients)) _GUICtrlComboBox_SetCurSel($List_Clients, 3) ; <<<----- set startup selection to 4TH entry GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $gui_event_close Exit Case $List_Clients MsgBox(0, 'Client', GUICtrlRead($List_Clients)) EndSwitch WEnd kylomas1 point
-
Regarding 1. Check out _GDIPlus_ImageScale() and _GDIPlus_ImageResize() but have in mind that resizing costs time which can decrease the FPS. 2. I don't have a web cam but it should be possible, too. Br, UEZ1 point
-
I created this after I developed because I was interested in the entry displaying when a folder was right clicked on. The entry will pass the folder name to your program via a commandline argument, so you'll have to use $CmdLine/$CmdLineRaw to access the folder that was selected. Any problems or suggestions then please post below. Thanks. UDF: #include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; #INDEX# ======================================================================================================================= ; Title .........: _ShellFolder ; AutoIt Version : v3.2.12.1 or higher ; Language ......: English ; Description ...: Create an entry in the shell contextmenu when selecting a folder, includes the program icon as well. ; Note ..........: ; Author(s) .....: guinness ; Remarks .......: Special thanks to KaFu for EnumRegKeys2Array() which I used as inspiration for enumerating the Registry Keys. ; =============================================================================================================================== ; #INCLUDES# ==================================================================================================================== ; None ; #GLOBAL VARIABLES# ============================================================================================================ ; None ; #CURRENT# ===================================================================================================================== ; _ShellFolder_Install: Creates an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu, but only displays when selecting a folder. ; _ShellFolder_Uninstall: Deletes an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu. ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; __ShellFolder_RegistryGet ......; Retrieve an array of registry entries for a specific key. ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ShellFolder_Install ; Description ...: Creates an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu, but only displays when selecting a file and folder. ; Syntax ........: _ShellFolder_Install($sText[, $sName = @ScriptName[, $sFilePath = @ScriptFullPath[, $sIconPath = @ScriptFullPath[, ; $iIcon = 0[, $fAllUsers = False[, $fExtended = False]]]]]]) ; Parameters ....: $sText - Text to be shown in the contextmenu. ; $sName - [optional] Name of the program. Default is @ScriptName. ; $sFilePath - [optional] Location of the program executable. Default is @ScriptFullPath. ; $sIconPath - [optional] Location of the icon e.g. program executable or dll file. Default is @ScriptFullPath. ; $iIcon - [optional] Index of icon to be used. Default is 0. ; $fAllUsers - [optional] Add to Current Users (False) or All Users (True) Default is False. ; $fExtended - [optional] Show in the Extended contextmenu using Shift + Right click. Default is False. ; Return values .: Success - Returns True ; Failure - Returns False and sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _ShellFolder_Install($sText, $sName = @ScriptName, $sFilePath = @ScriptFullPath, $sIconPath = @ScriptFullPath, $iIcon = 0, $fAllUsers = False, $fExtended = False) Local $i64Bit = '', $sRegistryKey = '' If $iIcon = Default Then $iIcon = 0 EndIf If $sFilePath = Default Then $sFilePath = @ScriptFullPath EndIf If $sIconPath = Default Then $sIconPath = @ScriptFullPath EndIf If $sName = Default Then $sName = @ScriptName EndIf If @OSArch = 'X64' Then $i64Bit = '64' EndIf If $fAllUsers Then $sRegistryKey = 'HKEY_LOCAL_MACHINE' & $i64Bit & 'SOFTWAREClassesFoldershell' Else $sRegistryKey = 'HKEY_CURRENT_USER' & $i64Bit & 'SOFTWAREClassesFoldershell' EndIf $sName = StringLower(StringRegExpReplace($sName, '.[^./]*$', '')) If StringStripWS($sName, 8) = '' Or FileExists($sFilePath) = 0 Then Return SetError(1, 0, False) EndIf _ShellFolder_Uninstall($sName, $fAllUsers) Local $iReturn = 0 $iReturn += RegWrite($sRegistryKey & $sName, '', 'REG_SZ', $sText) $iReturn += RegWrite($sRegistryKey & $sName, 'Icon', 'REG_EXPAND_SZ', $sIconPath & ',' & $iIcon) $iReturn += RegWrite($sRegistryKey & $sName & 'command', '', 'REG_SZ', '"' & $sFilePath & '" "%1"') If $fExtended Then $iReturn += RegWrite($sRegistryKey & $sName, 'Extended', 'REG_SZ', '') EndIf Return $iReturn > 0 EndFunc ;==>_ShellFolder_Install ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ShellFolder_Uninstall ; Description ...: Deletes an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu. ; Syntax ........: _ShellFolder_Uninstall([$sName = @ScriptName[, $fAllUsers = False]]) ; Parameters ....: $sName - [optional] Name of the Program. Default is @ScriptName. ; $fAllUsers - [optional] Was it added to Current Users (False) or All Users (True) Default is False. ; Return values .: Success - Returns True ; Failure - Returns False and sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _ShellFolder_Uninstall($sName = @ScriptName, $fAllUsers = False) Local $i64Bit = '', $sRegistryKey = '' If $sName = Default Then $sName = @ScriptName EndIf If @OSArch = 'X64' Then $i64Bit = '64' EndIf If $fAllUsers Then $sRegistryKey = 'HKEY_LOCAL_MACHINE' & $i64Bit & 'SOFTWAREClassesFoldershell' Else $sRegistryKey = 'HKEY_CURRENT_USER' & $i64Bit & 'SOFTWAREClassesFoldershell' EndIf $sName = StringLower(StringRegExpReplace($sName, '.[^./]*$', '')) If StringStripWS($sName, 8) = '' Then Return SetError(1, 0, 0) EndIf Local $aReturn = __ShellFolder_RegistryGet($sRegistryKey), $iReturn = 0, $sNameDeleted = '' If $aReturn[0][0] Then For $i = 1 To $aReturn[0][0] If $aReturn[$i][0] = $sName And $sNameDeleted <> $aReturn[$i][1] Then $sNameDeleted = $aReturn[$i][1] $iReturn += RegDelete($sNameDeleted) EndIf Next EndIf $aReturn = 0 Return $iReturn > 0 EndFunc ;==>_ShellFolder_Uninstall ; #INTERNAL_USE_ONLY#============================================================================================================ Func __ShellFolder_RegistryGet($sRegistryKey) Local $aArray[1][5] = [[0, 5]], $iCount_1 = 0, $iCount_2 = 0, $iDimension = 0, $iError = 0, $sRegistryKey_All = '', $sRegistryKey_Main = '', $sRegistryKey_Name = '', _ $sRegistryKey_Value = '' While 1 If $iError Then ExitLoop EndIf $sRegistryKey_Main = RegEnumKey($sRegistryKey, $iCount_1 + 1) If @error Then $sRegistryKey_All = $sRegistryKey $iError = 1 Else $sRegistryKey_All = $sRegistryKey & $sRegistryKey_Main EndIf $iCount_2 = 0 While 1 $sRegistryKey_Name = RegEnumVal($sRegistryKey_All, $iCount_2 + 1) If @error Then ExitLoop EndIf If ($aArray[0][0] + 1) >= $iDimension Then $iDimension = Ceiling(($aArray[0][0] + 1) * 1.5) ReDim $aArray[$iDimension][$aArray[0][1]] EndIf $sRegistryKey_Value = RegRead($sRegistryKey_All, $sRegistryKey_Name) $aArray[$aArray[0][0] + 1][0] = $sRegistryKey_Main $aArray[$aArray[0][0] + 1][1] = $sRegistryKey_All $aArray[$aArray[0][0] + 1][2] = $sRegistryKey & $sRegistryKey_Main & '' & $sRegistryKey_Name $aArray[$aArray[0][0] + 1][3] = $sRegistryKey_Name $aArray[$aArray[0][0] + 1][4] = $sRegistryKey_Value $aArray[0][0] += 1 $iCount_2 += 1 WEnd $iCount_1 += 1 WEnd ReDim $aArray[$aArray[0][0] + 1][$aArray[0][1]] Return $aArray EndFunc ;==>__ShellFolder_RegistryGetExample 1: #include "_ShellFolder.au3" Example() Func Example() _ShellFolder_Install('Start ShellFolder') ; Add the running EXE to the Shell ContextMenu. This will only display when selecting a drive and folder. Sleep(10000) _ShellFolder_Uninstall() ; Remove the running EXE from the Shell ContextMenu. EndFunc ;==>ExampleAll of the above has been included in a ZIP file. ShellFolder.zip1 point
-
Server (run first) #Include <APIConstants.au3> #Include <GDIPlus.au3> #Include <Memory.au3> #Include <WinAPIEx.au3> Global Const $STM_SETIMAGE = 0x0172 Global Const $STM_GETIMAGE = 0x0173 TCPStartup() $Main = TCPListen(@IPAddress1, 33891) If @error Then Exit EndIf GUICreate('MyGUI', 800, 600, @DesktopWidth - 819, @DesktopHeight - 671) $Pic = GUICtrlCreatePic('', 0, 0, 800, 600) GUISetState() Do $Socket = TCPAccept($Main) Until $Socket <> -1 Global $tHeader = DllStructCreate('byte[4]') Global $pHeader = DllStructGetPtr($tHeader) Global $bData = 0, $Count = 0 _GDIPlus_Startup() Do If Not IsBinary($bData) Then $bData = TCPRecv($Socket, 16384, 1) If @error Then ExitLoop EndIf EndIf If IsBinary($bData) Then If Not $Count Then DllStructSetData($tHeader, 1, $bData) $tData = DllStructCreate('dword', $pHeader) $Size = DllStructGetData($tData, 1) $tData = DllStructCreate('byte[' & $Size & ']') $pData = DllStructGetPtr($tData) EndIf $Lenght = BinaryLen($bData) $Sum = $Count + $Lenght If $Sum > $Size Then $dL = $Size - $Count $tPart = DllStructCreate('byte[' & $dL & ']', $pData + $Count) DllStructSetData($tPart, 1, $bData) $tByte = DllStructCreate('byte[' & $Lenght & ']') $tRecv = DllStructCreate('byte[' & ($Lenght - $dL) & ']', DllStructGetPtr($tByte) + $dL) DllStructSetData($tByte, 1, $bData) $bData = DllStructGetData($tRecv, 1) $Sum = $Size Else $tPart = DllStructCreate('byte[' & $Lenght & ']', $pData + $Count) DllStructSetData($tPart, 1, $bData) $Count = $Sum $bData = 0 EndIf If $Sum = $Size Then _SetScreenshot($Pic, $tData) $Count = 0 EndIf EndIf Until GUIGetMsg() = -3 _GDIPlus_Shutdown() TCPCloseSocket($Socket) TCPShutdown() Func _SetScreenshot($CtrlID, ByRef $tData, $fUpdate = 0) Local $hBitmap, $hPrev, $hScreen, $hMemory, $pMemory, $pStream, $pData, $iSize $hWnd = GUICtrlGetHandle($CtrlID) If Not $hWnd Then Return 0 EndIf $pData = DllStructGetPtr($tData) $iSize = DllStructGetData(DllStructCreate('dword', $pData + 4), 1) $hMemory = _MemGlobalAlloc($iSize, $GMEM_MOVEABLE) $pMemory = _MemGlobalLock($hMemory) _MemMoveMemory($pData + 8, $pMemory, $iSize) _MemGlobalUnlock($hMemory) $pStream = _WinAPI_CreateStreamOnHGlobal($hMemory) $hBitmap = _GDIPlus_CreateBitmapFromStream($pStream) $hScreen = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) _WinAPI_ReleaseStream($pStream) _WinAPI_DeleteObject(_SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hScreen)) $hPrev = _SendMessage($hWnd, $STM_GETIMAGE) If $hPrev <> $hScreen Then _WinAPI_DeleteObject($hScreen) EndIf If $fUpdate Then _WinAPI_UpdateWindow($hWnd) EndIf Return 1 EndFunc ;==>_SetScreenshot Func _GDIPlus_CreateBitmapFromStream($pStream) Local $Ret = DllCall($ghGDIPDll, 'uint', 'GdipCreateBitmapFromStream', 'ptr', $pStream, 'ptr*', 0) If (@error) Or ($Ret[0]) Then Return SetError(@error, @extended, 0) EndIf Return $Ret[2] EndFunc ;==>_GDIPlus_CreateBitmapFromStream Client #Include <APIConstants.au3> #Include <GDIPlus.au3> #Include <Memory.au3> #Include <WinAPIEx.au3> TCPStartup() $Socket = TCPConnect(@IPAddress1, 33891) If @error Then Exit EndIf _GDIPlus_Startup() Global $tEncoder = _WinAPI_GUIDFromString(_GDIPlus_EncodersGetCLSID('png')) Global $pEncoder = DllStructGetPtr($tEncoder) While 1 TCPSend($Socket, _GetScreenshot(0, 0, 800, 600)) If @error Then ExitLoop EndIf Sleep(1000) WEnd _GDIPlus_Shutdown() TCPShutdown() Func _GetScreenshot($iX = 0, $iY = 0, $iWidth = -1, $iHeight = -1) Local $hSrcDC, $hDstDC, $hDstSv, $hBitmap, $hDesktop, $hScreen, $hMemory, $pMemory, $pStream, $tOut, $pOut, $iSize If $iWidth = -1 Then $iWidth = @DesktopWidth EndIf If $iHeight = -1 Then $iHeight = @DesktopHeight EndIf $hDesktop = _WinAPI_GetDesktopWindow() $hSrcDC = _WinAPI_GetDC($hDesktop) $hScreen = _WinAPI_CreateCompatibleBitmap($hSrcDC, $iWidth, $iHeight) $hDstDC = _WinAPI_CreateCompatibleDC($hSrcDC) $hDstSv = _WinAPI_SelectObject($hDstDC, $hScreen) _WinAPI_BitBlt($hDstDC, $iX, $iY, $iWidth, $iHeight, $hSrcDC, $iX, $iY, $SRCCOPY) _WinAPI_SelectObject($hDstDC, $hDstSv) _WinAPI_ReleaseDC($hDesktop, $hSrcDC) _WinAPI_DeleteDC($hDstDC) $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hScreen) _WinAPI_DeleteObject($hScreen) $pStream = _WinAPI_CreateStreamOnHGlobal(0) _GDIPlus_SaveImageToStream($hBitmap, $pStream, $pEncoder) _GDIPlus_BitmapDispose($hBitmap) $hMemory = _WinAPI_GetHGlobalFromStream($pStream) $pMemory = _MemGlobalLock($hMemory) $iSize = _MemGlobalSize($hMemory) $tOut = DllStructCreate('dword;dword;byte[' & ($iSize - Mod($iSize, 4) + 4) & ']') $pOut = DllStructGetPtr($tOut) DllStructSetData($tOut, 1, DllStructGetSize($tOut)) DllStructSetData($tOut, 2, $iSize) _MemMoveMemory($pMemory, $pOut + 8, $iSize) _WinAPI_ReleaseStream($pStream) Return DllStructGetData(DllStructCreate('byte[' & DllStructGetSize($tOut) & ']', DllStructGetPtr($tOut)), 1) EndFunc ;==>_GetScreenshot Func _GDIPlus_SaveImageToStream($hImage, $pStream, $pEncoder, $pParams = 0) Local $Ret = DllCall($ghGDIPDll, 'uint', 'GdipSaveImageToStream', 'ptr', $hImage, 'ptr', $pStream, 'ptr', $pEncoder, 'ptr', $pParams) If (@error) Or ($Ret[0]) Then Return SetError(@error, @extended, 0) EndIf Return 1 EndFunc ;==>_GDIPlus_SaveImageToStream1 point
-
Here an example how to send an image without saving it to disk first! It will take a screenshot, convert it to a jpg image and send to the server everything done in the memory! Client Send - Receive Picture.au3 #include <memory.au3> #include <screencapture.au3> _GDIPlus_Startup() TCPStartup() Local $ConnectedSocket, $szData Local $szIPADDRESS = @IPAddress1 Local $nPORT = 33891 $ConnectedSocket = -1 $ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT) If @error Then Exit MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error) $iMsgBox = MsgBox(4, "Send image", "Send image to server?") If $iMsgBox = 6 Then $hHBITMAP = _ScreenCapture_Capture("", 0, 0, 100, 100) $bImage = HBITMAP2BinaryString($hHBITMAP) ConsoleWrite(TCPSend($ConnectedSocket, Binary($bImage)) & @LF) _WinAPI_DeleteObject($hHBITMAP) EndIf _GDIPlus_Shutdown() Exit Func HBITMAP2BinaryString($HBITMAP) ;function by Andreik Local $BITMAP = _GDIPlus_BitmapCreateFromHBITMAP($HBITMAP) Local $JPG_ENCODER = _GDIPlus_EncodersGetCLSID("jpg") Local $TAG_ENCODER = _WinAPI_GUIDFromString($JPG_ENCODER) Local $PTR_ENCODER = DllStructGetPtr($TAG_ENCODER) Local $STREAM = DllCall("ole32.dll", "uint", "CreateStreamOnHGlobal", "ptr", 0, "bool", 1, "ptr*", 0) DllCall($ghGDIPDll, "uint", "GdipSaveImageToStream", "ptr", $BITMAP, "ptr", $STREAM[3], "ptr", $PTR_ENCODER, "ptr", 0) _GDIPlus_BitmapDispose($BITMAP) Local $MEMORY = DllCall("ole32.dll", "uint", "GetHGlobalFromStream", "ptr", $STREAM[3], "ptr*", 0) Local $MEM_SIZE = _MemGlobalSize($MEMORY[2]) Local $MEM_PTR = _MemGlobalLock($MEMORY[2]) Local $DATA_STRUCT = DllStructCreate("byte[" & $MEM_SIZE & "]", $MEM_PTR) Local $DATA = DllStructGetData($DATA_STRUCT, 1) Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data;ptr") Local $aCall = DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $STREAM[3], "dword", 8 + 8 * @AutoItX64, "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) _MemGlobalFree($MEMORY[2]) Return $DATA EndFunc ;==>HBITMAP2BinaryString Server Send - Receive Picture.au3 #include <guiconstantsex.au3> #include <gdiplus.au3> #include <memory.au3> #include <staticconstants.au3> Local $szIPADDRESS = @IPAddress1 Local $nPORT = 33891 Local $MainSocket, $edit, $ConnectedSocket, $szIP_Accepted Local $msg, $recv TCPStartup() $MainSocket = TCPListen($szIPADDRESS, $nPORT) If $MainSocket = -1 Then Exit GUICreate("My Server (IP: " & $szIPADDRESS & ")", 300, 200, 100, 100, Default, 0x00000008) $edit = GUICtrlCreateEdit("", 10, 10, 280, 180) GUISetState() $ConnectedSocket = -1 Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket <> -1 $szIP_Accepted = SocketToIP($ConnectedSocket) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop $recv = TCPRecv($ConnectedSocket, 8192, 1) If @error Then ExitLoop If $recv <> "" Then GUICtrlSetData($edit, $recv) WEnd If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket) TCPShutdown() Global Const $IMAGE_BITMAP = 0 Global Const $STM_SETIMAGE = 0x0172 _GDIPlus_Startup() $hBitmap = Load_BMP_From_Mem(Binary(GUICtrlRead($edit)), True) $hGUI = GUICreate("Test", 320, 200) $idPic = GUICtrlCreatePic("", 0, 0, 320, 200, $SS_CENTERIMAGE) GUISetState() _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)) Do Until GUIGetMsg() = -3 _WinAPI_DeleteObject($hBitmap) _GDIPlus_Shutdown() Exit Func SocketToIP($SHOCKET) Local $sockaddr, $aRet $sockaddr = DllStructCreate("short;ushort;uint;char[8]") $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr)) If Not @error And $aRet[0] = 0 Then $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3)) If Not @error Then $aRet = $aRet[0] Else $aRet = 0 EndIf $sockaddr = 0 Return $aRet EndFunc ;==>SocketToIP ;====================================================================================== ; Function Name: Load_BMP_From_Mem ; Description: Loads an image which is saved as a binary string and converts it to a bitmap or hbitmap ; ; Parameters: $bImage: the binary string which contains any valid image which is supported by GDI+ ; Optional: $hHBITMAP: if false a bitmap will be created, if true a hbitmap will be created ; ; Remark: hbitmap format is used generally for GUI internal images, $bitmap is more a GDI+ image format ; Don't forget _GDIPlus_Startup() and _GDIPlus_Shutdown() ; ; Requirement(s): GDIPlus.au3, Memory.au3 and _GDIPlus_BitmapCreateDIBFromBitmap() from WinAPIEx.au3 ; Return Value(s): Success: handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format), ; Error: 0 ; Error codes: 1: $bImage is not a binary string ; 2: unable to create stream on HGlobal ; 3: unable to create bitmap from stream ; ; Author(s): UEZ ; Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines and ; Yashied for _GDIPlus_BitmapCreateDIBFromBitmap() from WinAPIEx.au3 ; Version: v0.97 Build 2012-04-10 Beta ;======================================================================================= Func Load_BMP_From_Mem($bImage, $hHBITMAP = False) If Not IsBinary($bImage) Then Return SetError(1, 0, 0) Local $aResult Local Const $memBitmap = Binary($bImage) ;load image saved in variable (memory) and convert it to binary Local Const $len = BinaryLen($memBitmap) ;get length of image Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002) Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data _MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents If @error Then Return SetError(2, 0, 0) Local Const $hStream = $aResult[3] $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface If @error Then Return SetError(3, 0, 0) Local Const $hBitmap = $aResult[2] Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr") DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _ "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak $tMem = 0 $tVARIANT = 0 If $hHBITMAP Then Local Const $hHBmp = _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBmp EndIf Return $hBitmap EndFunc ;==>Load_BMP_From_Mem Func _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap) Local $tBIHDR, $Ret, $tData, $pBits, $hResult = 0 $Ret = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0) If (@error) Or ($Ret[0]) Then Return 0 $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $Ret[2], $Ret[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB) $pBits = DllStructGetData($tData, 'Scan0') If Not $pBits Then Return 0 $tBIHDR = DllStructCreate('dword;long;long;ushort;ushort;dword;dword;long;long;dword;dword') DllStructSetData($tBIHDR, 1, DllStructGetSize($tBIHDR)) DllStructSetData($tBIHDR, 2, $Ret[2]) DllStructSetData($tBIHDR, 3, $Ret[3]) DllStructSetData($tBIHDR, 4, 1) DllStructSetData($tBIHDR, 5, 32) DllStructSetData($tBIHDR, 6, 0) $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0) If (Not @error) And ($hResult[0]) Then DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $Ret[2] * $Ret[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0')) $hResult = $hResult[0] Else $hResult = 0 EndIf _GDIPlus_BitmapUnlockBits($hBitmap, $tData) Return $hResult EndFunc ;==>_GDIPlus_BitmapCreateDIBFromBitmap Start first Server Send - Receive Picture.au3 and then Client Send - Receive Picture.au3. Because I'm not familiar with the tcp/ip stuff I took the tcp/ip stuff from the help file! Br, UEZ1 point
-
For compatibility's sake, these keys work on Win2000-Win7: HKEY_CURRENT_USER\SOFTWARE\Classes\Folder\shell or HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell (the latter requires admin rights of course) HKEY_CURRENT_USER keys override keys with the same name in HKEY_LOCAL_MACHINE The only shortcoming is I don't know of a way to put an icon in the menu, but I don't mind. All you need to do is add these subkeys. For example, to add 'CommandPromptHere', this is a .reg file that would add this: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\SOFTWARE\Classes\Folder\shell] [HKEY_CURRENT_USER\SOFTWARE\Classes\Folder\shell\CommandPromptHere] @="Command Prompt Here" "Icon"=hex(2):25,00,63,00,6f,00,6d,00,73,00,70,00,65,00,63,00,25,00,2c,00,30,\ 00,00,00 [HKEY_CURRENT_USER\SOFTWARE\Classes\Folder\shell\CommandPromptHere\command] @=hex(2):25,00,63,00,6f,00,6d,00,73,00,70,00,65,00,63,00,25,00,20,00,2f,00,6b,\ 00,20,00,20,00,70,00,75,00,73,00,68,00,64,00,20,00,22,00,25,00,31,00,22,00,\ 20,00,26,00,20,00,74,00,69,00,74,00,6c,00,65,00,20,00,43,00,6f,00,6d,00,6d,\ 00,61,00,6e,00,64,00,20,00,50,00,72,00,6f,00,6d,00,70,00,74,00,00,00 Hmm, forgot about the hex conversion. The Icon and Command lines appear as: "Icon"=%comspec%,0 %comspec% /k pushd "%1" & title Command Prompt The list of common context menu locations follows (HKCU can be used in place of HKLM): HKLM\Software\Classes\Folder\shell\yourappname HKLM\Software\Classes\Folder\shell\yourappname\command HKLM\Software\Classes\Directory\shell\yourappname HKLM\Software\Classes\Directory\shell\yourappname\command HKLM\Software\Classes\Drive\shell\yourappname HKLM\Software\Classes\Drive\shell\yourappname\commandNote: On Vista+, the command prompt here registry addition is unneeded and should just be seen as a placeholder for whatever program you like. (Shift-Right-Click a folder on Vista+ to open a command prompt) *edit: oops, I guess its pretty easy to add an Icon after all.1 point