Nine Posted August 13 Posted August 13 (edited) In this thread it was discussed about fading out a label from dark to white. So I suggested to use an ownerdraw label to perform such a task. After a bit of searching, I did not find good example, on this forum, of doing it with a label. So there you go : expandcollapse popup; From Nine #include <WinAPIDiag.au3> #include <GDIPlus.au3> #include <GUIConstants.au3> ; Blend - Fade - Text - OWNERDRAW - label Opt("MustDeclareVars", True) Global Const $tagDRAWITEMSTRUCT = "uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;hwnd hwndItem;hwnd hDC;" & $tagRECT & ";ulong_ptr itemData;" Global Const $SS_OWNERDRAW = 0x0D Example() Func Example() _GDIPlus_Startup() Local $hGUI = GUICreate("Example", 400, 200, -1, -1, $WS_OVERLAPPEDWINDOW) GUISetBkColor(0xFFFF00) Local $idLabel = GUICtrlCreateLabel("", 75, 20, 250, 40, $SS_OWNERDRAW) GUIRegisterMsg($WM_DRAWITEM, WM_DRAWITEM) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idLabel ConsoleWrite("Label was clicked" & @CRLF) EndSwitch WEnd _GDIPlus_Shutdown() EndFunc ;==>Example Func WM_DRAWITEM($hWnd, $iMsg, $wParam, $lParam) Local $tData = DllStructCreate($tagDRAWITEMSTRUCT, $lParam) Local $hGraphic = _GDIPlus_GraphicsCreateFromHDC($tData.hdc) Local $hBrush = _GDIPlus_LineBrushCreate(0, 20, $tData.right, 20, 0xFF606060, 0xFFFFFFFF) Local $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) Local $hFamily = _GDIPlus_FontFamilyCreate("Arial") Local $hFont = _GDIPlus_FontCreate($hFamily, 28, 2) Local $tLayout = _GDIPlus_RectFCreate(0, Int(($tData.bottom - 40) / 2), $tData.right, 40) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, "AutoIt Rulez !", $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsClear($hGraphic, 0xFFFF0000) _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt Rulez !", $hFont, $aInfo[0], $hFormat, $hBrush) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) Return $GUI_RUNDEFMSG EndFunc ;==>WM_DRAWITEM Edited August 13 by Nine argumentum 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
ioa747 Posted yesterday at 02:36 AM Posted yesterday at 02:36 AM here is a native solution to get the Windows Installed Key, (from a VBS translation) Spoiler Option Explicit Dim objshell,path,DigitalID, Result Set objshell = CreateObject("WScript.Shell") 'Set registry key path Path = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\" 'Registry key value DigitalID = objshell.RegRead(Path & "DigitalProductId") Dim ProductName,ProductID,ProductKey,ProductData 'Get ProductName, ProductID, ProductKey ProductName = "Product Name: " & objshell.RegRead(Path & "ProductName") ProductID = "Product ID: " & objshell.RegRead(Path & "ProductID") ProductKey = "Installed Key: " & ConvertToKey(DigitalID) ProductData = ProductName & vbNewLine & ProductID & vbNewLine & ProductKey 'Show messbox if save to a file If vbYes = MsgBox(ProductData & vblf & vblf & "Save to a file?", vbYesNo + vbQuestion, "BackUp Windows Key Information") then Save ProductData End If 'Convert binary to chars Function ConvertToKey(Key) Const KeyOffset = 52 Dim isWin8, Maps, i, j, Current, KeyOutput, Last, keypart1, insert 'Check if OS is Windows 8 isWin8 = (Key(66) \ 6) And 1 Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4) i = 24 Maps = "BCDFGHJKMPQRTVWXY2346789" Do Current= 0 j = 14 Do Current = Current* 256 Current = Key(j + KeyOffset) + Current Key(j + KeyOffset) = (Current \ 24) Current=Current Mod 24 j = j -1 Loop While j >= 0 i = i -1 KeyOutput = Mid(Maps,Current+ 1, 1) & KeyOutput Last = Current Loop While i >= 0 If (isWin8 = 1) Then keypart1 = Mid(KeyOutput, 2, Last) insert = "N" KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 2, 1, 0) If Last = 0 Then KeyOutput = insert & KeyOutput End If ConvertToKey = Mid(KeyOutput, 1, 5) & "-" & Mid(KeyOutput, 6, 5) & "-" & Mid(KeyOutput, 11, 5) & "-" & Mid(KeyOutput, 16, 5) & "-" & Mid(KeyOutput, 21, 5) End Function 'Save data to a file Function Save(Data) Dim fso, fName, txt,objshell,UserName Set objshell = CreateObject("wscript.shell") 'Get current user name 'UserName = objshell.ExpandEnvironmentStrings("%UserName%") 'Create a text file on desktop fName = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\WindowsKeyInfo.txt" 'WScript.Echo "fName: " & fName Set fso = CreateObject("Scripting.FileSystemObject") Set txt = fso.CreateTextFile(fName) txt.Writeline Data txt.Close End Function Thank to 🏆 argumentum for helping me get rid of the "WScript.Shell" Object expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Global $info = ShowKeyPlus() ConsoleWrite($info & @CRLF) Func ShowKeyPlus() Local $sProductName, $sProductID, $sProductKey, $sProductData, $sDigitalID, $aDigitalID $sProductName = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName") $sProductID = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductId") $sDigitalID = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductId") Local $n, $sRet = "", $aArray = StringSplit($sDigitalID, "", 0) For $n = 4 To $aArray[0] Step 2 $sRet &= Int("0x" & $aArray[$n - 1] & $aArray[$n]) & "," Next $aDigitalID = StringSplit(StringTrimRight($sRet, 1), ",", 2) If Not IsArray($aDigitalID) Or UBound($aDigitalID) < 164 Then MsgBox(16, "Error", "Could not read the DigitalProductId from the registry.") Exit EndIf $sProductKey = ConvertToKey($aDigitalID) $sProductData = "Product Name: " & $sProductName & @CRLF & _ "Product ID: " & $sProductID & @CRLF & _ "Installed Key: " & $sProductKey Return $sProductData EndFunc Func ConvertToKey($aKeyBytes) Local Const $iKeyOffset = 52 Local Const $sMaps = "BCDFGHJKMPQRTVWXY2346789" Local $isWin8, $i, $j, $iCurrent, $sKeyOutput = "", $iLast $isWin8 = BitAND(Int($aKeyBytes[66] / 6), 1) $aKeyBytes[66] = BitOR(BitAND($aKeyBytes[66], 0xF7), BitShift(BitAND($isWin8, 2), 2)) For $i = 24 To 0 Step -1 $iCurrent = 0 For $j = 14 To 0 Step -1 $iCurrent = $iCurrent * 256 $iCurrent = $iCurrent + $aKeyBytes[$j + $iKeyOffset] $aKeyBytes[$j + $iKeyOffset] = Floor($iCurrent / 24) $iCurrent = Mod($iCurrent, 24) Next If $i > 0 Then $sKeyOutput = StringMid($sMaps, $iCurrent + 1, 1) & $sKeyOutput $iLast = $iCurrent Next If $isWin8 = 1 Then Local $sKeyPart1 = StringMid($sKeyOutput, 1, $iLast) Local $sInsert = "N" $sKeyOutput = $sKeyPart1 & $sInsert & StringMid($sKeyOutput, $iLast + 1) EndIf Return StringMid($sKeyOutput, 1, 5) & "-" & _ StringMid($sKeyOutput, 6, 5) & "-" & _ StringMid($sKeyOutput, 11, 5) & "-" & _ StringMid($sKeyOutput, 16, 5) & "-" & _ StringMid($sKeyOutput, 21, 5) EndFunc argumentum 1 I know that I know nothing
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