Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/10/2024 in all areas

  1. Input control for the GUI with label and rounded corners It all started in this post I tried to make a rectangle with rounded corners, using $GUI_GR_BEZIER. I managed to do it but the result did not satisfy me because $GUI_GR_BEZIER produced (is producing) a rough result. A flickering, which I could not overcome. So I changed the approach with two rectangles and a circle for each corner The script demonstrates the use of functions to create input fields with and without labels, and rounded corners, where the font size changes dynamically depending on the height of Input control. Valid value for Corner [0=Rectangle] to [($Height/2)=Round], Default=($Height/4) Example1: _CreateInputWL() #include <GUIConstants.au3> _Example() ;---------------------------------------------------------------------------------------- Func _Example() Local $hGUI = GUICreate("Shipping Details", 390, 320) GUISetStyle(-1, $WS_EX_COMPOSITED) GUISetBkColor(0x0D1117) Local $ShippingDetails = GUICtrlCreateLabel("Shipping Address", 10, 5, 380, 30) GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFD800) Local $Exit = GUICtrlCreateButton("EXIT", 20, 270, 95, 40) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x0D1117) GUICtrlSetBkColor(-1, 0xFFD800) Local $Corner = -1 ; *** <- Valid value from [0=Rectangle] to [($Height/2)=Round], Default=($Height/4) *** <- Local $FirstName = _CreateInputWL("First Name:", "John", 10, 50, 180, 40, 0x00FFFF, $Corner) Local $LastName = _CreateInputWL("Last Name:", "Doe", 200, 50, 180, 40, 0x00FFFF, $Corner) Local $Address = _CreateInputWL("Address:", "123 Main St", 10, 100, 230, 40, 0x00FFFF, $Corner) Local $Apt = _CreateInputWL("Apt:", "4B", 250, 100, 130, 40, 0x00FFFF, $Corner) Local $City = _CreateInputWL("City:", "Springfield", 10, 150, 140, 40, 0x00FFFF, $Corner) Local $State = _CreateInputWL("State:", "IL", 160, 150, 80, 40, 0x00FFFF, $Corner) Local $ZipCode = _CreateInputWL("Zip Code:", "627 01", 250, 150, 130, 40, 0x00FFFF, $Corner) Local $Email = _CreateInputWL("Email:", "jdoe627@gmail.com", 10, 200, 230, 40, 0x00FFFF, $Corner) Local $Phone = _CreateInputWL("Phone:", "0123456789", 250, 200, 130, 40, 0x00FFFF, $Corner) GUISetState(@SW_SHOW) Sleep(4000) GUICtrlSetData($Email[0], "Johndoe@gmail.com") GUICtrlSetData($Phone[1], "Mobile:") GUICtrlSetData($Phone[0], "654210789") ;********************************** While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $Exit ExitLoop EndSwitch WEnd ;********************************** EndFunc ;==>_Example ;---------------------------------------------------------------------------------------- Func _CreateInputWL($Label, $Text, $Left, $Top, $Width, $Height, $Color, $Corner = -1) ; $Corner Valid value [0=Rectangle] to [($Height/2)=Round], Default=($Height/4) ; Validate parameters If $Corner < 0 Or $Corner = Default Then $Corner = $Height / 4 If $Corner > $Height / 2 Then $Corner = $Height / 2 If $Width <= 0 Or $Height <= 0 Then Return SetError(1, 0, 0) EndIf ; graphic GUICtrlCreateGraphic($Left, $Top, $Width, $Height) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $Color, $Color) ; body GUICtrlSetGraphic(-1, $GUI_GR_RECT, $Corner, 0, $Width - ($Corner * 2), $Height) ; outer part GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, $Corner, $Width, $Height - ($Corner * 2)) ; inner part ; corners GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $Corner * 2, $Corner * 2) ; Top-left GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $Width - $Corner * 2, 0, $Corner * 2, $Corner * 2) ; Top-right GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, $Height - $Corner * 2, $Corner * 2, $Corner * 2) ; Bottom-left GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $Width - $Corner * 2, $Height - $Corner * 2, $Corner * 2, $Corner * 2) ; Bottom-right GUICtrlSetState(-1, $GUI_DISABLE) Local $idLabel = GUICtrlCreateLabel($Label, $Left + $Corner, $Top, $Width - ($Corner * 2), $Height * 0.4) GUICtrlSetBkColor($idLabel, $Color) GUICtrlSetFont($idLabel, $Height * 0.25) Local $idInput1 = GUICtrlCreateInput($Text, $Left + $Corner, $Top + ($Height * 0.35), $Width - ($Corner * 2), $Height * 0.60, -1 ,$WS_EX_COMPOSITED) GUICtrlSetFont($idInput1, $Height * 0.35) GUICtrlSetBkColor($idInput1, $Color) Local $aRet[] = [$idInput1, $idLabel] Return $aRet ; Return both ID EndFunc ;==>_CreateInputWL ;---------------------------------------------------------------------------------------- Example2: _CreateInputWL(), _CreateInput() #include <GUIConstants.au3> Global $hGUI = GUICreate("GUI") GUISetStyle ( -1, $WS_EX_COMPOSITED ) GUISetBkColor(0x0D1117) Global $id_1 = _CreateInput("INPUT1", 20, 20, 150, 30, "0xFFD800", 15) Global $id_2 = _CreateInput("INPUT2", 20, 60, 150, 30, "0xB6FF00") Global $id_3 = _CreateInput("INPUT3", 20, 100, 150, 35, "0x00FFFF", 10) Global $id_4 = _CreateInput("INPUT4", 20, 145, 150, 35, "0x0094FF") Global $id_5 = _CreateInput("INPUT5", 20, 190, 150, 40, "0xFF0000", 10) Global $id_6 = _CreateInput("INPUT6", 20, 240, 150, 40, "0xFF80EE") Global $id_7 = _CreateInputWL("Label:", "INPUT7", 220, 20, 150, 30, "0xFFD800", 10) Global $id_8 = _CreateInputWL("Label:", "INPUT8", 220, 60, 150, 30, "0xB6FF00") Global $id_9 = _CreateInputWL("Label:", "INPUT9", 220, 100, 150, 35, "0x00FFFF", 10) Global $id_10 = _CreateInputWL("Label:", "INPUT10", 220, 145, 150, 35, "0x0094FF") Global $id_11 = _CreateInputWL("Label:", "INPUT11", 220, 190, 150, 40, "0xFF0000", 10) Global $id_12 = _CreateInputWL("Label:", "INPUT12", 220, 240, 150, 40, "0xFF80EE") Global $id_13 = _CreateInputWL("LabelXXL:", "INPUTXXL", 20, 300, 350, 60, "0xB6B6B6", 30) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;---------------------------------------------------------------------------------------- Func _CreateInput($Text, $Left, $Top, $Width, $Height, $Color, $Corner = 10) ; $Corner Valid value [0=Rectangle] to [($Height/2)=Round], Default=($Height/4) ; Validate parameters If $Corner < 0 Or $Corner = Default Then $Corner = $Height / 4 If $Corner > $Height / 2 Then $Corner = $Height / 2 If $Width <= 0 Or $Height <= 0 Then Return SetError(1, 0, 0) EndIf ; graphic GUICtrlCreateGraphic($Left, $Top, $Width, $Height) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $Color, $Color) ; body GUICtrlSetGraphic(-1, $GUI_GR_RECT, $Corner, 0, $Width - ($Corner * 2), $Height) ; outer part GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, $Corner, $Width, $Height - ($Corner * 2)) ; inner part ; corners GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $Corner * 2, $Corner * 2) ; Top-left GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $Width - $Corner * 2, 0, $Corner * 2, $Corner * 2) ; Top-right GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, $Height - $Corner * 2, $Corner * 2, $Corner * 2) ; Bottom-left GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $Width - $Corner * 2, $Height - $Corner * 2, $Corner * 2, $Corner * 2) ; Bottom-right GUICtrlSetState(-1, $GUI_DISABLE) $idInput1 = GUICtrlCreateInput($Text, $Left + $Corner, $Top + ($Height * 0.2), $Width - ($Corner * 2), $Height * 0.6, -1, $WS_EX_COMPOSITED) GUICtrlSetFont($idInput1, $Height * 0.4, 400) GUICtrlSetBkColor($idInput1, $Color) Return $idInput1 EndFunc ;==>_CreateInput ;---------------------------------------------------------------------------------------- Func _CreateInputWL($Label, $Text, $Left, $Top, $Width, $Height, $Color, $Corner = -1) ; $Corner Valid value [0=Rectangle] to [($Height/2)=Round], Default=($Height/4) ; Validate parameters If $Corner < 0 Or $Corner = Default Then $Corner = $Height / 4 If $Corner > $Height / 2 Then $Corner = $Height / 2 If $Width <= 0 Or $Height <= 0 Then Return SetError(1, 0, 0) EndIf ; graphic GUICtrlCreateGraphic($Left, $Top, $Width, $Height) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $Color, $Color) ; body GUICtrlSetGraphic(-1, $GUI_GR_RECT, $Corner, 0, $Width - ($Corner * 2), $Height) ; outer partt GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, $Corner, $Width, $Height - ($Corner * 2)) ; inner part ; corners GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $Corner * 2, $Corner * 2) ; Top-left GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $Width - $Corner * 2, 0, $Corner * 2, $Corner * 2) ; Top-right GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, $Height - $Corner * 2, $Corner * 2, $Corner * 2) ; Bottom-left GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $Width - $Corner * 2, $Height - $Corner * 2, $Corner * 2, $Corner * 2) ; Bottom-right GUICtrlSetState(-1, $GUI_DISABLE) Local $idLabel = GUICtrlCreateLabel($Label, $Left + $Corner, $Top, $Width - ($Corner * 2), $Height * 0.4) GUICtrlSetBkColor($idLabel, $Color) GUICtrlSetFont($idLabel, $Height * 0.25) Local $idInput1 = GUICtrlCreateInput($Text, $Left + $Corner, $Top + ($Height * 0.35), $Width - ($Corner * 2), $Height * 0.60, -1, $WS_EX_COMPOSITED) GUICtrlSetFont($idInput1, $Height * 0.35) GUICtrlSetBkColor($idInput1, $Color) Local $aRet[]=[$idInput1, $idLabel] Return $aRet ; Return both ID EndFunc ;==>_CreateInputWL ;---------------------------------------------------------------------------------------- Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
    1 point
  2. Dan_555

    Dan's misc. Scripts

    This is a mix of few scripts found here on the forum. What does it do ? - It is a Font Preview App. It has a Big Label, Normal Label, Edit box, Input box, Resizable Input box and a Big Button. - All of these are filled with a text. The script takes a list of fonts (although there are some missing like Terminal ... which you can type in the font name box) and applies the font with the settings to the above controls - On The Fly. You can see the result immediately. The Input box on the bottom right side holds the AutoIt ready command. If you click on the "Remember font", this setting will be saved (and added to the edit box above it). You can copy the text from the edit box, but conveniently, this app will Copy all the "Remembered" font commands and copy it to the clipboard. (There should be no duplicate entries) ;modified version of this script: https://www.autoitscript.com/forum/topic/52677-font-selector/?do=findComment&comment=398585 ;mixed with (and modified) https://www.autoitscript.com/forum/topic/202989-enumerating-fonts/?do=findComment&comment=1458177 #include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #include <WinAPIGdi.au3> #include <GuiEdit.au3> $hGui = GUICreate("Font", 640, 252, 0, 0, $WS_SYSMENU + $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX + $WS_THICKFRAME) Global $aWeight[][] = [["$FW_DONTCARE", 0], ["$FW_THIN", 100], ["$FW_EXTRALIGHT", 200], ["$FW_LIGHT", 300], ["$FW_NORMAL", 400], ["$FW_MEDIUM", 500], ["$FW_SEMIBOLD", 600], ["$FW_BOLD", 700], ["$FW_EXTRABOLD", 800], ["$FW_HEAVY", 900]] Opt("GUIResizeMode", 1) $fontlist = _FontGetList(0) _ArrayDelete($fontlist, 0) $aEnumFont = EnumFontTree() For $i = 1 To UBound($aEnumFont) - 1 _ArrayAdd($fontlist, $aEnumFont[$i]) Next $aEnumFont="" ;Free the Array $fontlist = _ArrayUnique($fontlist) _ArrayDelete($fontlist, 0) _ArraySort($fontlist) $fontselect = GUICtrlCreateCombo("Arial", 0, 200, 215, 20) For $i = 0 To UBound($fontlist) - 1 GUICtrlSetData($fontselect, $fontlist[$i], "Arial") Next $fontlist="" ;Free the Array $fontsize = GUICtrlCreateCombo("2", 216, 200, 45, 20) GUICtrlSetData($fontsize, "4|5|6.5|7|7.5|8|8.5|9|9.5|10|10.5|11|11.5|12|12.5|14|14.5|16|16.5|18|18.5|20|20.5|22|22.5|24|24|26|28|30|32|36|48|72", "10") $fontstyle = GUICtrlCreateCombo("Normal", 262, 200, 75, 20) GUICtrlSetData($fontstyle, "Italic|Underline|Strike", "Normal") $weight = GUICtrlCreateCombo("", 233, 179, 103, 20) $setfont = GUICtrlCreateButton("Test Font123", 233, 0, 103, 45) $edit = GUICtrlCreateEdit("", 339, 0, 300, 193) $label = GUICtrlCreateLabel("", 0, 0, 230, 193) $input = GUICtrlCreateInput("Font Test123", 233, 46, 103, 45) $inputSmall = GUICtrlCreateInput("Font Test123", 233, 93, 103, 20) GUICtrlSetResizing(-1, $GUI_DOCKSIZE) $labelSmall = GUICtrlCreateLabel("Font Test123", 233, 117, 103, 20) GUICtrlSetResizing(-1, $GUI_DOCKSIZE) $usefont = GUICtrlCreateButton("Remember font", 233, 150, 103, 22) GUICtrlSetTip($usefont, "Adds the definition into a variable and to the edit box! " & @CRLF & "The variable will be copied into clipboard at the end of the program", "Info:") $output = GUICtrlCreateInput("", 340, 200, 298, 20) GUICtrlSetBkColor($label, 0xff00ff) GUISetState() $tmp = "" $tmp = $tmp & "ABCDEFGHIJLKMNOPQRSTUVWYYZ" $tmp = $tmp & "ÜÄÖßüäöß" & @CRLF $tmp = $tmp & "abcdefghijlkmnopqrstuvwyyz" & @CRLF $tmp = $tmp & "1234567890!§$%&/()=?`|_-,<>|@^" & @CRLF $tmp = $tmp & "******************************" & @CRLF $tmp = $tmp & "* * * *" & @CRLF $tmp = $tmp & "* *" & @CRLF $tmp = $tmp & "******************************" & @CRLF For $x = 1 To 255 $tmp1 = "" If Mod($x, 30) = 1 Then $tmp1 = @CRLF $tmp = $tmp & Chr($x) & $tmp1 Next GUICtrlSetData($label, $tmp & @CRLF) GUICtrlSetData($edit, $tmp & @CRLF) $tmp = "" $tmp1 = "" For $x = 0 To UBound($aWeight) - 1 $tmp1 = "|" If $x = UBound($aWeight) - 1 Then $tmp1 = "" $tmp = $tmp & $aWeight[$x][0] & $tmp1 Next GUICtrlSetData($weight, $tmp, $aWeight[4][0]) Local $diffFSize = -1, $diffSel, $diffAttr, $diffWe, $changed = 0 Local $ClipboardText[0] Do $msg3 = GUIGetMsg() If $diffFSize <> GUICtrlRead($fontsize) Then $changed = 1 If $diffSel <> GUICtrlRead($fontselect) Then $changed = 1 If $diffAttr <> GUICtrlRead($fontstyle) Then $changed = 1 If $diffWe <> GUICtrlRead($weight) Then $changed = 1 If $changed = 1 Then If GUICtrlRead($fontstyle) = "Normal" Then $attribute = 0 ElseIf GUICtrlRead($fontstyle) = "Italic" Then $attribute = 2 ElseIf GUICtrlRead($fontstyle) = "Underline" Then $attribute = 4 ElseIf GUICtrlRead($fontstyle) = "Strike" Then $attribute = 8 EndIf $diffFSize = GUICtrlRead($fontsize) $diffSel = GUICtrlRead($fontselect) $diffAttr = GUICtrlRead($fontstyle) $diffWe = GUICtrlRead($weight) $tmp = "" For $x = 0 To UBound($aWeight) - 1 If $aWeight[$x][0] = $diffWe Then $tmp = $aWeight[$x][1] ExitLoop EndIf Next GUICtrlSetFont($edit, $diffFSize, $tmp, $attribute, $diffSel) GUICtrlSetFont($setfont, $diffFSize, $tmp, $attribute, $diffSel) GUICtrlSetFont($label, $diffFSize, $tmp, $attribute, $diffSel) GUICtrlSetFont($input, $diffFSize, $tmp, $attribute, $diffSel) GUICtrlSetFont($inputSmall, $diffFSize, $tmp, $attribute, $diffSel) GUICtrlSetFont($labelSmall, $diffFSize, $tmp, $attribute, $diffSel) GUICtrlSetData($output, "GuiCtrlSetFont ($id," & $diffFSize & "," & $diffWe & "," & $attribute & "," & $diffSel & ")") $changed = 0 EndIf If $msg3 = $usefont Then $tmp = GUICtrlRead($output) _ArrayAdd($ClipboardText, $tmp) _GUICtrlEdit_AppendText($edit, $tmp & @CRLF) EndIf Until $msg3 = $GUI_EVENT_CLOSE If IsArray($ClipboardText) And UBound($ClipboardText) > 0 Then $ClipboardText = _ArrayUnique($ClipboardText) _ArrayDelete($ClipboardText, 0) _ArrayToClip($ClipboardText, @CRLF) EndIf GUIDelete($hGui) Exit ;=============================================================================== ; Function Name: _FontGetList() ; Description: Returns an array with a list of all fonts currently installed on the system. ; Parameter(s): $i_opt - An Integer, 0 or 1. 0 will create a 1D array with font names only. ; 1 will create a 2d array with font names in the first column, font file names in the second ; Requirement(s): None ; Return Value(s): 1D-2D Array = [0] or [0][0] Contains total number of fonts. ; Author(s): Simucal <simucal@gmail.com> ; Revision: 20060501A ; ;=============================================================================== Func _FontGetList($i_opt = 0) Dim $a_FontNames[1], $a_FontNamesFiles[1][1], $i = 1 If @OSType = "WIN32_NT" Then $regkey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" If @OSType = "WIN32_WINDOWS" Then $regkey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts" While 1 $s_temp = RegEnumVal($regkey, $i) If @error <> 0 Then ExitLoop $s_temp2 = RegRead($regkey, $s_temp) $s_temp = StringRegExpReplace($s_temp, "\s\(.*?\)(\s*)?", "") If $i_opt = 0 Then ReDim $a_FontNames[($i + 1)] $a_FontNames[$i] = $s_temp ElseIf $i_opt = 1 Then ReDim $a_FontNames[($i + 1)] $a_FontNames[$i] = $s_temp & "|" & $s_temp2 EndIf $i = $i + 1 WEnd If $i_opt = 0 Then _ArraySort($a_FontNames) $a_FontNames[0] = (UBound($a_FontNames) - 1) Return ($a_FontNames) ElseIf $i_opt = 1 Then _ArraySort($a_FontNames) ; Sort with font names and files as a single array For $i = 1 To (UBound($a_FontNames) - 1) ; then split it up into 2D, so they will be alphabatized together. $s_fontsplit = StringSplit($a_FontNames[$i], "|") If IsArray($s_fontsplit) = 1 Then ReDim $a_FontNamesFiles[($i + 1)][2] $a_FontNamesFiles[$i][0] = $s_fontsplit[1] $a_FontNamesFiles[$i][1] = $s_fontsplit[2] EndIf Next $a_FontNamesFiles[0][0] = (UBound($a_FontNamesFiles) - 1) Return ($a_FontNamesFiles) EndIf EndFunc ;==>_FontGetList Func EnumFontTree() Local $font_list = _WinAPI_EnumFontFamilies(0, "", "", -1, "@*", True) _ArraySort($font_list, 0, 1, 0, 0) Local $font_tree[1] $i = 1 While ($i <= $font_list[0][0]) $tmp = $font_list[$i][0] _ArrayAdd($font_tree, $tmp) $i = $i + 1 WEnd Return $font_tree EndFunc ;==>EnumFontTree
    1 point
  3. Could you test this piece of code in your setup? Open file AutoItAutoComplete.lua andchange this part on line 661: -- print("-->",endPos, str:sub(-1 * reststring:len()):lower(), reststring, (str:sub(-1 * reststring:len()):lower() == reststring:lower()) ) -- move the cursor to the end when equal to: -- print("-->",endPos, str:sub(-1 * reststring:len()):lower(), reststring, (str:sub(-1 * reststring:len()):lower() == reststring:lower()) ) self:DebugPrint("OnUserListSelection>",endPos, str:sub(-1 * reststring:len()):lower(), reststring, (str:sub(-1 * reststring:len()):lower() == reststring:lower()) ) -- fix DOT in reststring word if reststring:find('%.') then editor:SetTargetRange(endPos, editor:WordEndPosition(endPos, true)-reststring:len()+reststring:find('%.')-1) reststring = reststring:sub(1,reststring:find('%.')-1) self:DebugPrint("Fixed DOT in variable >",endPos, str:sub(-1 * reststring:len()):lower(), reststring, (str:sub(-1 * reststring:len()):lower() == reststring:lower()) ) end -- move the cursor to the end when equal Let me know if that fixes it for you so I can update the source. Cheers, Jos
    1 point
  4. #include "bignum.au3" #include <Array.au3> #include <String.au3> Global Const $ANS1_Tags[35][2] = [ _ ["01","BOOLEAN"], _ ["02","INTEGER"], _ ["03","BIT STRING"], _ ["04","OCTET STRING"], _ ["05","NULL"], _ ["06","OBJECT IDENTIFIER"], _ ["07","ObjectDescriptor"], _ ["08","EXTERNAL"], _ ["09","REAL"], _ ["0A","ENUMERATED"], _ ["0B","EMBEDDED PDV"], _ ["0C","UTF8String"], _ ["0D","RELATIVE-OID"], _ ["0E","TIME"], _ ["0F","unknow"], _ ["10","SEQUENCE"], _ ["11","SET"], _ ["12","NumericString"], _ ["13","PrintableString"], _ ["14","TeletexString, T61String"], _ ["15","VideotexString"], _ ["16","IA5String"], _ ["17","UTCTime"], _ ["18","GeneralizedTime"], _ ["19","GraphicString"], _ ["1A","VisibleString"], _ ["1B","GeneralString"], _ ["1C","UniversalString"], _ ["1D","CHARACTER STRING"], _ ["1E","BMPString"], _ ["A0","[0]"], _ ["A2","[2]"], _ ["A5","[5]"], _ ["40","Application"], _ ["30","SEQUENCE"]] ;_ArrayDisplay($ANS1_Tags) Local $exponent1, $exponent2, $coefficient, $prime1, $prime2, $privateExponent, $publicExponent, $modulus Local $sFilePath = FileOpenDialog("Please select Key file", "", "Key File(*.*)", 1) If @error Then Exit Local $hFileOpen = FileOpen($sFilePath, 0) Local $sFileRead = FileRead($hFileOpen) if StringInStr($sFileRead,"-----BEGIN PRIVATE KEY-----") <> 0 Then $PEM = Hex(_WinAPI_Base64Decode(_StringBetween($sFileRead,"-----BEGIN PRIVATE KEY-----","-----END PRIVATE KEY-----")[0])) $arrayin = ASN1_Parse($PEM) Private_MAP($arrayin) ElseIf StringInStr($sFileRead,"-----BEGIN RSA PRIVATE KEY-----") <> 0 Then $PEM = Hex(_WinAPI_Base64Decode(_StringBetween($sFileRead,"-----BEGIN RSA PRIVATE KEY-----","-----END RSA PRIVATE KEY-----")[0])) $arrayin = ASN1_Parse($PEM) Private_MAP($arrayin) ElseIf StringInStr($sFileRead,"-----BEGIN PUBLIC KEY-----") <> 0 Then $PEM = Hex(_WinAPI_Base64Decode(_StringBetween($sFileRead,"-----BEGIN PUBLIC KEY-----","-----END PUBLIC KEY-----")[0])) $arrayin = ASN1_Parse($PEM) Puplic_MAP($arrayin) ElseIf StringInStr($sFileRead,"-----BEGIN PUBLIC KEY-----") <> 0 Then $PEM = Hex(_WinAPI_Base64Decode(_StringBetween($sFileRead,"-----BEGIN RSA PUBLIC KEY-----","-----END RSA PUBLIC KEY-----")[0])) $arrayin = ASN1_Parse($PEM) Puplic_MAP($arrayin) EndIf Func ASN1_Parse($data) Local $dataLen, $selectstring, $selectstring_tag, $selectstring_len, $selectstring_len_Dec, $selectstring_data_start, $selectstring_data, $tag_offset, $hr, $result[0][8], $class = 0, $Data_offset = 0 Local $FC = 0, $temp_i, $temp_offset, $CD, $temp_data, $zero_add, $temp_original_len, $temp_original_data $dataLen = StringLen($data) $temp_original_data = $data $temp_original_len = $dataLen ;MsgBox(0,"",$dataLen) _ArrayAdd($result,"Class|ANS.1 TAG|Len TAG|Len Hex|Data String|TAG's Len|Len Dec|Data offset") While $dataLen <> 0 for $i = 1 to $dataLen Step 2 $selectstring = StringMid($data,$i,2) if $selectstring = "" Then ExitLoop EndIf if $selectstring = "00" Then $zero_add += 1 EndIf $hr = _ArraySearch($ANS1_Tags, $selectstring) if $selectstring = "30" or $selectstring = "04" or $selectstring = "03" or $selectstring = "A0" or $selectstring = "A5" or $selectstring = "A2" Then $FC = 1 Else $FC = 0 EndIf ;msgbox(0,$FC,$selectstring) if $hr <> -1 Then $selectstring_tag = StringMid($data,$i+2,2) if $selectstring_tag = "82" Then $selectstring_len = StringMid($data,$i+4,4) $selectstring_len_Dec = Dec(Hex(Binary("0x"&$selectstring_len))) $tag_offset = 8 $selectstring_data_start = $i + 8 ElseIf $selectstring_tag = "81" Then $selectstring_len = StringMid($data,$i+4,2) $selectstring_len_Dec = Dec(Hex(Binary("0x"&$selectstring_len))) $tag_offset = 6 $selectstring_data_start = $i + 6 Else $selectstring_len = $selectstring_tag $selectstring_len_Dec = Dec(Hex(Binary("0x"&$selectstring_len))) $tag_offset = 4 $selectstring_data_start = $i + 4 EndIf if UBound($result) >= 2 Then if $class <> $result[UBound($result)-1][0] Then $Data_offset-=$result[UBound($result)-1][6] EndIf EndIf $Data_offset+=$zero_add $selectstring_data = StringMid($data,$selectstring_data_start,$selectstring_len_Dec*2) _ArrayAdd($result,$class&"|"&$selectstring&"|"&$selectstring_tag&"|"&$selectstring_len&"|"&$selectstring_data&"|"&$tag_offset/2&"|"&$selectstring_len_Dec&"|"&$Data_offset) $zero_add = 0 ;if $FC = 1 Then if $FC = 1 and $class <> 0 Then $CD = $selectstring_len_Dec $temp_data = $data $class+=1 $data = $selectstring_data $dataLen = StringLen($data) $i+=$tag_offset+$selectstring_len_Dec*2 - 2 $temp_i = $i $Data_offset+=$tag_offset/2 + $selectstring_len_Dec $temp_Data_offset = $Data_offset $i = 1 - 2 ContinueLoop EndIf if $CD <> 0 Then $CD = $CD - $selectstring_len_Dec - ($tag_offset/2) if $CD = 0 Then $i = $temp_i $Data_offset = $temp_Data_offset $data = $temp_data $dataLen = StringLen($data) $class-=1 ContinueLoop EndIf EndIf $Data_offset+=$tag_offset/2 + $selectstring_len_Dec $i+=$tag_offset+$selectstring_len_Dec*2 - 2 ;_ArrayDisplay($result) EndIf Next $class+=1 $data = $selectstring_data $dataLen = StringLen($data) if $FC = 0 Then ;MsgBox(0,"",$Data_offset) if $Data_offset*2 >= $temp_original_len Then ExitLoop Else $data = StringMid( $temp_original_data ,2*($i)+1,$temp_original_len-2*($i)) $dataLen = StringLen($data) $class-=2 EndIf EndIf WEnd _ArrayDisplay($result) Return $result EndFunc Func Puplic_MAP($data) Local $CC = 0 For $i = UBound($data) - 1 to 0 step -1 if $data[$i][1] = "02" Then $CC+=1 if $CC = 2 Then $modulus = $data[$i][4] MsgBox(0,"modulus - n (HEX)",$modulus) MsgBox(0,"modulus - n (DEC)",_BigHex_ToBase2($modulus,16)) elseif $CC = 1 Then $publicExponent = $data[$i][4] MsgBox(0,"publicExponent - e",Dec(Hex("0x"&$publicExponent))) EndIf EndIf Next EndFunc Func Private_MAP($data) Local $CC = 0 For $i = UBound($data) - 1 to 0 step -1 if $data[$i][1] = "02" Then $CC+=1 if $CC = 8 Then $modulus = $data[$i][4] MsgBox(0,"modulus - n (HEX)",$modulus) MsgBox(0,"modulus - n (DEC)",_BigHex_ToBase2($modulus,16)) elseif $CC = 7 Then $publicExponent = $data[$i][4] MsgBox(0,"publicExponent - e",Dec(Hex("0x"&$publicExponent))) elseif $CC = 6 Then $privateExponent = $data[$i][4] MsgBox(0,"privateExponent - d",$privateExponent) elseif $CC = 5 Then $prime1 = $data[$i][4] MsgBox(0,"prime1 - p (HEX)",$prime1) MsgBox(0,"prime1 - p (DEC)",_BigHex_ToBase2($prime1,16)) elseif $CC = 4 Then $prime2 = $data[$i][4] MsgBox(0,"prime2 - q (HEX)",$prime2) MsgBox(0,"prime2 - q (DEC)",_BigHex_ToBase2($prime2,16)) elseif $CC = 3 Then $exponent1 = $data[$i][4] MsgBox(0,"exponent1 - d mod (p - 1)",$exponent1) elseif $CC = 2 Then $exponent2 = $data[$i][4] MsgBox(0,"exponent2 - d mod (q - 1)",$exponent2) elseif $CC = 1 Then $coefficient = $data[$i][4] MsgBox(0,"coefficient - q–1 mod p",$coefficient) EndIf EndIf Next EndFunc Func _WinAPI_Base64Decode($sB64String) Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "") Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]") $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "") Return DllStructGetData($bBuffer, 1) EndFunc 1.Execute process 2.Select key file 3.Pop the information 1.pem 2.pem
    1 point
  5. Thank you for this amazing UDF, Nine! A small bug that caught me today - _MKHKS_UnRegister_HotKey fails if a hotkey was registered with more than one keyboard. This is because your for loop is missing "Step -1" so that the loop is specified to go from 1 to 0, for example, which causes it to never run. The original line is: Func _MKHKS_UnRegister_HotKey ..... For $i = UBound($aIdx) - 1 To 0     If $iKeyBoard < 0 Or $aMKHKS_HotKeySet[$aIdx[$i]][2] = $iKeyBoard Then It should read:  For $i = UBound($aIdx) - 1 To 0 Step -1     If $iKeyBoard < 0 Or $aMKHKS_HotKeySet[$aIdx[$i]][2] = $iKeyBoard Then On a related note, it would be nice to have a function to handle a new "keyboard" being attached. The problem is the merely re-assigning $aMKHKS_Keyboard, aside from messing with an "internal variable" is not sufficient, since it then breaks any currently assigned hotkeys. Preserving hotkeys across a change of the keyboard list would be a bit tricky -- you currently don't store enough information in $aMKHKS_HotKeySet to do it. But at the very least, all existing hotkeys should be unregistered. My proposed function would be something like Func RescanKeyboards($exclude)   Local $aCurrentKbds = __MKHKS_EnumRawKeyboards($exclude)   If _ArrayToString($aMKHKS_Keyboard) <> _ArrayToString($aCurrentKbds) Then     "ToDo: Unregister all hotkeys"    $aMKHKS_Keyboard = $aCurrentKbds    Return True ;kdbs changed, user needs to reinitialize all hotkeys   Endif   Return False EndFunc My use case: I'm handling "keystrokes" from a remote control (Logitech R400 Wireless Presenter Remote Control), but also assigns hotkeys to the local keyboard. The script runs at Windows startup but the usb stick for the remote is not immediately plugged in. So if the code doesn't find the remote (based on its ID), it scans until it is found, then updates the keyboard definitions. Also, to make the program a bit less dependent on exact ID strings, anything that is not the remote controller is treated as the local keyboard -- usually there is more than one of these, just because of how the manufacturers specify their keyboards (keypad vs. main kbd, for example), hence the need to unregister keys from multiple keyboards. Thanks again for all your hard work on this!
    1 point
  6. My understanding is that - as the CID part is completely embedded in the HTML that has to be created by you - the mail program (be it Outlook or CMail or ...) is only used to put the HTML mail into an envelope and transmit it. No changes to the HTML will be done by Outlook/CMail. But I could be wrong
    1 point
  7. ValentinM, Good day yesterday with the nietos and I think I have a new solution for you today - the scrolling problem was exactly what I thought it might be and the solution was pretty easy to code. Here is a new Beta: GUIListViewEx_Mod.au3 And the example I have been using to test which works perfectly for me: GLVEx_Ex.au3 If you still have problems, please let me see the code you are using to create, load and initialise your ListView to see if I can spot the reason. M23 Edit: Found an edge case in testing - working on it. Edit 2: New Beta uploaded.
    1 point
  8. WinGetClassList EnableExplicit Structure winparam hwnd.i title.s text.s result.s EndStructure Procedure EnumWinProc(hwnd.l, *ptr.winparam) Protected title${256} ; буфер GetWindowText_(hwnd, @title$, 256) If Asc(title$) And title$ = *ptr\title PokeL(@*ptr\hwnd, hwnd) ProcedureReturn 0 EndIf ProcedureReturn 1 EndProcedure Procedure EnumChildProc(hwnd.l, *ptr.winparam) Protected class${256}, text${256} GetClassName_(hwnd, @class$, 256) If Asc(class$) If Asc(*ptr\text) GetWindowText_(hwnd, @text$, 256) If text$ = *ptr\text *ptr\result + class$ + #LF$ EndIf Else *ptr\result + class$ + #LF$ EndIf EndIf ProcedureReturn 1 EndProcedure Procedure.s WinGetClassList(title$, text$ = "") Protected ptr.winparam ptr\title = title$ ptr\text = text$ EnumWindows_(@EnumWinProc(), @ptr) If ptr\hwnd EnumChildWindows_(ptr\hwnd, @EnumChildProc(), @ptr) ptr\result = RTrim(ptr\result, #LF$) ProcedureReturn ptr\result EndIf EndProcedure Debug WinGetClassList("Untitled — Notepad")
    1 point
  9. Nhardel

    ListUserSessions

    @argumentum So I will be the first to admit I don't understand dll structure and converting back to readable data. I have been toying with your listusersessions array trying to understand it and get it to pull the data I want. But I need two additional columns of info. WTSLogonTime & WTSIdleTime. Here are the changes I have made to your base code but I don't think I am converting things correctly. If you could help me understand what I am doing wrong and where I can find the different structures for each property. I believe I want to create an array that list all the properties for all sessions. I made no changes to the function _WTSQuerySessionInformation Func ListUserSessions() ; mod. of https://www.autoitscript.com/forum/topic/139774-dllcall-and-returned-pointers/?do=findComment&comment=980850 Local $_Self_SessionId = _WTSQuerySessionInformation(-1, 4) ; -1 = current user ; 4 = WTSSessionId Local Enum $e_IsSelf_SessionId, $e_SessionName, $e_UserName, $e_SessionId, $e_StateName, $e_StateInt, $e_ClientName, $e_ClientIp, $e_Domain, $e_IdleTime, $e_LogonTime, $e_UBound Local Const $tagWTS_SESSION_INFO = 'dword SessionId;ptr WinStationName;uint State' Local $aResult = DllCall('wtsapi32.dll', 'int', 'WTSEnumerateSessionsW', 'ptr', 0, 'dword', 0, 'dword', 1, 'ptr*', 0, 'dword*', 0) If @error Or $aResult[0] = 0 Then Return SetError(1, 0, "") ; https://docs.microsoft.com/en-us/windows/desktop/api/wtsapi32/ne-wtsapi32-_wts_connectstate_class Local $aConnectionState = StringSplit("Active,Connected,ConnectQuery,Shadow,Disconnected,Idle,Listen,Reset,Down,Init", ",", 2) Local $tInfo, $Offset = 0, $c = 0, $aReturn[$aResult[5] + 1][$e_UBound] ; $e_UBound is the last enumerator, just to determine the size of the array $aReturn[0][$e_SessionId] = "ID" $aReturn[0][$e_SessionName] = "SessionName" $aReturn[0][$e_StateInt] = "StateInt" $aReturn[0][$e_StateName] = "State" $aReturn[0][$e_UserName] = "UserName" $aReturn[0][$e_ClientName] = "ClientName" $aReturn[0][$e_ClientIp] = "ClientIp" $aReturn[0][$e_Domain] = "Domain" $aReturn[0][$e_IdleTime] = "IdleTime" $aReturn[0][$e_LogonTime] = "LogonTime" For $i = 1 To $aResult[5] $tInfo = DllStructCreate($tagWTS_SESSION_INFO, $aResult[4] + $Offset) $Offset += DllStructGetSize($tInfo) $c += 1 $aReturn[$c][$e_SessionId] = DllStructGetData($tInfo, 'SessionId') $aReturn[$c][$e_SessionName] = DllStructGetData(DllStructCreate('wchar[1024]', DllStructGetData($tInfo, 'WinStationName')), 1) $aReturn[$c][$e_StateInt] = DllStructGetData($tInfo, 'State') If UBound($aConnectionState) > $aReturn[$c][$e_StateInt] Then $aReturn[$c][$e_StateName] = $aConnectionState[$aReturn[$c][$e_StateInt]] $aReturn[$c][$e_UserName] = _WTSQuerySessionInformation($aReturn[$c][$e_SessionId], 5) ; WTSUserName $aReturn[$c][$e_ClientName] = _WTSQuerySessionInformation($aReturn[$c][$e_SessionId], 10) ; WTSClientName $aReturn[$c][$e_ClientIp] = _WTSQuerySessionInformation($aReturn[$c][$e_SessionId], 14) ; WTSClientAddress $aReturn[$c][$e_Domain] = _WTSQuerySessionInformation($aReturn[$c][$e_SessionId], 7) ; WTSDomainName $aReturn[$c][$e_IdleTime] = _WTSQuerySessionInformation($aReturn[$c][$e_SessionId], 17) ; WTSIdleTime $aReturn[$c][$e_LogonTime] = _WTSQuerySessionInformation($aReturn[$c][$e_SessionId], 18) ; WTSLogonTime $aReturn[0][$e_IsSelf_SessionId] = $c If $_Self_SessionId = $aReturn[$c][$e_SessionId] Then $aReturn[$c][$e_IsSelf_SessionId] = 1 Else $aReturn[$c][$e_IsSelf_SessionId] = 0 EndIf Next DllCall('wtsapi32.dll', 'none', 'WTSFreeMemory', 'ptr', $aResult[4]) Return $aReturn EndFunc ;==>ListUserSessions
    1 point
×
×
  • Create New...