Leaderboard
Popular Content
Showing content with the highest reputation on 12/30/2012 in all areas
-
I created this after I developed >_ShellFolder() because I was interested in the entry displaying when an associated file was right clicked on. I was also intrigued to see how easy it would be to register a file type with my program, quite easy it appears. The UDF is a little different to what I've seen on the forum as this works with the Current User and/or All Users and an icon is created in the ContextMenu too. The entry will pass the file name to your program via a commandline argument, so you'll have to use $CmdLine/$CmdLineRaw to access the file 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 .........: _ShellFile ; AutoIt Version : v3.2.12.1 or higher ; Language ......: English ; Description ...: Create an entry in the shell contextmenu when selecting an assigned filetype, includes the program icon as well. ; Note ..........: ; Author(s) .....: guinness ; Remarks .......: ; =============================================================================================================================== ; #INCLUDES# ==================================================================================================================== #include <Constants.au3> ; #GLOBAL VARIABLES# ============================================================================================================ ; None ; #CURRENT# ===================================================================================================================== ; _ShellFile_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 an assigned filetype to the program. ; _ShellFile_Uninstall: Deletes an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu. ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; None ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ShellFile_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 an assigned filetype to the program. ; Syntax ........: _ShellFile_Install($sText, $sFileType[, $sName = @ScriptName[, $sFilePath = @ScriptFullPath[, $sIconPath = @ScriptFullPath[, ; $iIcon = 0[, $fAllUsers = False[, $fExtended = False]]]]]]) ; Parameters ....: $sText - Text to be shown in the contextmenu. ; $sFileType - Filetype to be associated with the application e.g. .autoit or autoit. ; $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 _ShellFile_Install($sText, $sFileType, $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 & '\SOFTWARE\Classes\' Else $sRegistryKey = 'HKEY_CURRENT_USER' & $i64Bit & '\SOFTWARE\Classes\' EndIf $sFileType = StringRegExpReplace($sFileType, '^\.+', '') $sName = StringLower(StringRegExpReplace($sName, '\.[^.\\/]*$', '')) If StringStripWS($sName, $STR_STRIPALL) = '' Or FileExists($sFilePath) = 0 Or StringStripWS($sFileType, $STR_STRIPALL) = '' Then Return SetError(1, 0, False) EndIf _ShellFile_Uninstall($sFileType, $fAllUsers) Local $iReturn = 0 $iReturn += RegWrite($sRegistryKey & '.' & $sFileType, '', 'REG_SZ', $sName) $iReturn += RegWrite($sRegistryKey & $sName & '\DefaultIcon\', '', 'REG_SZ', $sIconPath & ',' & $iIcon) $iReturn += RegWrite($sRegistryKey & $sName & '\shell\open', '', 'REG_SZ', $sText) $iReturn += RegWrite($sRegistryKey & $sName & '\shell\open', 'Icon', 'REG_EXPAND_SZ', $sIconPath & ',' & $iIcon) $iReturn += RegWrite($sRegistryKey & $sName & '\shell\open\command\', '', 'REG_SZ', '"' & $sFilePath & '" "%1"') $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 ;==>_ShellFile_Install ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ShellFile_Uninstall ; Description ...: Deletes an entry in the 'All Users/Current Users' registry for displaying a program entry in the shell contextmenu. ; Syntax ........: _ShellFile_Uninstall($sFileType[, $fAllUsers = False]) ; Parameters ....: $sFileType - Filetype to be associated with the application e.g. .autoit or autoit. ; $fAllUsers - [optional] Add 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 _ShellFile_Uninstall($sFileType, $fAllUsers = False) Local $i64Bit = '', $sRegistryKey = '' If @OSArch = 'X64' Then $i64Bit = '64' EndIf If $fAllUsers Then $sRegistryKey = 'HKEY_LOCAL_MACHINE' & $i64Bit & '\SOFTWARE\Classes\' Else $sRegistryKey = 'HKEY_CURRENT_USER' & $i64Bit & '\SOFTWARE\Classes\' EndIf $sFileType = StringRegExpReplace($sFileType, '^\.+', '') If StringStripWS($sFileType, $STR_STRIPALL) = '' Then Return SetError(1, 0, False) EndIf Local $iReturn = 0, $sName = RegRead($sRegistryKey & '.' & $sFileType, '') If @error Then Return SetError(2, 0, False) EndIf $iReturn += RegDelete($sRegistryKey & '.' & $sFileType) $iReturn += RegDelete($sRegistryKey & $sName) Return $iReturn > 0 EndFunc ;==>_ShellFile_UninstallExample 1: #include <GUIConstantsEx.au3> #include '_ShellFile.au3' If @Compiled = 0 Then Exit MsgBox($MB_SYSTEMMODAL, '@Compiled Returned 0.', 'Please compile the program before testing. Thanks.') EndIf _Main() Func _Main() Local $sFilePath = '' If $CmdLine[0] > 0 Then $sFilePath = $CmdLine[1] EndIf Local $hGUI = GUICreate('_ShellFile() Example', 370, 110) GUICtrlCreateEdit(_GetFile($sFilePath), 10, 5, 350, 65) ; If a file was passed via commandline then random text will appear in the GUICtrlCreateEdit(). Local $iAdd = GUICtrlCreateButton('Add FileType', 10, 80, 75, 25) Local $iRemove = GUICtrlCreateButton('Remove FileType', 90, 80, 95, 25) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $iAdd _ShellFile_Install('Open with _ShellFile()', 'autoit') ; Add the running EXE to the Shell ContextMenu. If @error Then MsgBox($MB_SYSTEMMODAL, 'Association NOT Created.', '".autoit" was not associated due to an error occurring.') Else MsgBox($MB_SYSTEMMODAL, 'Association Created.', '"RandomFile.autoit" file was created to show that the filetype ".autoit" has been associtated with ' & @ScriptName & '.' & _ @CRLF & @CRLF & 'If you restart the computer you''ll see the icon of "RandomFile.autoit" is the same as the program icon.' & _ @CRLF & @CRLF & 'Now close the program and double/right click on "RandomFile.autoit" to display the random text in the edit box.') EndIf _SetFile(_RandomText(5000), @ScriptDir & '\RandomFile.autoit', 1) ; Create a file with Random text. Case $iRemove _ShellFile_Uninstall('autoit') ; Remove the running EXE from the Shell ContextMenu. If @error Then MsgBox($MB_SYSTEMMODAL, 'Association NOT Deleted.', '".autoit" was not deleted from the Registry due to an error occurring.') Else MsgBox($MB_SYSTEMMODAL, 'Association Deleted.', '".autoit" was successfully deleted from the Registry and is no longer associated with ' & @ScriptName & '.') EndIf EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>_Main Func _GetFile($sFilePath, $sFormat = 0) Local $hFileOpen = FileOpen($sFilePath, $sFormat) If $hFileOpen = -1 Then Return SetError(1, 0, 'No File Was Passed Via Commandline.') EndIf Local $sData = FileRead($hFileOpen) FileClose($hFileOpen) Return $sData EndFunc ;==>_GetFile Func _RandomText($iLength = 7) Local $iCount = 0, $iCRLF, $sData = '', $sRandom For $i = 1 To $iLength $sRandom = Random(55, 116, 1) If $iCount = 100 Then $iCRLF = @CRLF $iCount = 0 EndIf $sData &= Chr($sRandom + 6 * ($sRandom > 90) - 7 * ($sRandom < 65)) & $iCRLF $iCount += 1 $iCRLF = '' Next Return $sData EndFunc ;==>_RandomText Func _SetFile($sString, $sFilePath, $iOverwrite = 0) Local $hFileOpen = FileOpen($sFilePath, $iOverwrite + 1) FileWrite($hFileOpen, $sString) FileClose($hFileOpen) If @error Then Return SetError(1, 0, $sString) EndIf Return $sString EndFunc ;==>_SetFileAll of the above has been included in a ZIP file. ShellFile.zip1 point
-
I agree that reviving old topics with a valid request is fine. I also agree that a certain politeness should be adhered to in all topics. But following the board (see "General Help"), this is the third post to a different thread on the same topic in short time, so I wouldn't have minded an even stronger response... but hey, Jos is one of the nice guys ... http://stackoverflow.com/questions/14062399/reset-and-zero-fill-unused-ram-in-c1 point
-
It failed for me as well, but when I changed it to a 64 bit key, it worked. Are you using a 64bit machine? $a = RegRead("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Cryptography", "MachineGuid") MsgBox(0,'',$a & " " & @error)1 point
-
Use these to update the graphic: GUICtrlSetGraphic($hGraphic, $GUI_GR_COLOR, 0x666666, 0x00ff00) GUICtrlSetGraphic($hGraphic, $GUI_GR_ELLIPSE, 0, 1, 10, 10) GUICtrlSetGraphic($hGraphic, $GUI_GR_REFRESH) Jos1 point
-
I think the concept is flawed. It is better to create a backup directory which automatically saves your work in backup files. The following script creates backups of all notepad windows (implementing jdelaney's suggestion). Whether they are saved, maximized or minimized doesn't matter. HotKeySet("{ESC}", "Quit") ; Hit the escape key to quit. ; Run the backup every 1000 ms (the time delay of 1 second is just for testing) AdlibRegister ( "NotePad_Backup" , 1000) ; Change the time delay to a longer period. While 1 ; Keep the script alive. Sleep(100) ; Reduce memory usage. WEnd Func NotePad_Backup() Local $aNotepad, $sText, $hFile, $hPath $aNotepad = WinList("[Class:Notepad]") ; Get all notepad windows. If $aNotepad[0][0] Then ; Notepad windows exist. For $i = 1 To $aNotepad[0][0] ; Run through the list. $sText = WinGetText($aNotepad[$i][1]) ; Get the text from each window. ; Create a backup name. ; Adjust this by including $aNotepad[$i][0] in the title if you wish. $hFile = StringRight(@YEAR, 2) & @MON & @MDAY & StringTrimLeft($aNotepad[$i][1], 2) & ".txt" $hPath = @ScriptDir & "\backup\" & $hFile ; The backup files belong in a backup directory. FileOpen($hPath, 10) ; Creates directory and overwrites any previous backup of the same file. If @error Then ConsoleWrite("File Open Failed with " & $hPath &@LF) ; Check the file isn't read only. FileWrite($hPath, WinGetText($aNotepad[$i][1])) ; Write the contents of the window to the backup text file. If @error Then ConsoleWrite("File Write Failed with " & $hPath &@LF) ; Check the file isn't read only. FileClose($hPath) Next EndIf EndFunc Func Quit() Exit EndFunc This isn't 100% bullet proof all of the time. If you close a window without saving you could still lose some work. If you then start a new instance of notepad, Windows may reassign the same handle, and the new file may overwrite the old one. This can only happen on the same day, but some tweaks to the naming could reduce the risk (see comment - line 19). For Example replace line 20 with this: $hFile = StringRight(@YEAR, 2) & @MON & @MDAY & StringTrimLeft($aNotepad[$i][1], 2) & " (" & $aNotepad[$i][0] & ").txt" If you don't overwrite files you will end up with a bloated folder full of backups. This script is only intended as a precaution. To be absolutely certain, make sure you save your work manually. Also consider that there may be other alternatives which you, or I, haven't thought of yet.1 point
-
GUI design concepts.
antonioj84 reacted to PlayHD for a topic
One of my old projects... #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinApi.au3> Global $RBOX_EVENT_CLOSE = 1 Global $ROUNDES = 20, $LastHwnd = 0 Global $GUIBKCOLOR = 0xEEC591 Global $ARRAY_COLOR_TOP_MIN[3] = [36 ,65 ,142] , $ARRAY_COLOR_TOP_MAX[3] = [11 ,42 ,122] Local $hGui = RBoxCreate("Gui Design PHD",800,600) While 1 CheckX($hGui,$RBOX_EVENT_CLOSE,"GuiCtrlSetColor("&$RBOX_EVENT_CLOSE&",0xA3A3A3)","GuiCtrlSetColor("&$RBOX_EVENT_CLOSE&",0x555555)") $gMsg = GUIGetMsg() Switch $gMsg Case $RBOX_EVENT_CLOSE, $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func RBoxCreate($Title,$width, $height ,$left=-1 ,$top=-1 ,$show=1) Local $GUI = GUICreate($Title,$width,$height,$left,$top,$WS_POPUP) GUISetBkColor($GUIBKCOLOR,$GUI) _GuiRoundCorners($GUI,0,0,$ROUNDES,$ROUNDES) $RBOX_EVENT_CLOSE = GUICtrlCreateLabel('X',$width-20,3,25,25) GUICtrlSetCursor($RBOX_EVENT_CLOSE,0) GUICtrlSetBkColor($RBOX_EVENT_CLOSE,-2) GUICtrlSetFont($RBOX_EVENT_CLOSE,15,800) GUICtrlSetColor($RBOX_EVENT_CLOSE,0x555555) $Title &= " " Local $hTitle = GUICtrlCreateLabel($Title,0,0,$width-20,26,$SS_CENTER,$GUI_WS_EX_PARENTDRAG) GUICtrlSetFont($hTitle,17,400,0,"Consolas") GUICtrlSetBkColor($hTitle,-2) Local $Graphic = GUICtrlCreateGraphic (0,0, $width, 25) GUICtrlSetState($Graphic,$Gui_DISABLE) GradientFill($Graphic, 0, 0, $width, 25, $ARRAY_COLOR_TOP_MIN, $ARRAY_COLOR_TOP_MAX) If $show = 1 Then GUISetState(@SW_SHOW,$GUI) Return $GUI EndFunc Func CheckX($hGui, $CtrlID, $sCMD, $eCMD) Local $cGui = GUIGetCursorInfo($hGui) If Not IsArray($cGui) Then Return 0 if $LastHwnd <> $cGui[4] And $cGui[4] = $CtrlID Then Return Execute($sCMD) + Assign("LastHwnd",$cGui[4]) if $LastHwnd <> $cGui[4] Then Return Execute($eCMD) + Assign("LastHwnd",$cGui[4]) EndFunc Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3) Dim $pos, $ret, $ret2 $pos = WinGetPos($h_win) $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3) If $ret[0] Then $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1) If $ret2[0] Then Return 1 Else Return 0 EndIf Else Return 0 EndIf EndFunc Func GradientFill($im, $x1, $y1, $width, $height, $left_color, $right_color) Local $color0=($left_color[0]-$right_color[0])/$height Local $color1=($left_color[1]-$right_color[1])/$height $color2=($left_color[2]-$right_color[2])/$height For $Y=0 to $height-1 $red=$left_color[0]-floor($Y*$color0) $green=$left_color[1]-floor($Y*$color1) $blue=$left_color[2]-floor($Y*$color2) $col = Dec(Hex($blue,2) & Hex($green,2) & Hex($red,2)) GUICtrlSetGraphic($im,$GUI_GR_COLOR, $col) GUICtrlSetGraphic($im,$GUI_GR_MOVE,0,$Y) GUICtrlSetGraphic($im,$GUI_GR_LINE,$width,$Y) Next GUICtrlSetGraphic($im,$GUI_GR_COLOR, 0x000000) GUICtrlSetGraphic($im,$GUI_GR_MOVE,0,$height) GUICtrlSetGraphic($im,$GUI_GR_LINE,$width,$height) GUICtrlSetGraphic($im,$GUI_GR_REFRESH) EndFunc Here is a screen : http://prntscr.com/ni5sq1 point -
Found this in my collection: ;another fast hack by UEZ 2011 #include <GDIPlus.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) _GDIPlus_Startup() Global Const $SC_DRAGMOVE = 0xF012 Global Const $W = -1 Global Const $H = 200 Global Const $hGUI = GUICreate("GDI+ Test by UEZ 2011", $W, $H, -1, -1, $WS_POPUP, $WS_EX_LAYERED) Global Const $hGUI_Child = GUICreate("", $W, $H, 0, 0, $WS_POPUP, $WS_EX_MDICHILD + $WS_EX_LAYERED + $WS_EX_TOOLWINDOW, $hGUI) GUISetBkColor(0xABCDEF, $hGUI_Child) GUISwitch($hGUI_Child) Global Const $idButton = GUICtrlCreateButton("Exit", 40, 20, 100, 40) GUICtrlSetOnEvent(-1, "_Exit") Global Const $idLabel = GUICtrlCreateLabel("TEST LABEL HERE!!!", 110, 140, 180, 20) GUICtrlSetFont(-1, 14, 400, 0, "Times New Roman", 3) GUICtrlSetColor(-1, 0xF0F0FF) GUICtrlSetBkColor(-1, -2) _WinAPI_SetLayeredWindowAttributes($hGUI_Child, 0xABCDEF, 0xFF) GUISetState(@SW_SHOW, $hGUI_Child) GUISetState(@SW_SHOW, $hGUI) _SetGuiRoundCorners($hGUI, 40, False, True, True, False) Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global Const $hBitmap = _CreateCustomBk($hGUI, 0x550555) Global Const $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) _CreateCustomGroupPic($hContext, 100, 100, 200, 75, 0xff0000) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $W, $H) SetTransparentBitmap($hGUI, $hBitmap, 0xD0) GUISetOnEvent(-3, "_Exit") GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") While Sleep(2 ^ 16) WEnd Func _Exit() _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI_Child) GUIDelete($hGUI) Exit EndFunc ;==>_Exit Func _CreateCustomBk($hGUI, $hexColor, $alpha = "0xAA") Local $iWidth = _WinAPI_GetClientWidth($hGUI) Local $iHeight = _WinAPI_GetClientHeight($hGUI) Local $oBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($oBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Local $hBrush = _GDIPlus_BrushCreateSolid($alpha & Hex($hexColor, 6)) _GDIPlus_GraphicsFillRect($hGraphics, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_GraphicsFillRect($hGraphics, 2, 2, $iWidth - 6, $iHeight - 6, $hBrush) _GDIPlus_BrushSetSolidColor($hBrush, 0x22FFFFFF) Local $iTimes = Round($iWidth / 50) Local $aPoints[5][2] $aPoints[0][0] = 4 $aPoints[1][1] = $iHeight $aPoints[2][1] = $iHeight $aPoints[4][1] = 0 $aPoints[3][1] = 0 For $i = 0 To $iTimes Local $Random1 = Random(0, $iWidth, 1) Local $Random2 = Random(30, 50, 1) $aPoints[1][0] = $Random1 $aPoints[2][0] = $Random1 + $Random2 $aPoints[4][0] = $aPoints[1][0] + 50 $aPoints[3][0] = $aPoints[2][0] + 50 _GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush) $aPoints[1][0] -= $Random2 / 10 $aPoints[2][0] = $Random1 + $Random2 - ($Random2 / 10 * 2) $aPoints[3][0] = $aPoints[2][0] + 50 $aPoints[4][0] = $aPoints[1][0] + 50 _GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush) Next _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) Return $oBitmap EndFunc ;==>_CreateCustomBk Func _CreateCustomGroupPic($hGraphics, $ix, $iy, $Width, $iHeight, $hexColor, $alpha = "0x55") _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Local $hBrush = _GDIPlus_BrushCreateSolid($alpha & Hex($hexColor, 6)) _GDIPlus_GraphicsFillRect($hGraphics, $ix, $iy, $Width, $iHeight, $hBrush) _GDIPlus_GraphicsFillRect($hGraphics, 2, 2, $Width - 4, $iHeight - 4, $hBrush) _GDIPlus_BrushDispose($hBrush) EndFunc ;==>_CreateCustomGroupPic Func _SetGuiRoundCorners($hGUI, $iEllipse, $iLeftUp = True, $iLeftDown = True, $iRightUp = True, $iRightDown = True) Local $hCornerRgn Local $aGuiSize = WinGetPos($hGUI) Local $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $aGuiSize[2], $aGuiSize[3], $iEllipse, $iEllipse) If $iLeftUp = False Then $hCornerRgn = _WinAPI_CreateRectRgn(0, 0, $aGuiSize[2] / 2, $aGuiSize[3] / 2) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iLeftDown = False Then $hCornerRgn = _WinAPI_CreateRectRgn(0, $aGuiSize[3] / 2, $aGuiSize[2] / 2, $aGuiSize[3]) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iRightUp = False Then $hCornerRgn = _WinAPI_CreateRectRgn($aGuiSize[2] / 2, 0, $aGuiSize[2], $aGuiSize[3] / 2) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iRightDown = False Then $hCornerRgn = _WinAPI_CreateRectRgn($aGuiSize[2] / 2, $aGuiSize[3] / 2, $aGuiSize[2] - 1, $aGuiSize[3] - 1) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf _WinAPI_SetWindowRgn($hGUI, $hRgn) EndFunc ;==>_SetGuiRoundCorners Func SetTransparentBitmap($hGUI, $hImage, $iOpacity = 0xFF) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetTransparentBitmap Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) If @error Then Return SetError(@error, @extended, 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0 Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Screenshot: Br, UEZ1 point
-
QR Code
jaberwacky reacted to ptrex for a topic
@all Modified the version so it goes to Clipboard and file as well. ( Credits go to UEZ ) ; ======================================================================================= ; Title .........: QR Generator ; Description ...: Generate QR code in some formats ; Requirement(s).: Autoit 3.3.6.1 ; Author(s) .....: Giovanni Rossati (El Condor) ; Version........: 0.1.1 ; Date...........: 5 jui 2012 ; ======================================================================================= #include <Constants.au3> #Include <Array.au3> #include <WindowsConstants.au3> #include "formhandler.au3" #include "functions.au3" #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <Clipboard.au3> #include <Date.au3> ;Global $hWnd $hWnd = GUICreate("QR Code generator", 400, 300, 250, 200) $flMenu = GUICtrlCreateMenu("&File") $fineItem = GUICtrlCreateMenuItem("End", $flMenu) $helpMenu = GUICtrlCreateMenu("?") $infoItem = GUICtrlCreateMenuItem("&Info", $helpMenu) $records = "Prodotto,,20,CMTM,GIACCHE UOMO,GIACCHE UOMO|GIACCHE DONNA;" _ & "Magazzino,,15,CMTM,CUMIANA,CUMIANA|BAIA MARE;" _ & "Peso,,5,NM,2;" _ & "Data,Data reg.,10,TM," & _DateTimeFormat(_NowCalc(), 2) & ";" _ & "OutputType,Tipo di output,30,R,XML,XML|JSON;" GUISetState() $aReturn = formHandler("QR Data",$records,$hWnd) createQR($aReturn) While 1 $msg = GUIGetMsg() Switch $msg Case $infoItem MsgBox(0, "Credits", "Condor Informatique - Turin" _ & @CRLF & "Generatore codice QR" _ & @CRLF & "Version 0.1.1 7 juin 2012" _ & @CRLF & "Program developped with AutoIt3") Case $GUI_EVENT_CLOSE,$fineItem MsgBox(0,"QR Code generator","See you later alligator",2) ExitLoop EndSwitch WEnd Func createQR($a) $templXML = '<?xml version="1.0" encoding="UTF-8"?><Sermig Application="MASO">' _ & '<Scatola Prodotto="&Prodotto" Magazzino="&Magazzino" Peso="&Peso" Data="&Data" />' _ & '</Sermig>' $templJSON = '{"Sermig": { "Application" : "MASO",' _ & '"Prodotto": "&Prodotto","Magazzino": "&Magazzino","Peso": &Peso,"Data"} }' $tmpl = $templXML if TakeData($a,"OutputType") = "JSON" Then $tmpl = $templJSON For $i = 0 To UBound($a)-1 $tmpl = StringReplace($tmpl,"&" & $a[$i][0], $a[$i][1]) Next DllCall("quricol32.dll","none", "GenerateBMP","str", @ScriptDir & "\GDIPlus_Image.bmp", "str", $tmpl,"int",4,"int",2) DllCall("quricol32.dll","none", "GeneratePNG","str", @ScriptDir & "\GDIPlus_Image.png", "str", $tmpl,"int",4,"int",2) _GDIPlus_Startup() $return = DllCall("quricol32.dll","HANDLE", "GetHBitmap", "str", $tmpl,"int",4,"int",2) $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($return[0]) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd) _GDIPlus_GraphicsDrawImage($hGraphic,$hBitmap, 100, 100) _GDIPlus_ImageSaveToFile($hGraphic, @ScriptDir & "\GDIPlus_Image.bmp") ; Save bitmap to file If Not _ClipBoard_Open($hWnd) Then _WinAPI_ShowError("_ClipBoard_Open failed") If Not _ClipBoard_Empty() Then _WinAPI_ShowError("_ClipBoard_Empty failed") $hBitmap2 = _WinAPI_CopyImage(_GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap), 0, 0, 0, $LR_COPYDELETEORG + $LR_COPYRETURNORG) $iResult = _ClipBoard_SetDataEx($hBitmap2, $CF_BITMAP ) ConsoleWrite("$hBitmap2: " & $hBitmap2 & @CRLF & "$iresult: " & $iResult & @CRLF) ConsoleWrite( @CRLF) ShowData($hWnd) _ClipBoard_Close() ;_ClipBoard_SetDataEx($return[0],$CF_BITMAP) it seems not working ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BitmapDispose($hBitmap) ;_GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($return[0]) _GDIPlus_Shutdown() ; Shut down GDI+ library Return EndFunc Func _WinAPI_CopyImage($hImage, $iType = 0, $xDesired = 0, $yDesired = 0, $iFlags = 0); from _WinAPIEx by Yashied Local $Ret = DllCall('user32.dll', 'ptr', 'CopyImage', 'ptr', $hImage, 'int', $iType, 'int', $xDesired, 'int', $yDesired, 'int', $iFlags) If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, 0) Return $Ret[0] EndFunc ;==>_WinAPI_CopyImage ; Show clipboard statistics Func ShowData($hGUI) ConsoleWrite("GUI handle ............: " & $hGUI & @CRLF) ConsoleWrite("Clipboard owner .......: " & _ClipBoard_GetOwner()& @CRLF) ConsoleWrite("Clipboard open window .: " & _ClipBoard_GetOpenWindow()& @CRLF) ConsoleWrite("Clipboard sequence ....: " & _ClipBoard_GetSequenceNumber()& @CRLF) EndFunc ;==>ShowData Enjoy !! Rgds ptrex1 point