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 August 28 Posted August 28 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
argumentum Posted September 13 Posted September 13 (edited) ; moved to the example below _NowCalc() or _NowCalc(1) returns Local time _NowCalc(0) returns System time / UTC I should push the mod. in all _Now*() for the standard Date.au3 UDF 🤔 Why do I need this ?, ok, I'll tell you. I wanted a ProcessStartAge() to know if I should kill it because is taking too long. So.., I wanted to use System time instead of local for..., just in case. Like this: Exit ConsoleWrite('--- ProcessStartAge: ' & ProcessStartAge(@AutoItPID) & ' minutes ( will be zero if all works well )'& @CRLF) ; ---- ProcessStartAge: 0 min. Func ProcessStartAge($sProcessOrPID) ; https://www.autoitscript.com/forum/index.php?showtopic=139260&view=findpost&p=1545875 Local $sReturn = ProcessStartDate($sProcessOrPID, 0, 0) If @error Then Return SetError(@error, @extended, $sReturn) Return _DateDiff('n', $sReturn, _NowCalc_Mod(0)) EndFunc ;==>ProcessStartAge Func ProcessStartDate($sProcessOrPID, $iRet_tSYSTEMTIME = 0, $iLocalTime = 0) Local $aFT, $tFT, $tST, $iID = ProcessExists($sProcessOrPID) If $iID Then ; https://www.autoitscript.com/forum/index.php?showtopic=139260&view=findpost&p=1538034 $aFT = _WinAPI_GetProcessTimes($iID) If @error Or UBound($aFT) <> 3 Then Return SetError(@error, _WinAPI_GetLastError(), "GetProcessTimes FAILED") $tST = _Date_Time_FileTimeToSystemTime($iLocalTime ? _Date_Time_FileTimeToLocalFileTime($aFT[0]) : $aFT[0]) If $iRet_tSYSTEMTIME Then Return $tST Return _Date_Time_SystemTimeToDateTimeStr($tST, 1) EndIf Return SetError(11, 0, "Process does not exist") EndFunc ;==>ProcessStartDate Func _NowCalc_Mod($iLocalTime = 1) ; https://www.autoitscript.com/forum/index.php?showtopic=139260&view=findpost&p=1545875 Local $tLocalTime = ($iLocalTime ? _Date_Time_GetLocalTime() : _Date_Time_GetSystemTime()) If @error Then Return SetError(@error, @extended, "") Return SetError(0, $iLocalTime, $tLocalTime.Year & "/" & StringRight('00' & $tLocalTime.Month, 2) & "/" & StringRight('00' & $tLocalTime.Day, 2) & " " & _ StringRight('00' & $tLocalTime.Hour, 2) & ":" & StringRight('00' & $tLocalTime.Minute, 2) & ":" & StringRight('00' & $tLocalTime.Second, 2)) EndFunc ;==>_NowCalc_Mod ...and that's the full story Edited September 13 by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
FadeSoft Posted Sunday at 03:41 AM Posted Sunday at 03:41 AM (edited) This script forces all new and existing tray icons in Windows 11 to always show on the taskbar (instead of being hidden in the overflow). It does this by running a PowerShell command that sets the IsPromoted registry value for every app under HKCU:\Control Panel\NotifyIconSettings to 1, then restarts Explorer so changes take effect. You must compile this script if you want to run it every reboot. $Startup = @StartupDir & "\" & @ScriptName If Not FileExists($Startup) Then FileCopy(@ScriptFullPath, $Startup, 1) EndIf Run(@ComSpec & " /c powershell -NoProfile -Command ""Get-ChildItem 'HKCU:\Control Panel\NotifyIconSettings' | ForEach-Object { Set-ItemProperty -Path $_.PsPath -Name IsPromoted -Value 1 }""", "", @SW_HIDE) Edited Sunday at 04:24 AM by FadeSoft wakillon and WildByDesign 2
argumentum Posted yesterday at 06:44 AM Posted yesterday at 06:44 AM Exit ConsoleWrite(@CRLF & WM_NOTIFY_LEGEND(-2) & @CRLF & @CRLF) Func WM_NOTIFY_LEGEND($iInt) Local Static $aNM_Array = ["NM_FIRST", "NM_OUTOFMEMORY", "NM_CLICK", "NM_DBLCLK", "NM_RETURN", "NM_RCLICK", "NM_RDBLCLK", _ "NM_SETFOCUS", "NM_KILLFOCUS", "", "", "", "NM_CUSTOMDRAW", "NM_HOVER", "NM_NCHITTEST", "NM_KEYDOWN", _ "NM_RELEASEDCAPTURE", "NM_SETCURSOR", "NM_CHAR", "NM_TOOLTIPSCREATED", "NM_LDOWN", "NM_RDOWN", "NM_THEMECHANGED", _ "NM_FONTCHANGED","NM_CUSTOMTEXT/NM_TVSTATEIMAGECHANGING"] ; NM_CUSTOMTEXT uses NMCUSTOMTEXT struct ; NM_TVSTATEIMAGECHANGING uses NMTVSTATEIMAGECHANGING struct Local $iNumber = Int(StringReplace($iInt, "-", "")) Switch $iNumber Case 0 To 8, 12 To 24 Return $aNM_Array[$iNumber] EndSwitch Return SetError(1, 0, "NM_UNCLASSIFIED:" & $iInt) EndFunc ;==>WM_NOTIFY_LEGEND Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
mLipok Posted yesterday at 08:14 AM Posted yesterday at 08:14 AM 1 hour ago, argumentum said: Exit ConsoleWrite(@CRLF & WM_NOTIFY_LEGEND(-2) & @CRLF & @CRLF) Func WM_NOTIFY_LEGEND($iInt) Local Static $aNM_Array = ["NM_FIRST", "NM_OUTOFMEMORY", "NM_CLICK", "NM_DBLCLK", "NM_RETURN", "NM_RCLICK", "NM_RDBLCLK", _ "NM_SETFOCUS", "NM_KILLFOCUS", "", "", "", "NM_CUSTOMDRAW", "NM_HOVER", "NM_NCHITTEST", "NM_KEYDOWN", _ "NM_RELEASEDCAPTURE", "NM_SETCURSOR", "NM_CHAR", "NM_TOOLTIPSCREATED", "NM_LDOWN", "NM_RDOWN", "NM_THEMECHANGED", _ "NM_FONTCHANGED","NM_CUSTOMTEXT/NM_TVSTATEIMAGECHANGING"] ; NM_CUSTOMTEXT uses NMCUSTOMTEXT struct ; NM_TVSTATEIMAGECHANGING uses NMTVSTATEIMAGECHANGING struct Local $iNumber = Int(StringReplace($iInt, "-", "")) Switch $iNumber Case 0 To 8, 12 To 24 Return $aNM_Array[$iNumber] EndSwitch Return SetError(1, 0, "NM_UNCLASSIFIED:" & $iInt) EndFunc ;==>WM_NOTIFY_LEGEND Some description please Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
argumentum Posted yesterday at 01:41 PM Posted yesterday at 01:41 PM (edited) 6 hours ago, mLipok said: Some description please Is "self-descripting"(TM) WM_NOTIFY_LEGEND($NM_CLICK) returns "NM_CLICK" on a listview. The problem is that it may be too silly of a function, but when you see "-2" and you'd like to know what a "-2" mean, you'd "WM_NOTIFY_LEGEND(-2)" Actually, I'd like to know what those -100, -101, 102, ... , are. But could not find any info. All I found new are these "NM_FONTCHANGED","NM_CUSTOMTEXT" Edit: ..maybe the problem is my interpretation of the word "legend" that for some reason means "title", or "caption", or "what it reads" if that makes any linguistic sense. And I still feel ( as irrational as it may be ), that the given word ( legend ) should be descriptive as is the most befitting for the function it provides yet, I don't find much to support my feeling of the word. 🤷♂️ Edit2: maybe call it WM_NOTIFY_meaning() ?, let me know. Edit3: I asked my AI and it say: Spoiler Why "LEGEND" Might Be a Stretch "Legend" typically refers to a key (e.g., in charts or UI elements) that explains symbols or abbreviations. For example, a legend might clarify what a red triangle means in a chart. "Caption" or "Title" are more direct for a brief explanation of content (e.g., a photo’s caption or a section’s title). "Meaning" or "Definition" are better for returning the interpretation of a value (e.g., "42" → "the answer to life, the universe, and everything"). ...the more dig into it the more am unsure. Edited 23 hours ago by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
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