Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/31/2023 in all areas

  1. For those who prefer to see all the bits at work: ;~ Variable names ;~ $xyzt ;~ ||||______ M = mask V = variable part ;~ |||_______ S = surrogate ;~ ||________ H = high L = low C = codepoint ;~ |_________ i = int b = binary h = hex Local $iC = 0x1F50A ; codepoint ConsoleWrite(Hex($iC, 6) & @LF) Local $bC = _IntToString($iC, 2) $bC = StringRight(_StringRepeat("0", 32) & $bC, 32) ConsoleWrite($bC & @LF) ConsoleWrite("00000000000<---bHSV--><--bLSV-->" & @LF) ConsoleWrite(@LF) Local $iHSM = 0xD7C0 Local $bHSM = _IntToString($iHSM, 2) Local $hHSM = Hex(_StringToInt($bHSM, 2), 4) ConsoleWrite("high surrogate mask = " & $bHSM & " " & $hHSM & @LF) Local $bHSV = "00000" & StringMid($bC, 12, 11) Local $hHSV = Hex(_StringToInt($bHSV, 2), 4) ConsoleWrite("high surrogate variable part = " & $bHSV & " " & $hHSV & @LF) Local $iHS = $iHSM + _StringToInt($bHSV, 2) Local $hHS = Hex($iHS, 4) ConsoleWrite("high surrogate = " & _IntToString($iHS, 2) & " " & $hHS & @LF) ConsoleWrite(@LF) Local $iLSM = 0xDC00 Local $bLSM = _IntToString($iLSM, 2) Local $hLSM = Hex(_StringToInt($bLSM, 2), 4) ConsoleWrite("low surrogate mask = " & $bLSM & " " & $hLSM & @LF) Local $bLSV = "000000" & StringRight($bC, 10) Local $hLSV = Hex(_StringToInt($bLSV, 2), 4) ConsoleWrite("low surrogate variable part = " & $bLSV & " " & $hLSV & @LF) Local $iLS = $iLSM + _StringToInt($bLSV, 2) Local $hLS = Hex($iLS, 4) ConsoleWrite("low surrogate = " & _IntToString($iLS, 2) & " " & $hLS & @LF) Func _StringToInt($s, $base = 16) Return DllCall("msvcrt.dll", "int64:cdecl", "_wcstoi64", "wstr", $s, "ptr*", 0, "int", $base)[0] EndFunc ;==>_StringToInt Func _IntToString($i, $base = 16) Return DllCall("msvcrt.dll", "wstr:cdecl", "_i64tow", "int64", $i, "wstr", "", "int", $base)[0] EndFunc ;==>_IntToString
    2 points
  2. KaFu

    Put the DWG file image in a GUI

    Checked for that too while researching PNG extraction 😉. #include <Binary.au3> ; https://www.autoitscript.com/forum/topic/131037-binary-udf/?do=findComment&comment=1339527 _Extract_BMP(@ScriptDir & "\test.bmp") Func _Extract_BMP($sFile_Input, $sFile_Output = "") If Not $sFile_Output Then $sFile_Output = $sFile_Input & "_extracted.bmp" Local $hFile = FileOpen($sFile_Input, 16) If $hFile = -1 Then Return SetError(1) Local $bContent = FileRead($hFile) FileClose($hFile) Local $i_BMP_Position_Header = _BinaryInBin($bContent, Binary("0x424D")) Local $i_BMP_Total_Size = Int(BinaryMid($bContent, $i_BMP_Position_Header + 2, 4)) If $i_BMP_Position_Header And $i_BMP_Total_Size Then ConsoleWrite("+ BMP data found" & @CRLF) If FileExists($sFile_Output) Then ConsoleWrite("! Output file '" & $sFile_Output & "' existed, BMP extraction skipped " & @CRLF) Return SetError(2) EndIf $hFile = FileOpen($sFile_Output, 2 + 16) If $hFile = -1 Then Return SetError(3) FileWrite($hFile, BinaryMid($bContent, $i_BMP_Position_Header, $i_BMP_Total_Size)) FileClose($hFile) Return 1 EndIf ConsoleWrite("- No BMP data found" & @CRLF) Return 0 EndFunc ;==>_Extract_BMP Edit: And for JPG too while I'm at it. #include <Binary.au3> ; https://www.autoitscript.com/forum/topic/131037-binary-udf/?do=findComment&comment=1339527 _Extract_JPG(@ScriptDir & "\test.jpg") Func _Extract_JPG($sFile_Input, $sFile_Output = "") If Not $sFile_Output Then $sFile_Output = $sFile_Input & "_extracted.jpg" Local $hFile = FileOpen($sFile_Input, 16) If $hFile = -1 Then Return SetError(1) Local $bContent = FileRead($hFile) FileClose($hFile) Local $i_JPG_Position_Header = _BinaryInBin($bContent, Binary("0xFFD8")) If $i_JPG_Position_Header Then Local $i_JPG_Position_End = _BinaryInBin($bContent, Binary("0xFFD9")) If $i_JPG_Position_End And ($i_JPG_Position_Header < $i_JPG_Position_End) Then ConsoleWrite("+ JPG data found" & @CRLF) If FileExists($sFile_Output) Then ConsoleWrite("! Output file '" & $sFile_Output & "' existed, JPG extraction skipped " & @CRLF) Return SetError(2) EndIf $hFile = FileOpen($sFile_Output, 2 + 16) If $hFile = -1 Then Return SetError(3) FileWrite($hFile, BinaryMid($bContent, $i_JPG_Position_Header, $i_JPG_Position_End - $i_JPG_Position_Header + 2)) FileClose($hFile) Return 1 EndIf EndIf ConsoleWrite("- No JPG data found" & @CRLF) Return 0 EndFunc ;==>_Extract_JPG
    1 point
  3. funkey

    My OwnTab-Control

    I made my own tab-control! OwnTab-Gallery Example #include "OwnTab.au3" #cs Known Bugs: --> Bug mit $OwnTab_Style, da diese Variable zur Laufzeit abgefragt wird beim Verstecken und erneuten Anzeigen der Register. --> "Zittern" der alarmierten Register, wenn diese bereits angewählt wurden --> durch blinken mit der selben Farbe #ce Local $hGui = GUICreate("Funkey's OwnTab-UDF Example", 500, 350) GUISetBkColor(0xbbbbbb) $OwnTab_Style = Random(0, 1, 1) ;random style (only 2 styles available!!) Local $aTabText[5] = ["Settings", "Register without icon", "Pic", "Status", "Tab in Tab"] ;Declare the regions for the OwnTab-control Local $aTabIcons[5][2] = [["shell32.dll", 130],[""],["shell32.dll", 139],["shell32.dll", 90], ["shell32.dll", 43]] Global $aCtrlTab = _OwnTab_Create($hGui, $aTabText, 10, 10, 480, 300, 30, 0xD5D5D5, 0xCFE0E7, 0xCFE0E7, $aTabIcons) Local $aTabTip[5] = ["Tip Item 1", "Tip Item 2", "Tip Item 3", "Alarm-Register"] _OwnTab_SetTip($aCtrlTab, $aTabTip) ;set the tooltips for the OwnTab-control #Region Tab1 _OwnTab_Add($aCtrlTab) ;Start controls tab1 Global $Edit1 = GUICtrlCreateEdit("Edit in Tab1", 20, 55, 300, 50, 0) Global $Button1 = GUICtrlCreateButton("Simulate an alarm", 20, 120, 300, 20) Global $Box1 = GUICtrlCreateCheckbox("Switch on hover - set time -->", 20, 180) GUICtrlSetBkColor(-1, 0xCFE0E7) Global $Input1 = GUICtrlCreateInput("1", 200, 180, 50, 20) GUICtrlCreateUpdown($Input1) GUICtrlSetLimit(-1, 15, 1) #EndRegion Tab1 #Region Tab2 _OwnTab_Add($aCtrlTab) ;Start controls tab2 Global $Edit2 = GUICtrlCreateEdit("Edit in Tab2", 20, 150, 300, 50, 0) Global $Label2 = GUICtrlCreateLabel("Label in Tab2", 20, 220, 300, 20, 0x201) GUICtrlSetBkColor(-1, -2) ;$GUI_BKCOLOR_TRANSPARENT #EndRegion Tab2 #Region Tab3 _OwnTab_Add($aCtrlTab) ;Start controls tab3 Global $Labe3 = GUICtrlCreateLabel("If you see this label, you can change the picture-path in scriptline " &@ScriptLineNumber + 1 & "!!", 40, 150, 400, 30, 0x201) Global $Edit3 = GUICtrlCreatePic(@DocumentsCommonDir & '\Eigene Bilder\Beispielbilder\Winter.jpg', 20, 55, 460, 280) #EndRegion Tab3 #Region Tab4 _OwnTab_Add($aCtrlTab) ;Start controls tab4 Global $Button4 = GUICtrlCreateButton("Acknowledge the alarm", 20, 120, 300, 20) Global $Button5 = GUICtrlCreateButton("Enable tab 3", 20, 150, 300, 20) Global $Button6 = GUICtrlCreateButton("Disable tab 3", 20, 180, 300, 20) Global $Button7 = GUICtrlCreateButton("Hide tab 2", 20, 240, 300, 20) Global $Button8 = GUICtrlCreateButton("Show tab 2", 20, 210, 300, 20) #EndRegion Tab4 #Region Tab5 and "Tab in Tab" _OwnTab_Add($aCtrlTab) ;Start controls tab5 GUICtrlCreateLabel("Style Black", 30, 50, 200, 20, 0x201) $OwnTab_Style = 0 Local $aTabText[2] = ["Tab1", "New Info"] ;Declare the regions for the OwnTab-control Local $aTabIcons[2][2] = [["shell32.dll", 20],["shell32.dll", 40]] Global $aCtrlTab2 = _OwnTab_Create($hGui, $aTabText, 30, 80, 200, 200, 30, 0xD5D5D5, 0x00ff00, 0x00ff00, $aTabIcons) _OwnTab_Add($aCtrlTab2) ;Start controls tab1 Global $BtnSet = GUICtrlCreateButton("Simulate", 80, 150, 100, 20) _OwnTab_Add($aCtrlTab2) ;Start controls tab2 Global $BtnReset = GUICtrlCreateButton("Acknowledge", 80, 170, 100, 20) _OwnTab_End($aCtrlTab2) GUICtrlCreateLabel("Style White", 270, 50, 200, 20, 0x201) $OwnTab_Style = 1 Local $aTabText[2] = ["Tab1", "Tab2"] ;Declare the regions for the OwnTab-control Local $aTabIcons[2][2] = [["shell32.dll", 10],["shell32.dll", 60]] Global $aCtrlTab3 = _OwnTab_Create($hGui, $aTabText, 270, 80, 200, 200, 30, 0xD5D5D5, 0x00ff00, 0x00ff00, $aTabIcons) _OwnTab_Add($aCtrlTab3) ;Start controls tab1 GUICtrlCreateLabel("Just testing...", 280, 150, 100, 20) GUICtrlSetBkColor(-1, -2) _OwnTab_Add($aCtrlTab3) ;Start controls tab2 GUICtrlCreateLabel("Hello from tab2", 280, 150, 100, 20) GUICtrlSetBkColor(-1, -2) _OwnTab_End($aCtrlTab3) #EndRegion Tab5 _OwnTab_End($aCtrlTab) ;new: end control-definition AND inizialize the OwnTab _OwnTab_Disable($aCtrlTab, 3) ;new: disable tabitems _OwnTab_SetFontCol($aCtrlTab, 0xFF) ;new: set font-color GUISetState() _OwnTab_Hover($aCtrlTab, 0xFFFF88) ;start hover-function if you want _OwnTab_AlarmInit() Local $msg While 1 $msg = GUIGetMsg() For $a = 1 To UBound($aCtrlTab, 1) - 1 If $msg = $aCtrlTab[$a][0] Then _OwnTab_Switch($aCtrlTab, $a) If $a = 5 Then _OwnTab_Switch($aCtrlTab2, $aCtrlTab2[0][0], 1) _OwnTab_Switch($aCtrlTab3, $aCtrlTab3[0][0], 1) EndIf EndIf Next For $a = 1 To UBound($aCtrlTab2, 1) - 1 If $msg = $aCtrlTab2[$a][0] Then _OwnTab_Switch($aCtrlTab2, $a) EndIf Next For $a = 1 To UBound($aCtrlTab3, 1) - 1 If $msg = $aCtrlTab3[$a][0] Then _OwnTab_Switch($aCtrlTab3, $a) EndIf Next Switch $msg Case $Button1 _OwnTab_SetAlarm($aCtrlTab, 4, 0xFF0000) Case $Button4 _OwnTab_ResetAlarm($aCtrlTab, 4) Case $BtnSet _OwnTab_SetAlarm($aCtrlTab2, 2, 0x5050FF) Case $BtnReset _OwnTab_ResetAlarm($aCtrlTab2, 2) Case $Button5 _OwnTab_Enable($aCtrlTab, 3) Case $Button6 _OwnTab_Disable($aCtrlTab, 3) Case $Button7 _OwnTab_Hide($aCtrlTab, 2) Case $Button8 _OwnTab_Show($aCtrlTab, 2) Case $Box1 If GUICtrlRead($Box1) = 1 Then _OwnTab_Hover($aCtrlTab, 0xFFFF88, GUICtrlRead($Input1)) Else _OwnTab_Hover($aCtrlTab, 0xFFFF88, 0) EndIf Case $Input1 If GUICtrlRead($Box1) = 1 Then _OwnTab_Hover($aCtrlTab, 0xFFFF88, GUICtrlRead($Input1)) Case -3 Exit EndSwitch Sleep(10) WEnd OwnTab-UDF #include-once #include <GDIPlus.au3> #include <Array.au3> #include <Constants.au3> #include <WindowsConstants.au3> #Include <Timers.au3> #cs Copyrights to funkey from Autoit.de #ce Local $HoverArray[1], $ControlID, $Global_I = 0, $__ControlID, $HoverActive = 0, $Temp_Found = 0, $szTemp_Array[2] Local $OwnTabHoverCol[2], $OwnTabHoverHelp[1], $OwnTabHoverSwitch, $aOwnTabHoverCount, $OwnTabHoverCtrl Local $aOwnTabAlarm[1][3], $iOwnTabAlarm, $hOwnTabGui, $hTimerAlarm, $hTimerHover Local $OwnTab_Style = 0 ; only 0 or 1 ! _GDIPlus_Startup() OnAutoItExitRegister("_OwnTab_OnExit") Func _OwnTab_Create($hWnd, $aTabText, $xPos, $yPos, $iWidth, $iHeight, $iItemHeight = -1, $nColNoSel = -1, $nColSel = -1, $nColBg = -1, $aIcons = "") Local $aSize, $aSize2[UBound($aTabText)][2], $xLast = 0, $aCtrl[UBound($aTabText) + 1][11], $iOffset = 0 If Not IsArray($aIcons) Then Local $Icons[UBound($aTabText)][2] Else Local $Icons = $aIcons EndIf If Not IsArray($aTabText) Then Return SetError(1, 0, "") For $i = 0 To UBound($aTabText) - 1 If $aTabText[$i] = "" Then Return SetError(2, $i + 1, "") $aSize = _GetTextSize($aTabText[$i]) $aSize[0] += Ceiling($aSize[0] / 10) ;make it 10% longer for bold text $aSize2[$i][0] = $aSize[0] $aSize2[$i][1] = $aSize[1] If $iItemHeight = -1 Then $iItemHeight = $aSize[1] If $Icons[$i][0] <> "" Then $iOffset = $iItemHeight $aTabText[$i] &= " " Else $iOffset = 0 EndIf $aCtrl[$i + 1][7] = $Icons[$i][0] ;filename for icon $aCtrl[$i + 1][8] = $Icons[$i][1] ;index for icon $aCtrl[$i + 1][9] = $aSize[0] + 5 + $iOffset ;labelwidth $aCtrl[$i + 1][0] = GUICtrlCreateLabel($aTabText[$i], $xPos + $xLast + 5, $yPos + 2, $aCtrl[$i + 1][9], $iItemHeight, 0x411201 + ($Icons[$i][0] <> ""), $OwnTab_Style) _HoverAddCtrl($aCtrl[$i + 1][0]) If $Icons[$i][0] <> "" Then $aCtrl[$i + 1][6] = GUICtrlCreateIcon("", 0, $xPos + $xLast + 8, $yPos + 5, $iItemHeight - 6, $iItemHeight - 6) Else $aCtrl[$i + 1][6] = GUICtrlCreateDummy() EndIf ;~ If $Icons[$i][0] <> "" Then _SetBkIcon($aCtrl[$i + 1][6], $nColNoSel, $aCtrl[$i + 1][7], $aCtrl[$i + 1][8], $iItemHeight - 6, $iItemHeight - 6) GUICtrlCreateLabel($aCtrl[$i + 1][7], -200, -200) ;For information GUICtrlCreateLabel($aCtrl[$i + 1][8], -200, -200) ;For information GUICtrlCreateLabel($iItemHeight - 6, -200, -200) ;For information $aCtrl[$i + 1][2] = $nColNoSel $aCtrl[$i + 1][3] = $nColSel $xLast += $aCtrl[$i + 1][9] Next GUICtrlCreateLabel("", $xPos, $yPos + $iItemHeight, $iWidth, $iHeight, 0x411000, $OwnTab_Style) GUICtrlSetState(-1, 128) ;$GUI_DISABLE GUICtrlSetBkColor(-1, $nColBg) $xLast = 0 For $i = 0 To UBound($aTabText) - 1 If $Icons[$i][0] <> "" Then $iOffset = $iItemHeight Else $iOffset = 0 EndIf $aCtrl[$i + 1][1] = GUICtrlCreateLabel("", $xPos + $xLast + 6, $yPos + $iItemHeight - $OwnTab_Style, $aSize2[$i][0] + 3 + $iOffset, 2+2*$OwnTab_Style) GUICtrlSetBkColor(-1, $nColSel) $xLast += $aSize2[$i][0] + 5 + $iOffset Next $aCtrl[0][1] = $iItemHeight $aCtrl[0][2] = $nColNoSel $aCtrl[0][3] = $nColSel $aCtrl[0][9] = $yPos + 2 $hOwnTabGui = $hWnd Return $aCtrl EndFunc ;==>_OwnTab_Create Func _OwnTab_Switch(ByRef $aOwnTab, $iIndex, $fForce = 0) _OwnTab_UnRegisterHover($aOwnTab, $iIndex) If _OwnTab_IsAlarmed($aOwnTab[$iIndex][0]) Then $aOwnTabAlarm[@extended][2] = $aOwnTabAlarm[@extended][1] $HoverActive = 0 If $aOwnTab[0][0] = $iIndex And $fForce = 0 Then Return For $s = 1 To UBound($aOwnTab, 1) - 1 If $iIndex <> $s Then GUICtrlSetState($aOwnTab[$s][1], 32) ;$GUI_HIDE GUICtrlSetFont($aOwnTab[$s][0], -1, 400) If Not _OwnTab_IsAlarmed($aOwnTab[$s][0]) Then GUICtrlSetBkColor($aOwnTab[$s][0], $aOwnTab[$s][2]) If $aOwnTab[$s][7] <> "" Then _SetBkIcon($aOwnTab[$s][6], $aOwnTab[$s][2], $aOwnTab[$s][7], $aOwnTab[$s][8], GUICtrlRead($aOwnTab[$s][0] + 4), GUICtrlRead($aOwnTab[$s][0] + 4)) EndIf If _ArraySearch($OwnTabHoverHelp, $aOwnTab[$s][0]) = -1 Then _OwnTab_RegisterHover($aOwnTab, $s) EndIf Else GUICtrlSetFont($aOwnTab[$iIndex][0], -1, 1000) If Not _OwnTab_IsAlarmed($aOwnTab[$s][0]) Then GUICtrlSetBkColor($aOwnTab[$iIndex][0], $aOwnTab[$iIndex][3]) If $aOwnTab[$s][7] <> "" Then _SetBkIcon($aOwnTab[$iIndex][6], $aOwnTab[$iIndex][3], $aOwnTab[$s][7], $aOwnTab[$s][8], GUICtrlRead($aOwnTab[$s][0] + 4), GUICtrlRead($aOwnTab[$s][0] + 4)) EndIf GUICtrlSetState($aOwnTab[$iIndex][1], 16) ;$GUI_SHOW EndIf Next If $aOwnTab[0][0] = "" Or $fForce Then For $t = $aOwnTab[0][4] To $aOwnTab[UBound($aOwnTab, 1) - 1][4] GUICtrlSetState($t, 32) ;$GUI_HIDE If $t > $aOwnTab[$iIndex - 1][4] And $t < $aOwnTab[$iIndex][4] Then GUICtrlSetState($t, 16) ;$GUI_SHOW Next Else For $t = $aOwnTab[$aOwnTab[0][0] - 1][4] To $aOwnTab[$aOwnTab[0][0]][4] GUICtrlSetState($t, 32) ;$GUI_HIDE Next For $t = $aOwnTab[$iIndex - 1][4] To $aOwnTab[$iIndex][4] GUICtrlSetState($t, 16) ;$GUI_SHOW Next EndIf $aOwnTab[0][0] = $iIndex EndFunc ;==>_OwnTab_Switch Func _OwnTab_SetTip(ByRef $aOwnTab, $ToolTips = "", $iIndex = "") If IsArray($ToolTips) Then For $i = 1 To UBound($aOwnTab, 1) - 1 $aOwnTab[$i][5] = $ToolTips[$i - 1] GUICtrlSetTip($aOwnTab[$i][0], $ToolTips[$i - 1]) Next Else If $iIndex = "" Then Return SetError(1) $aOwnTab[$iIndex][5] = $ToolTips GUICtrlSetTip($aOwnTab[$iIndex][0], $ToolTips) EndIf EndFunc ;==>_OwnTab_SetTip Func _OwnTab_AlarmInit($iTime = 555) If Not $hTimerAlarm Then $hTimerAlarm = _Timer_SetTimer($hOwnTabGui, $iTime, "_OwnTab_AlarmBlink") Else $hTimerAlarm = _Timer_SetTimer($hOwnTabGui, $iTime, "", $hTimerAlarm) EndIf EndFunc ;==>_OwnTab_AlarmInit Func _OwnTab_AlarmBlink($hWnd, $Msg, $iIDTimer, $dwTime) Local $AlarmColAct $iOwnTabAlarm = Not $iOwnTabAlarm For $i = 1 To UBound($aOwnTabAlarm, 1) - 1 If $iOwnTabAlarm Then $AlarmColAct = $aOwnTabAlarm[$i][2] Else $AlarmColAct = $aOwnTabAlarm[$i][1] EndIf GUICtrlSetBkColor($aOwnTabAlarm[$i][0], $AlarmColAct) _SetBkIcon($aOwnTabAlarm[$i][0] + 1, $AlarmColAct, GUICtrlRead($aOwnTabAlarm[$i][0] + 2), GUICtrlRead($aOwnTabAlarm[$i][0] + 3), GUICtrlRead($aOwnTabAlarm[$i][0] + 4), GUICtrlRead($aOwnTabAlarm[$i][0] + 4)) Next EndFunc ;==>_OwnTab_AlarmBlink Func _OwnTab_SetAlarm(ByRef $aOwnTab, $iIndex, $nAlarmSel = 0xFF0000) Local $hCtrl = $aOwnTab[$iIndex][0] Local $iSearch = _ArraySearch($aOwnTabAlarm, $hCtrl) If $iSearch <> -1 Then Return ReDim $aOwnTabAlarm[UBound($aOwnTabAlarm, 1) + 1][3] $aOwnTabAlarm[UBound($aOwnTabAlarm, 1) - 1][0] = $hCtrl $aOwnTabAlarm[UBound($aOwnTabAlarm, 1) - 1][1] = $nAlarmSel $aOwnTabAlarm[UBound($aOwnTabAlarm, 1) - 1][2] = $aOwnTab[$iIndex][2] ;~ GUICtrlSetBkColor($aOwnTab[$iIndex][1], $nAlarmSel) EndFunc ;==>_OwnTab_SetAlarm Func _OwnTab_ResetAlarm(ByRef $aOwnTab, $iIndex) Local $hCtrl = $aOwnTab[$iIndex][0] Local $iSearch = _ArraySearch($aOwnTabAlarm, $hCtrl) If $iSearch = -1 Then Return _ArrayDelete($aOwnTabAlarm, $iSearch) $aOwnTab[$iIndex][2] = $aOwnTab[0][2] $aOwnTab[$iIndex][3] = $aOwnTab[0][3] ;~ GUICtrlSetBkColor($aOwnTab[$iIndex][1], $aOwnTab[0][3]) If $aOwnTab[0][0] <> $iIndex Then GUICtrlSetBkColor($aOwnTab[$iIndex][0], $aOwnTab[0][2]) Else _SetBkIcon($aOwnTab[$iIndex][0] + 1, $aOwnTab[$iIndex][3], $aOwnTab[$iIndex][7], $aOwnTab[$iIndex][8], GUICtrlRead($aOwnTab[$iIndex][0] + 4), GUICtrlRead($aOwnTab[$iIndex][0] + 4)) GUICtrlSetBkColor($aOwnTab[$iIndex][0], $aOwnTab[0][3]) EndIf EndFunc ;==>_OwnTab_ResetAlarm Func _OwnTab_Add(ByRef $aOwnTab) Local $i = 0 While 1 If $aOwnTab[$i][4] = "" Then ExitLoop $i += 1 WEnd $aOwnTab[$i][4] = GUICtrlCreateDummy() EndFunc ;==>_OwnTab_Add Func _OwnTab_End(ByRef $aOwnTab, $iIndex = 1) $aOwnTab[UBound($aOwnTab, 1) - 1][4] = GUICtrlCreateDummy() _OwnTab_Switch($aOwnTab, $iIndex) EndFunc ;==>_OwnTab_End Func _OwnTab_Hover($aOwnTab, $nColHover, $fSwitch = 0, $iTime = 50) $OwnTabHoverCol[0] = $nColHover $OwnTabHoverCol[1] = $aOwnTab[0][2] $OwnTabHoverSwitch = $fSwitch If Not $hTimerHover Then $hTimerHover = _Timer_SetTimer($hOwnTabGui, $iTime, "_ProcessHover") Else $hTimerHover = _Timer_SetTimer($hOwnTabGui, $iTime, "", $hTimerHover) EndIf EndFunc ;==>_OwnTab_Hover Func _OwnTab_RegisterHover($aOwnTab, $iIndex) If _ArraySearch($HoverArray, $aOwnTab[$iIndex][0]) = -1 Then _HoverAddCtrl($aOwnTab[$iIndex][0]) EndFunc ;==>_OwnTab_RegisterHover Func _OwnTab_UnRegisterHover($aOwnTab, $iIndex) Local $iSearch = _ArraySearch($HoverArray, $aOwnTab[$iIndex][0]) If $iSearch <> -1 Then _ArrayDelete($HoverArray, $iSearch) EndFunc ;==>_OwnTab_UnRegisterHover #Region Disable and Enable Tab-Register Func _OwnTab_Disable($aOwnTab, $iIndex) GUICtrlSetState($aOwnTab[$iIndex][0], 128) _OwnTab_UnRegisterHover($aOwnTab, $iIndex) Local $iSearch = _ArraySearch($OwnTabHoverHelp, $aOwnTab[$iIndex][0]) If $iSearch = -1 Then _ArrayAdd($OwnTabHoverHelp, $aOwnTab[$iIndex][0]) EndFunc ;==>_OwnTab_Disable Func _OwnTab_Enable($aOwnTab, $iIndex) GUICtrlSetState($aOwnTab[$iIndex][0], 64) _OwnTab_RegisterHover($aOwnTab, $iIndex) Local $iSearch = _ArraySearch($OwnTabHoverHelp, $aOwnTab[$iIndex][0]) If $iSearch <> -1 Then _ArrayDelete($OwnTabHoverHelp, $iSearch) EndFunc ;==>_OwnTab_Enable #EndRegion Disable and Enable Tab-Register Func _OwnTab_Hide(ByRef $aOwnTab, $iIndex) If $iIndex = 0 Or $iIndex > UBound($aOwnTab, 1) - 1 Then Return SetError(1) If BitAND(GUICtrlGetState($aOwnTab[$iIndex][0]), 32) Then Return GUICtrlSetState($aOwnTab[$iIndex][0], 32) ;$GUI_HIDE GUICtrlSetState($aOwnTab[$iIndex][1], 32) ;$GUI_HIDE GUICtrlSetState($aOwnTab[$iIndex][6], 32) ;$GUI_HIDE Local $Offset = 3 For $o = 0 To $iIndex - 1 $Offset += $aOwnTab[$o][9] - 0 Next For $o = $iIndex + 1 To UBound($aOwnTab, 1) - 1 GUICtrlSetPos($aOwnTab[$o][0], $Offset, $aOwnTab[0][9]) GUICtrlSetPos($aOwnTab[$o][1], $Offset + 1, $aOwnTab[0][9] + $aOwnTab[0][1] - 2 - $OwnTab_Style) GUICtrlSetPos($aOwnTab[$o][6], $Offset + 3, $aOwnTab[0][9] + 3) $Offset += $aOwnTab[$o][9] Next If $iIndex = $aOwnTab[0][0] Then If $iIndex = 1 Then _OwnTab_Switch($aOwnTab, 2) Else _OwnTab_Switch($aOwnTab, $iIndex - 1) EndIf EndIf EndFunc ;==>_OwnTab_Hide Func _OwnTab_Show(ByRef $aOwnTab, $iIndex, $iActivate = 0) If $iIndex = 0 Or $iIndex > UBound($aOwnTab, 1) + 1 Then Return SetError(1) If BitAND(GUICtrlGetState($aOwnTab[$iIndex][0]), 16) Then Return Local $Offset = 3 For $o = 0 To UBound($aOwnTab, 1) - 2 $Offset += $aOwnTab[$o][9] - 0 Next For $o = UBound($aOwnTab, 1) - 1 To $iIndex + 1 Step -1 GUICtrlSetPos($aOwnTab[$o][0], $Offset, $aOwnTab[0][9]) GUICtrlSetPos($aOwnTab[$o][1], $Offset + 1, $aOwnTab[0][9] + $aOwnTab[0][1] - 2 - $OwnTab_Style) GUICtrlSetPos($aOwnTab[$o][6], $Offset + 3, $aOwnTab[0][9] + 3) $Offset -= $aOwnTab[$o - 1][9] Next GUICtrlSetState($aOwnTab[$iIndex][0], 16) ;$GUI_SHOW GUICtrlSetState($aOwnTab[$iIndex][6], 16) ;$GUI_SHOW If $iActivate Then _OwnTab_Switch($aOwnTab, $iIndex) EndIf EndFunc ;==>_OwnTab_Show Func _OwnTab_SetFontCol($aOwnTab, $nColor, $iIndex = "") If $iIndex = "" Then For $i = 1 To UBound($aOwnTab, 1) - 1 GUICtrlSetColor($aOwnTab[$i][0], $nColor) Next Else If $iIndex < 1 Or $iIndex >= UBound($aOwnTab, 1) Then Return SetError(1) GUICtrlSetColor($aOwnTab[$iIndex][0], $nColor) EndIf EndFunc ;==>_OwnTab_SetFontCol Func _OwnTab_SetOnEvent($aOwnTab, $sFunc = "", $iIndex = "") If $sFunc = "" Then $sFunc = "_OwnTab_OnEvent" If $iIndex = "" Then For $f = 1 To UBound($aOwnTab, 1) -1 GUICtrlSetOnEvent($aOwnTab[$f][0], $sFunc) Next Else If $iIndex < 1 Or $iIndex >= UBound($aOwnTab, 1) Then Return SetError(1) GUICtrlSetOnEvent($aOwnTab[$iIndex][0], $sFunc) EndIf EndFunc ;~ Func _OwnTab_OnEvent() ;for example ;~ For $a = 1 To UBound($aCtrlTab, 1) -1 ;~ If @GUI_CtrlId = $aCtrlTab[$a][0] Then ExitLoop ;~ Next ;~ If $a < UBound($aCtrlTab, 1) Then _OwnTab_Switch($aCtrlTab, $a) ;~ EndFunc Func _OwnTab_OnExit() _GDIPlus_Shutdown() If $hTimerAlarm Then _Timer_KillTimer($hOwnTabGui, $hTimerAlarm) If $hTimerHover Then _Timer_KillTimer($hOwnTabGui, $hTimerHover) EndFunc ;==>_OwnTab_Exit Func _GetTextSize($nText, $sFont = 'Microsoft Sans Serif', $iFontSize = 8.5, $iFontAttributes = 0) ;Author: Bugfix ;Modified: funkey If $nText = '' Then Return Local $hGui = GUICreate("Textmeter by Bugfix") ;~ _GDIPlus_Startup() Local $hFormat = _GDIPlus_StringFormatCreate(0) Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, $iFontAttributes, 3) Local $tLayout = _GDIPlus_RectFCreate(15, 171, 0, 0) Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $nText, $hFont, $tLayout, $hFormat) Local $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width")) Local $iHeight = Ceiling(DllStructGetData($aInfo[0], "Height")) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_GraphicsDispose($hGraphic) ;~ _GDIPlus_Shutdown() GUIDelete($hGui) Local $aSize[2] = [$iWidth, $iHeight] Return $aSize EndFunc ;==>_GetTextSize Func _ProcessHover($hWnd, $Msg, $iIDTimer, $dwTime) If $OwnTabHoverSwitch > 1 And $OwnTabHoverCtrl <> "" Then If $aOwnTabHoverCount < $OwnTabHoverSwitch Then $aOwnTabHoverCount += 1 If $aOwnTabHoverCount >= $OwnTabHoverSwitch Then ControlClick($hOwnTabGui, "", $OwnTabHoverCtrl) $aOwnTabHoverCount = 0 $OwnTabHoverCtrl = "" EndIf EndIf $ControlID = _HoverCheck() If IsArray($ControlID) Then If $ControlID[0] = "AcquiredHover" Then $OwnTabHoverCtrl = $ControlID[1] $aOwnTabHoverCount = 0 If $OwnTabHoverSwitch = "1" Then Return ControlClick($hOwnTabGui, "", $OwnTabHoverCtrl) Else _HoverFound($ControlID[1]) EndIf Else If $ControlID[1] <> "" Then _HoverLost($ControlID[1]) $OwnTabHoverCtrl = "" EndIf EndIf EndIf EndFunc ;==>_ProcessHover Func _HoverLost($ControlID) If _OwnTab_IsAlarmed($ControlID) Then Return GUICtrlSetBkColor($ControlID, $OwnTabHoverCol[1]) If GUICtrlRead($ControlID + 2) <> "" Then _SetBkIcon($ControlID + 1, $OwnTabHoverCol[1], GUICtrlRead($ControlID + 2), GUICtrlRead($ControlID + 3), GUICtrlRead($ControlID + 4), GUICtrlRead($ControlID + 4)) EndFunc ;==>_HoverLost Func _HoverFound($ControlID) If _OwnTab_IsAlarmed($ControlID) Then Return GUICtrlSetBkColor($ControlID, $OwnTabHoverCol[0]) If GUICtrlRead($ControlID + 2) <> "" Then _SetBkIcon($ControlID + 1, $OwnTabHoverCol[0], GUICtrlRead($ControlID + 2), GUICtrlRead($ControlID + 3), GUICtrlRead($ControlID + 4), GUICtrlRead($ControlID + 4)) EndFunc ;==>_HoverFound Func _OwnTab_IsAlarmed($hCtrl) Local $iSearch = _ArraySearch($aOwnTabAlarm, $hCtrl) If $iSearch = -1 Then Return 0 Return SetExtended($iSearch, 1) EndFunc #Region _MouseHover.au3 ;==================================================================================================================================== ; UDF Name: _MouseHover.au3 ; ; Author: marfdaman (Marvin) ; ; Contributions: RazerM (adding SetText parameter to _HoverFound and _HoverUndo). ; ; email: marfdaman at gmail dot com ; ; Use: Enable hover events for controls ; ; Note(s): If you want to use this i.c.w. an AdlibEnable in your current script, make your Adlib call "_HoverCheck()" as well. ; In this case, _HoverOn must NOT be called. ;==================================================================================================================================== ;=============================================================================== ; Description: _HoverAddCtrl ; Parameter(s): $___ControlID -> Control ID of control to be hoverchecked ; ; Requirement: Array.au3 ; Return Value(s): None ;=============================================================================== Func _HoverAddCtrl($___ControlID) _ArrayAdd($HoverArray, $___ControlID) EndFunc ;==>_HoverAddCtrl ;=============================================================================== ; Description: Checks whether the mousecursor is hovering over any of the defined controls. ; Parameter(s): None ; Requirement: None ; Return Value(s): If a control has matched, an array will be returned, with $array[1] being either ; "AcquiredHover" or "LostHover". $array[2] will contain the control ID. ; It is recommended that you put this function in an AdlibEnable, since it's EXTREMELY ; resource friendly. ;=============================================================================== Func _HoverCheck() $HoverData = GUIGetCursorInfo() If Not IsArray($HoverData) Then Return $Temp_Found = 0 For $i = 1 To UBound($HoverArray) - 1 If $HoverData[4] = $HoverArray[$i] Or $HoverData[4] = $HoverArray[$i] + 1 Then $Temp_Found = $i EndIf Next Select Case $Temp_Found = 0 And $HoverActive = 1 Or $Temp_Found <> 0 And $Temp_Found <> $Global_I And $HoverActive = 1 $HoverActive = 0 $Temp_Found = 0 $szTemp_Array[0] = "LostHover" $szTemp_Array[1] = $HoverArray[$Global_I] Return $szTemp_Array Case $Temp_Found > 0 And $HoverActive = 0 $Global_I = $Temp_Found $HoverActive = 1 $Temp_Found = 0 $szTemp_Array[0] = "AcquiredHover" $szTemp_Array[1] = $HoverArray[$Global_I] Return $szTemp_Array EndSelect EndFunc ;==>_HoverCheck #EndRegion _MouseHover.au3 Func _SetBkIcon($ControlID, $iBackground, $sIcon, $iIndex, $iWidth, $iHeight) ;Yashied ;http://www.autoitscript.com/forum/index.php?showtopic=92207&view=findpost&p=662886 Const $STM_SETIMAGE = 0x0172 Local $tIcon, $tID, $hDC, $hBackDC, $hBackSv, $hBitmap, $hImage, $hIcon, $hBkIcon $tIcon = DllStructCreate('hwnd') $tID = DllStructCreate('hwnd') $hIcon = DllCall('user32.dll', 'int', 'PrivateExtractIcons', 'str', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr', DllStructGetPtr($tIcon), 'ptr', DllStructGetPtr($tID), 'int', 1, 'int', 0) If (@error) Or ($hIcon[0] = 0) Then Return SetError(1, 0, 0) EndIf $hIcon = DllStructGetData($tIcon, 1) $tIcon = 0 $tID = 0 $hDC = _WinAPI_GetDC(0) $hBackDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateSolidBitmap(0, $iBackground, $iWidth, $iHeight) $hBackSv = _WinAPI_SelectObject($hBackDC, $hBitmap) _WinAPI_DrawIconEx($hBackDC, 0, 0, $hIcon, 0, 0, 0, 0, $DI_NORMAL) ;~ _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $hBkIcon = DllCall($__g_hGDIPDll, 'int', 'GdipCreateHICONFromBitmap', 'hWnd', $hImage, 'int*', 0) $hBkIcon = $hBkIcon[2] _GDIPlus_ImageDispose($hImage) GUICtrlSendMsg($ControlID, $STM_SETIMAGE, $IMAGE_ICON, _WinAPI_CopyIcon($hBkIcon)) _WinAPI_RedrawWindow(GUICtrlGetHandle($ControlID)) ;~ _GDIPlus_Shutdown() _WinAPI_SelectObject($hBackDC, $hBackSv) _WinAPI_DeleteDC($hBackDC) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_DeleteObject($hBkIcon) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hIcon) Return SetError(0, 0, 1) EndFunc ;==>_SetBkIcon Have fun! Edit: Fixed a problem with the hover-function Edit2: New version with Icon-support and hover-switch Edit3: 2009 New improved version!! Edit4: 2021 Updated UDF to work with actual version of AutoIt. (Thanks for downloading and using this script over 1350 times) OwnTab.au3 OwnTab_Example.au3
    1 point
  4. Yes, this way it's working.
    1 point
  5. In my office I have 3 monitors horizontally next to each other. The DPI for this: 100%, 125% and 150%. The main screen is in the middle (125%). HiDpi v. 0.2023.7.29(a) stable looks ok. The dev. version HiDpi v. 0.2023.7.30(a):
    1 point
  6. Trong

    AutoIt Snippets

    The replacement function for DirMove() Func _DirMove($SourceDir, $DestDir, $flag = 0) Local $Show_Debug = 1, $SourceDir_Exists = FileExists($SourceDir) If $Show_Debug Then ConsoleWrite("> Move folder '" & $SourceDir & "' [To> '" & $DestDir & "'" & @CRLF) If ($SourceDir_Exists < 1) Then If $Show_Debug Then ConsoleWrite("! ERROR - The source directory does not exist at: " & $SourceDir & @CRLF) Return SetError(1, -1, 0) EndIf Local $file_Move = '', $file_Moved = 0, $Move_Error = 0 $SourceDir = StringReplace($SourceDir, "/", '\') $DestDir = StringReplace($DestDir, "/", '\') If StringRight($SourceDir, 1) == '\' Then $SourceDir = StringTrimRight($SourceDir, 1) If StringRight($DestDir, 1) == '\' Then $DestDir = StringTrimRight($DestDir, 1) If Not FileExists($DestDir) Then If $Show_Debug Then ConsoleWrite("> Found folder: " & $SourceDir & @CRLF) If $Show_Debug Then ConsoleWrite("> Moving to: " & $DestDir & " (with Flag=" & $flag & ")" & @CRLF) DirCopy($SourceDir, $DestDir, $flag) Else If $Show_Debug Then ConsoleWrite("- Getting a list of files... " & @CRLF) Local $aFileList = _FileListToArrayRec($SourceDir & "\", "*", 1, 1, 1, 1) If (@error < 1) And IsArray($aFileList) Then If $Show_Debug Then ConsoleWrite("> Found files in: " & $SourceDir & @CRLF) If $Show_Debug Then ConsoleWrite("> Moving to: " & $DestDir & " (with Flag=" & $flag & ")" & @CRLF) For $I = 1 To $aFileList[0] $file_Move = $SourceDir & "\" & $aFileList[$I] $SourceDir_Exists = FileExists($file_Move) $file_Moved = FileMove($file_Move, $DestDir & "\" & $aFileList[$I], $flag < 1 ? 0 : 1 + 8) $Move_Error = @error If $Show_Debug Then ConsoleWrite("- Move file: " & $file_Move & " [" & $SourceDir_Exists & "] To> " & $DestDir & "\" & $aFileList[$I] & " [" & FileExists($DestDir & "\" & $aFileList[$I]) & "] > [Moved:" & $file_Moved & "-E:" & $Move_Error & "] " & (FileExists($file_Move) ? "Error" : "OK") & @CRLF) $file_Move = '' $SourceDir_Exists = 0 $file_Moved = 0 Next Else If $Show_Debug Then ConsoleWrite("! No files found at: " & $SourceDir & @CRLF) EndIf EndIf If $Show_Debug Then If FileExists($DestDir) Then ConsoleWrite("> Copied " & $SourceDir & " [To> " & $DestDir & @CRLF) EndIf If $Show_Debug Then ConsoleWrite("- Removing the source folder: " & $SourceDir & @CRLF) If FileExists($SourceDir) Then DirRemove($SourceDir, $flag) If FileExists($SourceDir) Then FileSetAttrib($SourceDir, "-RASH", $flag) DirRemove($SourceDir) If FileExists($SourceDir) And $flag Then RunWait(@ComSpec & ' /c takeown /f "' & $SourceDir & '" /r /d y', '', @SW_HIDE) RunWait(@ComSpec & ' /c Echo y|icacls "' & $SourceDir & '" /grant EveryOne:F /t /q', '', @SW_HIDE) RunWait(@ComSpec & ' /c RD /s /q "' & $SourceDir & '"', '', @SW_HIDE) DirRemove($SourceDir) EndIf EndIf EndIf If FileExists($SourceDir) Then If $Show_Debug Then ConsoleWrite("! FAILURE ! Folder " & $SourceDir & " has not been moved to: " & $DestDir & @CRLF) Return SetError(1, 0, 0) Else If $Show_Debug Then ConsoleWrite("+ SUCCESS ! Folder " & $SourceDir & " has been moved to: " & $DestDir & @CRLF) Return SetError(0, 0, 1) EndIf EndFunc ;==>_DirMove
    1 point
  7. ioa747, You might find this old thread interesting: That was my attempt at counting in French - I will have a go at a Spanish version this week when I find time. M23
    1 point
  8. ioa747

    GrepWinEditor

    GrepWin CmdLine Editor to SciTE for those who don't know ! grepWin is a powerful and fast search tool using regular expressions I use it Regularly, so I said to order in AutoIt services more info: https://github.com/stefankueng/grepWin Script does Two Jobs case 1 : Act as editor for grepWin to start SciTE at a specific line in this case for it to work we have to go to the grepWin settings and in the section Editor in Command line to start an editor at a specific line: and give the follow "PathToAutoIt3.exe" "PathToThisScript.au3" |%path%|%line% where "PathToAutoIt3.exe" = the path to AutoIt3.exe "PathToThisScript.au3" = the path of this script |%path%|%line% = as it is main_setting: "C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "D:\i\Pro\.AutoIT\SciTE_PlusBar\SciTE\CMD\GrepWinEditor.au3" |%path%|%line% and check the Only one instance CheckBox case 2 : Get the selected txt from SciTE and set as /searchfor: parameter to grepWin a dialog window opens to choose position / setting to search for which is dynamically updated from GrepWinEditor.ini The searchini , an ini file which contains all the values usually passed on the command line - /searchini:"path/to/inifile" [@ScriptDir], [1 Up], [2 Up] section do not change them, they update dynamically every time [@ScriptDir] = @ScriptDir [1 Up] = @ScriptDir & "\..\" [2 Up] = @ScriptDir & "\..\..\" [Default] = The Default setting if no parameter - do not change the Name the rest act as examples and they can change If you want for example after choose the @ScriptDir button to the search started immediately, without having to click the search button first put in the GrepWinEditor.ini in section [@ScriptDir] the entry execute= Command line parameters for grepWin Tested with grepWin-2.0.13_portable -x86 ; https://www.autoitscript.com/forum/topic/210301-grepwineditor/ ;------------------------------------------------------------------------------ ; Title...........: GrepWinEditor.au3 ; Description.....: GrepWin CmdLine Editor to SciTE ;------------------------------------------------------------------------------ #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\ICO\GrepWinEditor.ico #AutoIt3Wrapper_Res_Comment=GrepWin_CmdLine_Editor_Setting: "PathToAutoIt3.exe" "PathToThisScript.au3" |%path%|%line% #AutoIt3Wrapper_Res_Description=GrepWin CmdLine Editor to SciTE #AutoIt3Wrapper_Res_Fileversion=0.0.0.9 #AutoIt3Wrapper_Res_ProductName=GrepWinEditor.au3 #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> #include <ButtonConstants.au3> #include <SendMessage.au3> #include <File.au3> #include <Array.au3> Global $sGrepWinExe = 'D:\i\Pro\grepWin-x86\grepWin_portable.exe' ;ℹī¸ Add your path to grepWin <- Global $iShowGuiCtrlTip = 1 ;ℹī¸ Set to 0 to hide the GuiCtrlTip <- Global $MyIni = StringTrimRight(@ScriptFullPath, 4) & ".ini" Global $hSciTE_hWnd = WinGetHandle("[CLASS:SciTEWindow]", "") Global $hScite_Editor_hWnd = ControlGetHandle($hSciTE_hWnd, '', '[CLASS:Scintilla; INSTANCE:1]') Global $iParams, $hGrepWin_hWnd $iParams = $CmdLine[0] If Not $iParams Then Global $SciTE_CurrentFile, $SciTE_SelectetTxt $SciTE_SelectetTxt = _SciTE_GetSelection() ConsoleWrite("- $SciTE_CurrentFile=" & $SciTE_CurrentFile & @CRLF) ConsoleWrite("- $SciTE_SelectetTxt=" & $SciTE_SelectetTxt & @CRLF) _GrepWinGui($SciTE_SelectetTxt) Else $iParams = $CmdLine ;~ _TestGUI($CmdLineRaw) _OpenWithSciTE() EndIf Exit ;---------------------------------------------------------------------------------------- Func _SciTE_GetSelection() ;Return the Current SciTE Selection Local $ClipBack, $sClip $SciTE_CurrentFile = "" $ClipBack = ClipGet() ; backup clip data ;get first the $SciTE_CurrentFile ClipPut("<Empty>") ; <Empty> WinMenuSelectItem($hSciTE_hWnd, "", "&File", "Copy Pat&h") Sleep(50) Local $ScriptFullPath = ClipGet() Sleep(50) ConsoleWrite("--- $ScriptFullPath=" & $ScriptFullPath & @CRLF) If FileExists($ScriptFullPath) Then $SciTE_CurrentFile = $ScriptFullPath EndIf ; and then get the $SciTE_SelectetTxt ClipPut("<Empty>") ; <Empty> _SendMessage($hScite_Editor_hWnd, $WM_COPY) Sleep(100) ; * <- $sClip = ClipGet() ClipPut($ClipBack) ; Restore clip data If $sClip = "<Empty>" Then Return SetError(1, 0, "") Else Return $sClip EndIf EndFunc ;==>_SciTE_GetSelection ;---------------------------------------------------------------------------------------- Func _OpenWithSciTE() ;$CmdLineRaw order and send it to SciTE ; ℹī¸ important information ; in GrepWin settings in 'Command line to start an editor at a specific line:' give the follow string ; "PathToAutoIt3.exe" "PathToThisScript.au3" |%path%|%line% ; main:"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "D:\i\Pro\.AutoIT\SciTE_PlusBar\SciTE\CMD\GrepWinEditor.au3" |%path%|%line% ; ; then '|%path%|%line%' whill transformet to this. and send it to SciTE ; "-open:D:\\i\\Pro\\.AutoIT\\_Test\\_CreateContextMenu\\TrayMsg.au3" -goto:27 Local $aSpl = StringSplit($CmdLineRaw, "|") If $aSpl[0] = 3 Then Local $sCmdStr = '"-open:' & StringReplace($aSpl[2], "\", "\\") & '" -goto:' & $aSpl[3] ConsoleWrite("-- $sCmdStr=" & $sCmdStr & @CRLF) ShellExecute('C:\Program Files (x86)\AutoIt3\SciTE\SciTE.exe', $sCmdStr) EndIf EndFunc ;==>_OpenWithSciTE ;---------------------------------------------------------------------------------------- Func _TestGUI($Str) ; Test GUI Local $hGUI = GUICreate("Test GUI", 400, 151, 17, 552, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_NOACTIVATE)) GUICtrlCreateInput($Str, 10, 10, 381, 91, $ES_MULTILINE) Local $Button_Ok = GUICtrlCreateButton("OK", 140, 110, 91, 31) GUISetState(@SW_SHOWNORMAL, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $Button_Ok Exit Case Else ; EndSwitch WEnd EndFunc ;==>_TestGUI ;---------------------------------------------------------------------------------------- Func _GrepWinCall($CmdSectionName = Default, $sCmdSearchFor = Default, $sCmdRegex = Default, $sCmdSearchPath = Default) ; ℹī¸ important information ; https://tools.stefankueng.com/grepWin_cmd.html ; /searchpath:"path" sets the path to search in ; /searchfor:"regex or text" ; /regex:[yes|no] ; /searchini:"path/to/inifile" ; /name:"sectionname" argument ; main: ; /name:"sectionname" /searchini:"path" ; '/name:"Default" /searchini:"D:\i\Pro\.AutoIT\SciTE_PlusBar\SciTE\CMD\GrepWinEditor.ini"' ; chek if GrepWin is open and close it $hGrepWin_hWnd = WinGetHandle("[TITLE:grepWin; CLASS:#32770]") If WinExists($hGrepWin_hWnd) Then ConsoleWrite("! WinExists($hGrepWin_hWnd)" & @CRLF) ConsoleWrite("- WinClose=" & WinClose($hGrepWin_hWnd) & @CRLF) Sleep(100) EndIf Local $sCmdStr If $CmdSectionName = Default Then $CmdSectionName = "Default" If $sCmdSearchFor = Default Then $sCmdSearchFor = "" If $sCmdRegex = Default Then $sCmdRegex = "" If $sCmdSearchPath = Default Then $sCmdSearchPath = "" $sCmdStr = '/name:"' & $CmdSectionName & '"' $sCmdStr &= ' /searchini:"' & $MyIni & '"' If $sCmdSearchPath Then $sCmdStr &= ' /searchpath:"' & $sCmdSearchPath & '"' If Not $sCmdRegex Then $sCmdRegex = 'no' EndIf If $sCmdSearchFor Then $sCmdStr &= ' /searchfor:"' & $sCmdSearchFor & '"' If Not $sCmdRegex Then $sCmdRegex = 'no' EndIf If $sCmdRegex Then $sCmdStr &= ' /regex:"' & $sCmdRegex & '"' ConsoleWrite("- $sCmdStr=" & $sCmdStr & @CRLF) ShellExecute($sGrepWinExe, $sCmdStr) EndFunc ;==>_GrepWinCall ;---------------------------------------------------------------------------------------- Func _GrepWinGui($sCmdSearchFor = "", $sCmdRegex = "", $sCmdSearchPath = "") ; Ini Read Local $MyGui Local $iniFileExists = FileExists($MyIni) Local $index = 0 Local $aArray[1][3] $aArray[0][0] = $index $aArray[0][1] = "Button_ID" $aArray[0][2] = "SearchPath" #Region ===( Checks if .ini not exists then make one. )=== ; ℹī¸ important information ; Make the searchini , an ini file which contains all the values usually passed on the command line ; [@ScriptDir], [1 Up], [2 Up] section do not change them, they update dynamically evry time ; [@ScriptDir] = @ScriptDir ; [1 Up] = @ScriptDir & "\..\" ; [2 Up] = @ScriptDir & "\..\..\" ; [Default] = The Default setting if no parameter - do not change the Name ; the rest act as examples and they can change ; https://tools.stefankueng.com/grepWin_cmd.html ; https://github.com/stefankueng/grepWin/releases/tag/2.0.13 If Not $iniFileExists Then ;Open the file for writing (append to the end of a file) and store the handle to a variable. Local $hFileOpen = FileOpen($MyIni, $FO_APPEND + $FO_UTF8_NOBOM) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred while writing the " & @CRLF & $MyIni) Exit EndIf Local $spExamples = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1) & "\Examples" Local $spInclude = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1) & "\Include" Local $sTxt = "" $sTxt &= "[@ScriptDir]" & @CRLF $sTxt &= "searchpath=" & @CRLF $sTxt &= "regex=no" & @CRLF $sTxt &= "filemask=*.au3" & @CRLF $sTxt &= "direxcluderegex=BackUp" & @CRLF $sTxt &= "[1 Up]" & @CRLF $sTxt &= "searchpath=" & @CRLF $sTxt &= "regex=no" & @CRLF $sTxt &= "filemask=*.au3" & @CRLF $sTxt &= "direxcluderegex=BackUp" & @CRLF $sTxt &= "[2 Up]" & @CRLF $sTxt &= "searchpath=" & @CRLF $sTxt &= "regex=no" & @CRLF $sTxt &= "filemask=*.au3" & @CRLF $sTxt &= "direxcluderegex=BackUp" & @CRLF $sTxt &= "[Default]" & @CRLF $sTxt &= "searchpath=" & @MyDocumentsDir & @CRLF $sTxt &= "regex=no" & @CRLF $sTxt &= "filemask=*.au3" & @CRLF $sTxt &= "direxcluderegex=BackUp" & @CRLF $sTxt &= "[AutoIt3 -Examples]" & @CRLF $sTxt &= "searchpath=" & $spExamples & @CRLF $sTxt &= "regex=no" & @CRLF $sTxt &= "filemask=*.au3" & @CRLF $sTxt &= "direxcluderegex=BackUp" & @CRLF $sTxt &= "[AutoIt3 -Include]" & @CRLF $sTxt &= "searchpath=" & $spInclude & @CRLF $sTxt &= "regex=no" & @CRLF $sTxt &= "filemask=*.au3" & @CRLF $sTxt &= "direxcluderegex=BackUp" & @CRLF $sTxt &= "[All]" & @CRLF $sTxt &= "searchpath=" & @MyDocumentsDir & "|" & $spExamples & "|" & $spInclude & "|" & @CRLF $sTxt &= "regex=no" & @CRLF $sTxt &= "filemask=*.au3" & @CRLF $sTxt &= "direxcluderegex=BackUp" & @CRLF $sTxt &= "searchfor=search for All" & @CRLF ;Write data to the file using the handle returned by FileOpen. FileWrite($hFileOpen, $sTxt) ;Close the handle returned by FileOpen. FileClose($hFileOpen) Sleep(200) ShellExecute($MyIni) EndIf #EndRegion ===( Checks if .ini not exists then make one. )=== Local $iPosition, $sScriptDir, $sUp1, $sUp2 If $SciTE_CurrentFile Then $iPosition = StringInStr($SciTE_CurrentFile, "\", 0, -1) $sScriptDir = StringLeft($SciTE_CurrentFile, $iPosition - 1) ConsoleWrite("- $sScriptDir=" & $sScriptDir & @CRLF) $sUp1 = $sScriptDir $sUp2 = $sScriptDir $iPosition = StringInStr($SciTE_CurrentFile, "\", 0, -2) If $iPosition Then $sUp1 = StringLeft($SciTE_CurrentFile, $iPosition - 1) ConsoleWrite("- $sUp1=" & $sUp1 & @CRLF) $iPosition = StringInStr($SciTE_CurrentFile, "\", 0, -3) If $iPosition Then $sUp2 = StringLeft($SciTE_CurrentFile, $iPosition - 1) ConsoleWrite("- $sUp2=" & $sUp2 & @CRLF) EndIf ;prepare the @ScriptDir section IniWrite($MyIni, "@ScriptDir", "searchpath", $sScriptDir) IniWrite($MyIni, "1 Up", "searchpath", $sUp1) IniWrite($MyIni, "2 Up", "searchpath", $sUp2) Sleep(200) ;give some time to IniWrite ;Read the INI section names. This will return a 1 dimensional array. Local $aSections = IniReadSectionNames($MyIni) ;Check if an error occurred. If Not @error Then ;Enumerate through the array displaying the section names. For $i = 1 To $aSections[0] ReDim $aArray[UBound($aArray) + 1][3] $index += 1 $aArray[0][0] = $index ; cnt $aArray[$index][0] = $aSections[$i] $aArray[$index][2] = IniRead($MyIni, $aSections[$i], "searchpath", "default") ;SearchPath Next EndIf Local $iElements, $iOffset $iElements = $aArray[0][0] If $iElements > 0 Then $iOffset = 25 $MyGui = GUICreate("SearchFor: " & $sCmdSearchFor, 300, ($iElements * $iOffset) + 1, @DesktopWidth / 3, @DesktopHeight / 4, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) For $i = 1 To $iElements If $i = 1 Then $aArray[$i][1] = GUICtrlCreateButton($aArray[$i][0], 1, 0, 298, $iOffset, $BS_VCENTER) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") If $iShowGuiCtrlTip Then GUICtrlSetTip(-1, $aArray[$i][2]) Else $aArray[$i][1] = GUICtrlCreateButton($aArray[$i][0], 1, ($i - 1) * $iOffset, 298, $iOffset, $BS_VCENTER) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") If $iShowGuiCtrlTip Then GUICtrlSetTip(-1, $aArray[$i][2]) EndIf Next GUISetState(@SW_SHOW, $MyGui) ;~ _ArrayDisplay($aArray) Local $ID, $sSectionName While 1 $ID = GUIGetMsg() Switch $ID Case $GUI_EVENT_CLOSE Exit Case $aArray[1][1] To $aArray[$aArray[0][0]][1] $sSectionName = $aArray[$ID - 2][0] ConsoleWrite("- $sSectionName=" & $sSectionName & @CRLF) _GrepWinCall($sSectionName, $sCmdSearchFor, $sCmdRegex, $sCmdSearchPath) ExitLoop Case Else ; EndSwitch WEnd GUIDelete($MyGui) EndIf EndFunc ;==>_GrepWinGui ;---------------------------------------------------------------------------------------- Please, leave your comments and experiences here. thank you very much !
    1 point
  9. This works fine for me. #include <Binary.au3> ; https://www.autoitscript.com/forum/topic/131037-binary-udf/?do=findComment&comment=1339527 _Extract_PNG(@ScriptDir & "\Door.dwg") _Extract_PNG(@ScriptDir & "\test.png") Func _Extract_PNG($sFile_Input, $sFile_Output = "") If Not $sFile_Output Then $sFile_Output = $sFile_Input & "_extracted.png" Local $hFile = FileOpen($sFile_Input, 16) If $hFile = -1 Then Return SetError(1) Local $bContent = FileRead($hFile) FileClose($hFile) ; https://www.w3.org/TR/png/#5PNG-file-signature Local $i_Position_PNG_Header = _BinaryInBin($bContent, Binary("0x89504E470D0A1A0A")) If $i_Position_PNG_Header Then ; https://www.w3.org/TR/png/#11IEND ; https://stackoverflow.com/questions/51719833/whats-wrong-with-my-png-idat-chunk ; 49454E44 // IEND start - 4 bytes ; AE426082 // CRC of IEND chunk, 4 bytes Local $i_Position_PNG_IEND_Trailer = _BinaryInBin($bContent, Binary("0x49454E44AE426082")) If $i_Position_PNG_IEND_Trailer And ($i_Position_PNG_Header < $i_Position_PNG_IEND_Trailer) Then ConsoleWrite("+ PNG data found" & @CRLF) If FileExists($sFile_Output) Then ConsoleWrite("! Output file '" & $sFile_Output & "' existed, PNG extraction skipped " & @CRLF) Return SetError(2) EndIf $hFile = FileOpen($sFile_Output, 2 + 16) If $hFile = -1 Then Return SetError(3) FileWrite($hFile, BinaryMid($bContent, $i_Position_PNG_Header, $i_Position_PNG_IEND_Trailer - $i_Position_PNG_Header + 8)) ; +8 to include trailing PNG_IEND and CRC of IEND chunk FileClose($hFile) Return 1 EndIf EndIf ConsoleWrite("- No PNG data found" & @CRLF) Return 0 EndFunc ;==>_Extract_PNG Edit: Added +8 to binarymid length to include trailing IEND and CRC of IEND chunk and some error checking.
    1 point
  10. R0G

    Digital Sign Tool

    Digital Sign Tool V1.6 Features: Digitally sign: (.exe) (.cab) (.cat) (.ocx) (.dll) (.stl) Metro style GUI thanks @BBs19 Error logging Multi file support Instructions: You must have your (.pfx) certificate imported to the "Current User\Personal\Certificates" store Your certificate must be exportable Select your digital certificate from the drop down menu Click browse to add your files to sign Click sign For more information please visit: https://www.autoitscript.com/forum/topic/149137-sign-your-exe-with-a-digital-signature-signtoolexe/#comment-1061738 https://msdn.microsoft.com/en-us/library/bfsktky3(vs.100).aspx?f=255&MSPPError=-2147217396 Changelog: V1.6 1/8/2021 - Updated broken Signing URL - Added option to change signing URL in settings - Other Bug Fixes Download: Digital Sign Tool V1.6.zip Digital Sign Tool V0.5.zip
    1 point
×
×
  • Create New...