All Activity
- Past hour
-
gamalielrs joined the community
- Today
-
argumentum reacted to a post in a topic: Need help converting percentage to hex
-
Need help converting percentage to hex
WildByDesign replied to WildByDesign's topic in AutoIt General Help and Support
Thank you very much. That works beautifully. -
WildByDesign reacted to a post in a topic: Need help converting percentage to hex
-
argumentum reacted to a post in a topic: Need help converting percentage to hex
-
argumentum reacted to a post in a topic: Need help converting percentage to hex
-
ioa747 reacted to a post in a topic: Need help converting percentage to hex
-
Need help converting percentage to hex
UEZ replied to WildByDesign's topic in AutoIt General Help and Support
I misunderstood the value but it's easy, too: Local $iIntensity = '80' ;% of the alpha channel Local $iTintColor = '0x0078D4' $iIntensity = Int($iIntensity) * 255 / 100 Local $iColor = BitOR(BitShift($iIntensity > 255 ? 255 : $iIntensity < 0 ? 0: $iIntensity, -24), Int($iTintColor)) ConsoleWrite(Hex($iColor, 8) & @CRLF) _WinAPI_DwmEnableBlurBehindWindow10($hGUI, True, $iColor) -
Need help converting percentage to hex
WildByDesign replied to WildByDesign's topic in AutoIt General Help and Support
The more that I play around with these functions of yours, the more I realize how miraculous they are. One word: Magic! I have implemented this in my project now and it helps tremendously. Thank you again. Marked as Solution. Thank you for your reply and for your time. I appreciate it. I really like your technique with this and that knowledge that I gained from your example will likely help me in other projects. So I definitely benefited from your example. The only problem is that it did not return the correct colorref transparency hex in the first two characters after the '0x'. -
Need help converting percentage to hex
UEZ replied to WildByDesign's topic in AutoIt General Help and Support
Try: Local $iIntensity = '80' ;hex Local $iTintColor = '0x0078D4' Local $iColor = BitOR(BitShift(Dec($iIntensity), -24), Int($iTintColor)) ConsoleWrite(Hex($iColor, 8) & @CRLF) _WinAPI_DwmEnableBlurBehindWindow10($hGUI, True, $iColor) -
Need help converting percentage to hex
WildByDesign replied to WildByDesign's topic in AutoIt General Help and Support
Exquisite is the perfect and only word to describe your math, I agree. Thank you very much. -
CedKick joined the community
-
Need help converting percentage to hex
argumentum replied to WildByDesign's topic in AutoIt General Help and Support
ConsoleWrite(percentageOfAlpha(80, 0xFF1234FF) & @CRLF) ConsoleWrite(percentageOfAlpha(80, '0xFF0000FF') & @CRLF) ConsoleWrite(percentageOfAlpha(80, 0x0000FF) & @CRLF) ConsoleWrite(percentageOfAlpha(80, '0x0000FF') & @CRLF) Func percentageOfAlpha($iVal, $iColor) Return "0x" & percentageOfHex($iVal) & Hex($iColor, 6) ;~ Local $a = StringSplit(Hex($iColor, 6), "", 0) ;~ Return "0x" & percentageOfHex($iVal) & $a[$a[0] - 5] & $a[$a[0] - 4] & $a[$a[0] - 3] & $a[$a[0] - 2] & $a[$a[0] - 1] & $a[$a[0] - 0] EndFunc ;==>percentageOfAlpha Func percentageOfHex($iVal) $iVal = Int($iVal > 99 ? 100 : ($iVal < 1 ? 0 : $iVal)) ; no more than 100% or less than 0% Return Hex(Ceiling(($iVal * 100) * (2.55 * 100) / (100 * 100)), 2) ; calculate in integers, as floating point numbers suck in a CPU EndFunc ;==>percentageOfHex gotta say, my math is exquisite -
Need help converting percentage to hex
argumentum replied to WildByDesign's topic in AutoIt General Help and Support
ConsoleWrite( percentageOfHex(110) & @CRLF) ConsoleWrite( percentageOfHex(80) & @CRLF) ConsoleWrite( percentageOfHex(-2) & @CRLF) Func percentageOfHex($iVal) $iVal = Int($iVal > 99 ? 100 : ($iVal < 1 ? 0 : $iVal)) ; no more than 100% or less than 0% Return Hex(Ceiling(($iVal * 100) * (2.55 * 100) / (100 * 100)), 2) ; calculate in integers, as floating point numbers suck in a CPU EndFunc -
It's on my list to look at when I next have a dev spurt.
-
Need help converting percentage to hex
WildByDesign replied to WildByDesign's topic in AutoIt General Help and Support
It is just for coloring, but it has to be specific to work properly. It took me weeks, but I finally figured out how to add color hint to the blur behind for any color. I amended the original _WinAPI_DwmEnableBlurBehindWindow10 function by @scintilla4evr by adding optional color hint to the blur and color intensity (technically alpha). As follows: I am calling that with: Local $iIntensity = '80' Local $iTintColor = '0x0078D4' Local $iTintColorSwitch = Hex(_WinAPI_SwitchColor($iTintColor), 6) Local $iColor = '0x' & $iIntensity & $iTintColorSwitch _WinAPI_DwmEnableBlurBehindWindow10($hGUI, True, $iColor) The '80' refers to 50% which I am doing for now. But I really need the conversion. The API requires that the color comes in like: '0xFF0000FF' The last 6 are BGR which I've switched to RGB to make it easier for the user. The first 2 after the '0x' are what I need. Those deal with the alpha transparency and I want to make that easier for the user to supply. I don't want the user to have to supply B8 or FF, etc. I would like the user to supply anything between 0 and 100. And have the code convert to that 2 char hex. -
Need help converting percentage to hex
argumentum replied to WildByDesign's topic in AutoIt General Help and Support
If all this is for coloring, there is code for all that in https://www.autoitscript.com/forum/files/file/489-my-fine-tuned-high-contrast-theme/ If is for Hex, do give the user 255% because, why not. It'd simplify your code, enlighten the user, and gives fine control ( other wise you'd have to calculate "value * 2.55" each step ) for those that are very picky with colors. I look at it as from zero to Maximum Effort ! -
Need help converting percentage to hex
WildByDesign replied to WildByDesign's topic in AutoIt General Help and Support
Well that is actually really interesting. And thank you for your reply as well, by the way. I am still at that stage where I haven't really looked at AI at all yet. So looking at your AI response link there is my first actual look into something from AI. And to be honest, the response is really quite helpful. Particularly the way that it breaks down how it works. One reason why I have stayed away from AI is because I am still very new to AutoIt and I really would like to learn and fully understand things as best as possible. And then maybe dip into AI if needed. But this is very helped, I must admit. Thank you. -
Need help converting percentage to hex
WildByDesign replied to WildByDesign's topic in AutoIt General Help and Support
This is a good approach. And thank you for the quick reply as well. I like the idea of defining these ahead of time like you suggest. However, I have never done this before and also searching the forums and functions only come up with details about the newer Map functions (MapKeys, etc.) which of course are not related to what you suggest, I assume. I am pretty sure that I can do the math conversion that you suggest. But I'm not sure how to define them as you suggest mapping the values. Could you please provide a bit more info about that aspect or example? Thank you -
Need help converting percentage to hex
SOLVE-SMART replied to WildByDesign's topic in AutoIt General Help and Support
Hi @WildByDesign 👋 , this is one of rar good examples on when to use AI (in my opinion). Please have a look: https://chatgpt.com/share/68593c0e-abac-800f-b469-a29209d5d520 I really just copy and paste your question and already got an idea of how an approach could look like. I don't suggest to use AI to generate AutoIt code, becauce AutoIt code examples are not listed/progressed enough in the most LLMs, but I suggest to get the idea (which is close to your thoughts above) and then come up with the code/solution in AutoIt for yourself or by us as community 😀 . Hopefully this is a good starting point. Best regards Sven -
Need help converting percentage to hex
ahmet replied to WildByDesign's topic in AutoIt General Help and Support
What is FF when converted to decimal? You have minimum of zero in hexadecimal that matches 0 in dec. You also have FF in hexadecimal that matches to what in decimal? Then map (0,100) in decimal to (0,FF) afte you have converted it to decimal. -
I would like to have the user provide a percentage value (without percent symbol) and have the program convert that percentage to a hex value. The hex value is needed to then feed to a function. Please see this chart: Hexadecimal color code for transparency Examples: user gives 100, program converts to FF user gives 80, program converts to CC I have played with a bunch of hex to dec and dec to hex functions in forum but clearly it is the percentage aspect that is throwing my mind off here. I feel like I have to convert the percentage to integer or dec first but this is not an area that I am good at. Any help would be greatly appreciated. Thank you for your time.
-
Apologies for the late reply, I have been awol for a bit. Generally speaking, if the object name starts with windows.* then it'll be built into the OS. So we should have a decent chance of making these ones work. The Microsoft.* objects however are usually external. For these we'll probably need dependencies or a runtime in order to use them. So "Microsoft.UI.Content.DesktopChildSiteBridge" looks to be part of the Windows App SDK (And maybe WinUI3??). There will be associated *.winmd files in the SDK somewhere that contain object definitions. From these we should be able to wrap any object that we'll need in order to change colours etc.. But the tricky bit is how to implement the external objects/controls in the first place. Hope that makes sense. I will eventually get around to attacking this WinUI stuff - It'll just be whenever I have the time and energy to throw at it
-
State the last line to #include
SOLVE-SMART replied to Ilan3's topic in AutoIt General Help and Support
Hi @Ilan3, my suggestion is to avoid code duplications at all. For something like "I have an old and an new version of function XY" you usually would use a version control system like GIT. No need to store a old code state, functions, whatever - just commit your code state, tag it (by a good name) and it's recoverable in a easy way. Of course, only for aspects of your single example above it could be too much, but in general you would profit by the usage of GIT a lot regarding coding. My 2 Cents for this topic. Best regards Sven - Yesterday
-
Why does the code folding symbol look strange?
Jos replied to Jotos's topic in AutoIt General Help and Support
Ah sorry... you use notepad++ with the au3 lexer that comes with it? That is a very old version of the au3 scilexer as I've stopped sending updates a long time ago. Use SciTE full installer to use the latest version. -
Why does the code folding symbol look strange?
Jotos replied to Jotos's topic in AutoIt General Help and Support
I don't know why, but the problem is gone. -
Why does the code folding symbol look strange?
Jotos replied to Jotos's topic in AutoIt General Help and Support
The code is fine. It was alright BEFORE I used Notepad++. Just after I pushed the save button in Notpad++ and reopen the file with Autoit, I got this problem only at this file. All other files are as the same as before. -
Why does the code folding symbol look strange?
Jos replied to Jotos's topic in AutoIt General Help and Support
You probably have incomplete blocks in your code, so need to post the whole code in case you want me to have a look -
Hey! I used Notepad++ to edit an .au3 script. Now I noticed that the code folding symbols (the little minus/plus boxes next to functions or control structures) look strange when I open the file in Autoit — kind of stretched or misaligned, especially around Func ... EndFunc blocks. Here's a screenshot: Any suggestions on how to fix the visual issue? Thanks!
-
_Msg($iUI, $sText, $sTitle = @ScriptName, $iTimeout = 3, $iOption = 0) Displays a message using different UI elements based on the specified $iUI parameter. ; https://www.autoitscript.com/forum/topic/212945-_msg/ #include <MsgBoxConstants.au3> #include <TrayConstants.au3> #include <AutoItConstants.au3> ; #FUNCTION# ==================================================================================================================== ; Name...........: _Msg ; Description....: Displays a message using different UI elements based on the specified $iUI parameter. ; Syntax.........: _Msg($iUI, $sText, $sTitle = @ScriptName, $iTimeout = 3, $iOption = 0) ; Parameters.....: $iUI - Specifies the UI element to use: ; 0 - Return - nothing ; 1 - ConsoleWrite ; 2 - MsgBox ; 3 - ToolTip ; 4 - TrayTip ; $sText - The message text to be displayed. ; $sTitle - [optional] The title of the UI element. (Default is @ScriptName) ; $iTimeout - [optional] Timeout in seconds for displaying the message. (Default is 3) ; $iOption - [optional] Options for MsgBox, ToolTip, and TrayTip. (Default is 0) ; Return values .: Success: No specific return value, function exits after display. ; Failure: None ; Example .......: _Msg(1, "Hello, this is a test message.", @ScriptName, 5) ; =============================================================================================================================== Func _Msg($iUI, $sText, $sTitle = Default, $iTimeout = 3, $iOption = 0) If $sTitle = Default Then $sTitle = @ScriptName Switch $iUI Case 0 ; ### 0 Return - Does nothing, just exits the function. Return Case 1 ; ### 1 ConsoleWrite ConsoleWrite($sTitle & ": " & $sText & @CRLF) Case 2 ; ### 2 MsgBox MsgBox($iOption, $sTitle, $sText, $iTimeout) Case 3 ; ### 3 ToolTip ToolTip($sText, Default, Default, $sTitle, $iOption) Sleep($iTimeout * 1000) ; ToolTip doesn't have built-in timeout, so we use Sleep ToolTip("") ; Clear the tooltip after the timeout Case 4 ; ### 4 TrayTip TrayTip($sTitle, $sText, $iTimeout, $iOption) Sleep($iTimeout * 1000) ; give time to display it Case Else ; ### Else case - Does nothing, just exits the function. Return EndSwitch EndFunc ;==>_Msg ; Example Usage of _Msg Function ; ### ConsoleWrite ############################################### ; ConsoleWrite Example _Msg(1, "This message appears in the AutoIt console.", "Console Output") ; ConsoleWrite Example - Information-sign icon consisting of an 'i' in a circle _Msg(1, "This is an informational message.", "> Info") ; ConsoleWrite Example - Stop-sign icon _Msg(1, "This is a error message.", "! Error") ; ConsoleWrite Example - Question-mark icon _Msg(1, "This is a question message.", "+ Question") ; ConsoleWrite Example - Exclamation-point icon _Msg(1, "This is a warning message.", "- Warning") ; ### MsgBox ############################################### ; MsgBox Example - Information-sign icon consisting of an 'i' in a circle _Msg(2, "This is an informational message box.", "Info", 3, $MB_ICONINFORMATION) ; MsgBox Example - Stop-sign icon _Msg(2, "This is a error message box.", "Error", 3, $MB_ICONERROR) ; MsgBox Example - Question-mark icon _Msg(2, "This is a question message box.", "Question", 3, $MB_ICONQUESTION) ; MsgBox Example - Exclamation-point icon _Msg(2, "This is a warning message box.", "Warning", 3, $MB_ICONWARNING) ; ### ToolTip ############################################### ; ToolTip Example - no icon _Msg(3, "This is a question ToolTip.", "noicon", 3, $TIP_NOICON) ; ToolTip Example - Information-sign icon consisting of an 'i' in a circle _Msg(3, "This is an informational ToolTip.", "Info", 3, $TIP_INFOICON) ; ToolTip Example - error icon _Msg(3, "This is a error ToolTip.", "Error", 3, $TIP_ERRORICON) ; ToolTip Example - Warning icon _Msg(3, "This is a warning ToolTip.", "Warning", 3, $TIP_WARNINGICON) ; ### TrayTip ############################################### ; TrayTip Example - no icon _Msg(4, "This is a question TrayTip.", "noicon", 3, $TIP_ICONNONE) ; TrayTip Example - Information-sign icon consisting of an 'i' in a circle _Msg(4, "This is an informational TrayTip.", "Info", 3, $TIP_ICONASTERISK) ; TrayTip Example - error icon _Msg(4, "This is a error TrayTip.", "Error", 3, $TIP_ICONHAND) ; TrayTip Example - Warning icon _Msg(4, "This is a warning TrayTip.", "Warning", 3, $TIP_ICONEXCLAMATION) ; ################################################## ; Return Example (does nothing visible) _Msg(0, "This message will not be displayed.", "No Output") ; MsgBox Example $iTimeout = 0 _Msg(2, "All message examples have been executed.", "Examples Finished", 0)
-
Can not be outdated. These are timeless, as life itself. I would recommend putting everything in a zip file and add a simple password. That has shown to me to be better A/V wise for downloads.
-
Agree that a #cs - #ce could give issues when itself contains a comment block, but then you simply could use the "comment all" option in your preferred editor, adding a ";" in front of each line.