1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. Kanashius

Beiträge von Kanashius

  • Einzelnen Tab im Firefox schliessen?

    • Kanashius
    • 7. Oktober 2024 um 18:05

    In Firefox kannst du mit der Tastenkombination CTRL+w ein einzelnes Tab schließen. (Achtung: Das w muss KLEIN sein, ansonsten wird das Fenster geschlossen (CTRL+SHIFT+W)).

    Deshalb kannst du mit diesem Code ein einzelnes Tab schließen (Ich hab die Kombination nach 5 Sekunden im Aktiven Fenster gesendet, das kannst du aber an deinen Fenstertitel anpassen):

    AutoIt
    Sleep(5000)
    ControlSend("[active]", "", 0, "{CTRLDOWN}{w}{CTRLUP}")
  • Ballontipp bei Programmstart anzeigen an definierter Stelle

    • Kanashius
    • 19. September 2024 um 19:24

    Du wolltest den ToolTip ja auf dem ListItem haben:
    Du kannst die Position und Größe des Items mit _GuiCtrlListBox_GetItemRect abfragen.

    Ich hab mal ein Beispiel erstellt. Dabei werden auch mehrere ToolTips hintereinander angezeigt, ohne dass die GUI blockiert.
    Ich hab als alternative zu den Timern mal AdlibRegister genutzt.

    AutoIt
    #include <GUIConstantsEx.au3>
    #include <MsgBoxConstants.au3>
    #include <ListBoxConstants.au3>
    #include <GUIListBox.au3>
    #include <WindowsConstants.au3>
    
    Example()
    
    Func Example()
    	Local $mGuiData[]
    	Local $sMESSAGE = "||"
    
    	$mGuiData.hGui = GUICreate("My GUI list") ; will create a dialog box that when displayed is centered
    
    	$mGuiData.idList = GUICtrlCreateList("", 64, 32, 121, 97, BitOR($WS_VSCROLL, $LBS_USETABSTOPS))
    	GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
    	GUICtrlSetData(-1, "||")
    	GUICtrlSetData(-1, "1. Item")
    	$mGuiData.idButtonClose = GUICtrlCreateButton("my closing button", 64, 160, 175, 25)
    	$mGuiData.idButtonToolTip = GUICtrlCreateButton("show tooltips", 64, 200, 175, 25)
    
    	GUISetState(@SW_SHOW)
    
    	_showTooltips($mGuiData)
    
    	; Loop until the user exits.
    	While 1
    		Switch GUIGetMsg()
    			Case $GUI_EVENT_CLOSE
    				ExitLoop
    			Case $mGuiData.idButtonClose
    				MsgBox($MB_SYSTEMMODAL, "", "the closing button has been clicked", 2)
    				Exit
    			Case $mGuiData.idButtonToolTip
    				_showTooltips($mGuiData)
    		EndSwitch
    	WEnd
    EndFunc   ;==>Example
    
    Func _showTooltips(ByRef $mGuiData, $bContinue = False)
    	Local Static $iCurrent = 0
    	Local Static $mData
    	If $mGuiData<>Default Then $mData = $mGuiData
    	If Not $bContinue Then $iCurrent = 0
    	Switch $iCurrent
    		Case 0 ; first toolbar
    			Local $arPos = _GuiCtrlListBox_GetGlobalItemPos($mData.idList, 1)
    			_showToolTip($arPos[0] + ($arPos[2]*0.2), $arPos[1] + ($arPos[3]*0.9), "Listview item", 5)
    		Case 1 ; second toolbar
    			Local $arPos = _windowGetPos(GUICtrlGetHandle($mData.idButtonClose))
    			_showToolTip($arPos[0] + ($arPos[2]/2), $arPos[1] + ($arPos[3]/2), "Close button", 3)
    		Case 2 ; ...
    
    		Case Else
    			; Done
    	EndSwitch
    	$iCurrent += 1
    EndFunc
    
    Func _windowGetPos($hGui)
    	Local $tagRect = _WinAPI_GetWindowRect($hGui)
    	Local $arPos = [DllStructGetData($tagRect, 1), DllStructGetData($tagRect, 2), DllStructGetData($tagRect, 3) - DllStructGetData($tagRect, 1), DllStructGetData($tagRect, 4) - DllStructGetData($tagRect, 2)]
    	Return $arPos
    EndFunc
    
    Func _GuiCtrlListBox_GetGlobalItemPos($idList, $iIndex)
    	Local $arCtrlPos = _windowGetPos(GUICtrlGetHandle($idList))
    	Local $arItemPos = _GUICtrlListBox_GetItemRect($idList, 1)
    
    	Local $arRes = [$arCtrlPos[0]+$arItemPos[0], $arCtrlPos[1]+$arItemPos[1], $arItemPos[2]-$arItemPos[0], $arItemPos[3]-$arItemPos[1]]
    	Return $arRes
    EndFunc
    
    Func _showToolTip($x, $y, $sMessage, $iTimeS, $sTitle = "INFO", $iIcon = 1, $iOptions = 1)
    	ToolTip($sMessage, $x, $y, $sTitle, $iIcon, $iOptions)
    	AdlibRegister("_hideToolTip", $iTimeS*1000)
    EndFunc
    
    Func _hideToolTip()
    	ToolTip("")
    	AdlibUnRegister("_hideToolTip")
    	Local $oTmp = Default
    	_showTooltips($oTmp, True)
    EndFunc
    Alles anzeigen
  • erledigt: Umkreis von 50 oder 100 Meter auf einer Karte

    • Kanashius
    • 15. September 2024 um 21:39

    Duckduckgo: Draw on maps: https://www.scribblemaps.com/create#/lat=51…02&z=7&t=hybrid

    Hab ich grad getestet, da kann man recht leicht Kreise mit bestimmter größe zeichnen :)

  • Assemblerfunktion zum Aufsummieren direkt in AutoIt

    • Kanashius
    • 11. September 2024 um 15:02
    Zitat

    Aber zu der Rust-Dll-Geschichte: Eh ich erst einmal selbst wieder auf Recherchejagd gehe: Hast du da vielleicht gleich online Dokus wie man mit Rust entsprechende Dlls erstellt und evtl. sogar in AutoIt per MemCall einbindet?

    Ich hab für die QRCode UDF (QRCode UDF) mit Rust einen .dll erstellt. Wenn ich UEZ richtig verstanden habe, dann müsstest du die Base64 encoden und kannst die dann mit MemCall laden?

    Was du auf der Rustseite machen musst:

    Cargo.toml ([lib] section, damit eine windows .dll erstellt wird; [profile.release] kram ist für das optimizationlevel => kleinere Dateigröße):

    Code
    [lib]
    crate-type = ["cdylib"]
    
    [profile.release]
    codegen-units = 1
    lto = "fat"

    Code als C markieren (Damit structs, functions,... wie in C angelegt werden und kompatibel sind) e.g.:

    Code
    #[repr(C)]
    pub struct QRCode {
        pub something: u8, // ...
    }
    
    #[no_mangle]
    pub extern "C" fn EncodeText(input: *const u8, size: u32, ecl: u8, result: *mut QRCode) -> u8 { /* ... */}

    Mit target und als release kompilieren (beim erstenmal kann nen fehler kommen, dass du alles fürs build für das target erst installieren musst (je nachdem, auf was für einem system du bist), der command steht da aber auch direkt):

    Code
    x86: cargo build --target=x86_64-pc-windows-msvc --release
    x64: cargo build --target=i686-pc-windows-msvc --release


    Das sollte eigentlich alles sein :)

  • Assemblerfunktion zum Aufsummieren direkt in AutoIt

    • Kanashius
    • 31. August 2024 um 21:51

    Hi, ich kenn mich mit Assembler in AutoIt nicht so gut aus, nutze aber im moment Rust gerne und dachte mir, dass die Sprache doch sehr optimiert sein soll.
    Mit den passenden Parametern hab ich das ganze auf 8KB (x86) / 9KB (x64) bekommen und die Funktionen sind in Assembly auch deutlich kürzer, als dass was ich bei UEZ bei Freebasic sehe.
    Weiß aber leider nicht, wie man das mit AutoIt ausführt und ob der Code so funktioniert :)

    x86:

    Code
    ; =============== S U B R O U T I N E =======================================
                    public sum_double
    sum_double      proc near               ; DATA XREF: .rdata:off_10002508↓o
    var_8           = qword ptr -8
    arg_0           = dword ptr  8
    arg_4           = dword ptr  0Ch
                    push    ebp
                    mov     ebp, esp
                    and     esp, 0FFFFFFF8h
                    sub     esp, 8
                    mov     eax, [ebp+arg_4]
                    test    eax, eax
                    jz      short loc_1000102C
                    mov     ecx, [ebp+arg_0]
                    xorpd   xmm0, xmm0
                    mov     ecx, [ecx]
                    nop     dword ptr [eax+00000000h]
    loc_10001020:                           ; CODE XREF: sum_double+28↓j
                    addsd   xmm0, qword ptr [ecx]
                    add     ecx, 8
                    dec     eax
                    jnz     short loc_10001020
                    jmp     short loc_10001030
    loc_1000102C:                           ; CODE XREF: sum_double+E↑j
                    xorpd   xmm0, xmm0
    loc_10001030:                           ; CODE XREF: sum_double+2A↑j
                    movsd   [esp+8+var_8], xmm0
                    fld     [esp+8+var_8]
                    mov     esp, ebp
                    pop     ebp
                    retn
    sum_double      endp
    
    ; =============== S U B R O U T I N E =======================================
                    public sum_float
    sum_float       proc near               ; DATA XREF: .rdata:off_10002508↓o
    var_4           = dword ptr -4
    arg_0           = dword ptr  4
    arg_4           = dword ptr  8
                    push    eax
                    mov     eax, [esp+4+arg_4]
                    test    eax, eax
                    jz      short loc_10001074
                    mov     ecx, [esp+4+arg_0]
                    xorps   xmm0, xmm0
                    mov     ecx, [ecx]
                    nop     word ptr cs:[eax+eax+00000000h]
                    nop     dword ptr [eax+00h]
    loc_10001060:                           ; CODE XREF: sum_float+28↓j
                    addss   xmm0, dword ptr [ecx]
                    add     ecx, 4
                    dec     eax
                    jnz     short loc_10001060
                    movss   [esp+4+var_4], xmm0
                    fld     [esp+4+var_4]
                    pop     eax
                    retn
    loc_10001074:                           ; CODE XREF: sum_float+7↑j
                    xorps   xmm0, xmm0
                    movss   [esp+4+var_4], xmm0
                    fld     [esp+4+var_4]
                    pop     eax
                    retn
    sum_float       endp
    Alles anzeigen

    x64:

    Code
    ; =============== S U B R O U T I N E =======================================
                    public sum_double
    sum_double      proc near               ; DATA XREF: .rdata:off_1800027D8↓o
                    test    edx, edx
                    jz      short loc_18000101D
                    mov     rcx, [rcx]
                    mov     r8d, edx
                    mov     eax, r8d
                    and     eax, 7
                    cmp     edx, 8
                    jnb     short loc_180001021
                    xorpd   xmm0, xmm0
                    xor     edx, edx
                    jmp     short loc_180001068
    loc_18000101D:                          ; CODE XREF: sum_double+2↑j
                    xorps   xmm0, xmm0
                    retn
    loc_180001021:                          ; CODE XREF: sum_double+13↑j
                    and     r8d, 0FFFFFFF8h
                    xorpd   xmm0, xmm0
                    xor     edx, edx
                    nop     dword ptr [rax+rax+00h]
    loc_180001030:                          ; CODE XREF: sum_double+66↓j
                    addsd   xmm0, qword ptr [rcx+rdx*8]
                    addsd   xmm0, qword ptr [rcx+rdx*8+8]
                    addsd   xmm0, qword ptr [rcx+rdx*8+10h]
                    addsd   xmm0, qword ptr [rcx+rdx*8+18h]
                    addsd   xmm0, qword ptr [rcx+rdx*8+20h]
                    addsd   xmm0, qword ptr [rcx+rdx*8+28h]
                    addsd   xmm0, qword ptr [rcx+rdx*8+30h]
                    addsd   xmm0, qword ptr [rcx+rdx*8+38h]
                    add     rdx, 8
                    cmp     r8, rdx
                    jnz     short loc_180001030
    loc_180001068:                          ; CODE XREF: sum_double+1B↑j
                    test    rax, rax
                    jz      short locret_18000108D
                    lea     rcx, [rcx+rdx*8]
                    xor     edx, edx
                    db      66h, 66h, 66h, 66h, 2Eh
                    nop     word ptr [rax+rax+00000000h]
    loc_180001080:                          ; CODE XREF: sum_double+8B↓j
                    addsd   xmm0, qword ptr [rcx+rdx*8]
                    inc     rdx
                    cmp     rax, rdx
                    jnz     short loc_180001080
    locret_18000108D:                       ; CODE XREF: sum_double+6B↑j
                    retn
    sum_double      endp
    
    ; =============== S U B R O U T I N E =======================================
                    public sum_float
    sum_float       proc near               ; DATA XREF: .rdata:off_1800027D8↓o
                    test    edx, edx
                    jz      short loc_1800010AC
                    mov     rcx, [rcx]
                    mov     r8d, edx
                    mov     eax, r8d
                    and     eax, 7
                    cmp     edx, 8
                    jnb     short loc_1800010B0
                    xorps   xmm0, xmm0
                    xor     edx, edx
                    jmp     short loc_1800010F8
    loc_1800010AC:                          ; CODE XREF: sum_float+2↑j
                    xorps   xmm0, xmm0
                    retn
    loc_1800010B0:                          ; CODE XREF: sum_float+13↑j
                    and     r8d, 0FFFFFFF8h
                    xorps   xmm0, xmm0
                    xor     edx, edx
                    nop     dword ptr [rax+00000000h]
    loc_1800010C0:                          ; CODE XREF: sum_float+66↓j
                    addss   xmm0, dword ptr [rcx+rdx*4]
                    addss   xmm0, dword ptr [rcx+rdx*4+4]
                    addss   xmm0, dword ptr [rcx+rdx*4+8]
                    addss   xmm0, dword ptr [rcx+rdx*4+0Ch]
                    addss   xmm0, dword ptr [rcx+rdx*4+10h]
                    addss   xmm0, dword ptr [rcx+rdx*4+14h]
                    addss   xmm0, dword ptr [rcx+rdx*4+18h]
                    addss   xmm0, dword ptr [rcx+rdx*4+1Ch]
                    add     rdx, 8
                    cmp     r8, rdx
                    jnz     short loc_1800010C0
    loc_1800010F8:                          ; CODE XREF: sum_float+1A↑j
                    test    rax, rax
                    jz      short locret_18000111D
                    lea     rcx, [rcx+rdx*4]
                    xor     edx, edx
                    db      66h, 66h, 66h, 66h, 2Eh
                    nop     word ptr [rax+rax+00000000h]
    loc_180001110:                          ; CODE XREF: sum_float+8B↓j
                    addss   xmm0, dword ptr [rcx+rdx*4]
                    inc     rdx
                    cmp     rax, rdx
                    jnz     short loc_180001110
    locret_18000111D:                       ; CODE XREF: sum_float+6B↑j
                    retn
    sum_float       endp
    Alles anzeigen

    Code:

    Code
    #[repr(C)]
    pub struct Doubles { pub data: *mut f64, }
    
    #[repr(C)]
    pub struct Floats { pub data: *mut f32, }
    
    #[no_mangle]
    pub extern "C" fn sum_double(data: *mut Doubles, size: u32) -> f64 {
        unsafe { return std::slice::from_raw_parts((*data).data, size as usize).iter().sum(); }
    }
    
    #[no_mangle]
    pub extern "C" fn sum_float(data: *mut Floats, size: u32) -> f32 {
        unsafe { return std::slice::from_raw_parts((*data).data, size as usize).iter().sum(); }
    }
    Alles anzeigen

    Cargo.toml (für die c-lib und die compiler einstellungen zur optimierung):

    Code
    [package]
    name = "float_sum"
    version = "0.1.0"
    edition = "2021"
    
    [lib]
    crate-type = ["cdylib"]
    
    [dependencies]
    
    [profile.release]
    codegen-units = 1
    lto = "fat"
    Alles anzeigen


    Vielleicht hilft euch das ja weiter (und ich hatte etwas Spaß mit den Compileroptionen rumzuspielen :D)

    Dateien

    float_sum_dlls.zip 17,72 kB – 1 Download
  • QRCode UDF

    • Kanashius
    • 20. August 2024 um 15:46

    Hi :)
    Das war nur ein Beispiel, um die Geschwindigkeit der UDF (oft <100ms) zu zeigen.

    Für deine Frage:
    In Zeile 112: Local $sText = "Current date and time: "&@YEAR&"/"&@MON&"/"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC das @MSEC am Ende entfernen
    Und Zeile 133-139 Zeichnen das Viereck mit dem Sekundenzeiger
    Es gibt aber einige Variablen, die dort verwendet werden und woanders deklariert/definiert werden,...
    Sollte halt nur als Beispiel dienen, was alles möglich ist.

    Steht übrigens auch alles als Kommentar im Code: (; ==> Bottom QRCode / ; draw the white rectangle in the middle of the qrcode / ; draw the line in the rectangle / ...)

    MfG Kanashius

  • Tor Browser mit Autoit als Standart

    • Kanashius
    • 4. August 2024 um 15:22

    Ich hatte gerade nen Moment und hab das ganze etwas umgeschrieben/verbessert:
    - Ich hab die Dateien rausgenommen (bat/ps). Stattdessen werden die Scripte direkt mit RunWait ausgeführt => Kein unnötiges erstellen der Dateien jedesmal (Deine arme Festplatte :P)
    - Ich hab alles mit Arrays umgesetzt => Nicht so viel duplizierer Code und neue Optionen für Browser, VPNs und Länder können mit einer Zeile am Anfang des Scripts hinzugefügt werden
    (Könnte man theoretisch auch noch so ändern, dass man alles in einer Datei (z.B. Ini) definieren kann ohne jedesmall den Quellcode zu ändern => Zusätzlich: "nordvpn countries" listet alle verfügbaren Länder, "nordvpn status" könnte genutzt werden um auszulesen, welches Land gerade verbunden ist,... kannst mal mit "nordvpn help" schauen was alles geht )
    - Das Fenster hat en paar Parameter in Zeile 21 => Breite, Höhe,... kann dort angepasst werden und alle Controls haben automatisch die passende größe
    - Countries sind jetzt eine echte Liste, in der man auswählen kann => man sieht die letzte Auswahl noch

    AutoIt
    #include <StaticConstants.au3>
    #include <GuiComboBox.au3>
    #include <GuiListView.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    
    Global $sNordVPNPath = "C:\Program Files\NordVPN\nordvpn"
    ; Browser name, Control id
    Global $arBrowsers = [["Firefox", 0], ["Opera", 0], ["Edge", 0], ["Chrome", 0], ["Tor", 0]]
    ; VPN-Name, Function called when changing the country/disconnecting
    Global $arVPNs = [["NordVPN", "_NordVPNSelectCountry"], ["OtherVPN", "_OtherVPNSelectCountry"]]
    ; For every Country: Name, command argument nordvpn, command argument othervpn,...
    Global $arCountries = [ _
    						["Off", -1, -1], _
    						["Kenya", "Kenya", Default], _
    						["GBR", "United Kingdom", Default], _
    						["Portugal", "Portugal", "Portugal"], _
    						["Norwegen", "Norwegen", Default], _
    						["Sweden", "Sweden", Default] _
    					  ]
    
    
    Local $iNumberOfLines = (2+UBound($arBrowsers)+UBound($arCountries))+4
    Local $iSpace = 10, $iCtrlHeight = 25, $iWidth = 200, $iHeight = $iSpace*(1+$iNumberOfLines)+$iCtrlHeight*$iNumberOfLines
    If $iHeight>(@DesktopHeight-50) Then $iHeight = @DesktopHeight-50
    
    Local $hMainGui = GUICreate("VPN Selector", $iWidth, $iHeight)
    Local $iTop = $iSpace, $iCtrlWidth = $iWidth-$iSpace*2
    
    GUICtrlCreateLabel("Default Browser selection", $iSpace, $iTop, $iCtrlWidth, $iCtrlHeight, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 800)
    $iTop+=$iCtrlHeight+$iSpace
    For $i=0 To UBound($arBrowsers)-1 Step 1
    	$arBrowsers[$i][1] = GUICtrlCreateButton($arBrowsers[$i][0], $iSpace, $iTop, $iCtrlWidth, $iCtrlHeight)
    	$iTop+=$iCtrlHeight+$iSpace
    Next
    
    GUICtrlCreateLabel("VPN selection", $iSpace, $iTop, $iCtrlWidth, $iCtrlHeight, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 800)
    $iTop+=$iCtrlHeight+$iSpace
    Local $iComboVPNSelection = GUICtrlCreateCombo("", $iSpace, $iTop, $iCtrlWidth, $iCtrlHeight)
    For $i=0 To UBound($arVPNs)-1 Step 1
    	_GUICtrlComboBox_AddString(GUICtrlGetHandle($iComboVPNSelection), $arVPNs[$i][0])
    Next
    _GUICtrlComboBox_SetCurSel(GUICtrlGetHandle($iComboVPNSelection), 0)
    $iTop+=$iCtrlHeight+$iSpace
    
    GUICtrlCreateLabel("Country selection", $iSpace, $iTop, $iCtrlWidth, $iCtrlHeight, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 800)
    $iTop+=$iCtrlHeight+$iSpace
    
    Local $iCountryListView = GUICtrlCreateListView("Index|Country name", $iSpace, $iTop, $iCtrlWidth, $iHeight-$iTop-$iSpace)
    _GUICtrlListView_SetColumnWidth($iCountryListView, 0, 0)
    _GUICtrlListView_SetColumnWidth($iCountryListView, 1, $iCtrlWidth-5)
    _loadCountryList()
    
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    GUISetState(@SW_SHOW, $hMainGui)
    
    Global $iMsg
    While 1
    	$iMsg = GUIGetMsg()
    	Switch $iMsg
    		Case -3
    			Exit
    		Case $iComboVPNSelection
    			Local $iSelIndex = _GUICtrlComboBox_GetCurSel(GUICtrlGetHandle($iComboVPNSelection))
    			_loadCountryList($iSelIndex)
    		Case $iCountryListView
    
    	EndSwitch
    	For $i=0 To UBound($arBrowsers)-1 Step 1
    		If $arBrowsers[$i][1]=$iMsg Then
    			_selectDefaultBrowser($i)
    		EndIf
    	Next
    WEnd
    
    Func _loadCountryList($iIndexVPN = 0)
    	_GUICtrlListView_BeginUpdate($iCountryListView)
    	_GUICtrlListView_DeleteAllItems($iCountryListView)
    	For $i=0 To UBound($arCountries)-1 Step 1
    		If $arCountries[$i][1+$iIndexVPN]<>Default Then
    			Local $iIndex = _GUICtrlListView_AddItem($iCountryListView, $i)
    			_GUICtrlListView_AddSubItem($iCountryListView, $iIndex, $arCountries[$i][0], 1)
    		EndIf
    	Next
    	_GUICtrlListView_SetItemSelected($iCountryListView, 0)
    	_GUICtrlListView_EndUpdate($iCountryListView)
    EndFunc
    
    Func _NordVPNSelectCountry($iCountryIndex = 0)
    	Local $sCmd = ""
    	If $iCountryIndex = 0 Then
    		$sCmd = $sNordVPNPath&' --disconnect'
    	Else
    		Local $sCountry = $arCountries[$iCountryIndex][1]
    		$sCmd = $sNordVPNPath&' -c -g "'&$sCountry&'"'
    	EndIf
    	;ConsoleWrite($sCmd&@crlf)
    	RunWait($sCmd, @ScriptDir, @SW_HIDE)
    	If @error Then MsgBox(16, "Error", "Could not execute: "&$sCmd&@CRLF&"Errorcodes: "&@error&" >> "&@extended)
    EndFunc
    
    Func _OtherVPNSelectCountry($iCountryIndex = 0)
    	Local $sCmd = ""
    	If $iCountryIndex = 0 Then
    		$sCmd = "FancyVPN.exe"&' disconnect'
    	Else
    		Local $sCountry = $arCountries[$iCountryIndex][1]
    		$sCmd = "FancyVPN.exe"&' -c -g "'&$sCountry&'"'
    	EndIf
    	ConsoleWrite($sCmd&@crlf)
    EndFunc
    
    Func _selectDefaultBrowser($iBrowserIndex = 0)
    	Local $arCommands = [ _
    							"if ($env:OS -ne 'Windows_NT') { throw 'This script runs on Windows only' }", _
    							"Stop-Process -ErrorAction Ignore -Name SystemSettings", _
    							"Start-Process ms-settings:defaultapps", _
    							"$ps = Get-Process -ErrorAction Stop SystemSettings", _
    							"do {", _
    							"Start-Sleep -Milliseconds 100", _
    							"$ps.Refresh()", _
    							"} while ([int] $ps.MainWindowHandle)", _
    							"Start-Sleep -Milliseconds 200", _
    							"$shell = New-Object -ComObject WScript.Shell", _
    							"foreach ($i in 1..4) { $shell.SendKeys('{TAB}'); Start-Sleep -milliseconds 500 }", _
    							"$shell.SendKeys('" & $arBrowsers[$iBrowserIndex][0] & "'); Start-Sleep -seconds 1", _
    							"$shell.SendKeys('{TAB}'); Start-Sleep -milliseconds 100", _
    							"$shell.SendKeys('{ENTER}'); Start-Sleep -milliseconds 100", _
    							"$shell.SendKeys('{ENTER}'); Start-Sleep -milliseconds 100", _
    							"$shell.SendKeys('%{F4}')" _
    						]
    	Local $sCmd = ""
    	For $i=0 To UBound($arCommands)-1 Step 1
    		If $sCmd<>"" Then $sCmd&='; '
    		$sCmd&=$arCommands[$i]
    	Next
    	RunWait('powershell -command "'&$sCmd&'"', @ScriptDir, @SW_HIDE)
    	If @error Then MsgBox(16, "Error", "Could not execute: "&$sCmd&@CRLF&"Errorcodes: "&@error&" >> "&@extended)
    EndFunc
    
    Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
            Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
            Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
            Local $iCode = DllStructGetData($tNMHDR, "Code")
            Switch $hWndFrom
    			Case GUICtrlGetHandle($iCountryListView)
    				Switch $iCode
    					Case $NM_CLICK
    						;IDFrom,,Index,SubItem,NewState,OldState,Changed,ActionX,ActionY,lParam,KeyFlags
    						Local $tData = DllStructCreate($tagNMITEMACTIVATE, $lParam)
    						Local $iIndex = DllStructGetData($tData, "Index")
    						If $iIndex<>-1 Then
    							$iIndex = Int(_GUICtrlListView_GetItemText($iCountryListView, $iIndex, 0))
    							Local $iIndexVPN = _GUICtrlComboBox_GetCurSel(GUICtrlGetHandle($iComboVPNSelection))
    							Call($arVPNs[$iIndexVPN][1], $iIndex)
    						EndIf
    				EndSwitch
            EndSwitch
            Return $GUI_RUNDEFMSG
    EndFunc
    Alles anzeigen

    Ich hoffe, das kann dir helfen, das Script noch weiter zu optimieren und zu erweitern :)

  • SciTE - einfach zu Dark Theme switchen (+ Lua Dark Theme)

    • Kanashius
    • 1. August 2024 um 00:26
    Zitat

    Aber auch dabei bleiben Fensterrahmen, Scroolleiste, Menü usw. weiß bzw. hellgrau.

    Ja, das ist leider normal. SciTe an sich hat keinen Darkmode. Man ändert nur die Darstellung für den Code-Bereich.

  • If verzweigung treibt mich in den Wahnsinn

    • Kanashius
    • 29. Juli 2024 um 18:14

    Wenn du eh nur wissen willst, ob ein WWAN adapter vorhanden willst, würde ich es als Funktion mit Bool-Rückgabe implementieren. Macht das ganze kleiner und übersichtlicher.
    Du kannst dabei auch stattdessen das erste gefundene WWAN adapter zurückgeben und damit weiterarbeiten.

    AutoIt
    If Not _CI_HasWWAN() Then MsgBox(0, "Error", "No network adapters found or query failed.")
    
    Func _CI_HasWWAN()
    	Local $objWMIService = ObjGet("winmgmts:\\.\root\StandardCimv2")
    	Local $colItems = $objWMIService.ExecQuery("SELECT * FROM MSFT_NetAdapter")
    	If IsObj($colItems) Then
    		For $objItem In $colItems
    			; InterfaceType 243 ist für WWAN-Adapter
    			If $objItem.InterfaceType = 243 Then Return True ; maybe return $objItem, if you want the object itself
    		Next
    	EndIf
    	Return False
    EndFunc
    Alles anzeigen
  • Excel UDF

    • Kanashius
    • 26. Juli 2024 um 16:37

    Ist in AutoIt schon enthalten:

    #include <Excel.au3>

    Hilfe findest du, wenn du in SciTE z.B. _Excel_BookOpen eingibst, auf die Funktion klickst und F1 drückst.

  • Listbox wird immer mit letztem Eintrag angezeigt

    • Kanashius
    • 25. Juli 2024 um 15:56

    Zum auswählen in der ListBox: _GUICtrlListBox_SetCurSel($idList, 0)
    Dabei wird auch automatisch zu dem ausgewähltem Item gescrollt.

  • Listbox wird immer mit letztem Eintrag angezeigt

    • Kanashius
    • 25. Juli 2024 um 13:33

    Ich hab das ganze mal so umgebaut, wie ich das Error-Handling eher gestalten würde: Die Funktion gibt True/False zurück, je nach Erfolg, und setzt die entsprechenden Error-Codes, die nach dem Aufruf der Funktion behandelt werden.

    AutoIt
    Global $sFolderData = "data\"
    
    
    ; ... Gui code
    
    Local $sFilesFolder = @ScriptDir
    _fillListBox($QrCodeList, $sFilesFolder)
    If @error Then
    	Local $sTitle = "Fehler beim befüllen der Liste"
    	If @error = 1 Then MsgBox($MB_SYSTEMMODAL, $sTitle, 'Fehler beim auslesen des Ordners "'&$sFilesFolder&'": '&@extended&@crlf)
    	If @error = 2 Then MsgBox($MB_SYSTEMMODAL, $sTitle, 'Fehler beim schreiben der Ini: '&@extended&@crlf)
    	If @error = 4 Then MsgBox($MB_SYSTEMMODAL, $sTitle, '_fillListBox error, contact the developer with the following information: '&@error&">>"&@extended&@crlf)
    	If @error = 3 Then
    		If @extended = 1 Then
    			MsgBox($MB_SYSTEMMODAL, $sTitle, 'Pfad ungültig.'&@crlf)
    		ElseIf @extended = 4 Then
    			MsgBox($MB_SYSTEMMODAL, $sTitle, 'Keine Dateien gefunden.'&@crlf)
    		Else
    			MsgBox(16, $sTitle, 'Die INI-Datei konnte nicht gelesen werden.'&@crlf)
    		EndIf
    		Exit
    	EndIf
    EndIf
    
    ; Errors:
    ;         1: _FileListToArray failed (@extended contains _FileListToArray error code)
    ;         2: IniWrite failed (@extended contains IniWrite error code)
    ;         3: IniReadSection failed (@extended contains IniReadSection error code)
    ;         4: GUICtrlSetData failed (@extended contains GUICtrlSetData error code) => probably not a control for $idListBox
    Func _fillListBox($idListBox, $sFilePath, $sIniFile = $sFolderData & "listbox.ini")
    	Local Static $sSection = "items", $sKeyPrefix = "item"
    
    	; Update ini with files
    	$aFileList = _FileListToArray($sFilePath, "QR_*")
    	If @error Then Return SetError(1, @error, False)
    	For $i = 1 To UBound($aFileList)-1
    		IniWrite($sIniFile, $sSection, $sKeyPrefix & $i, $aFileList[$i])
    		If @error Then Return SetError(2, @error, False)
    	Next
    
    	; Read ini and fill listbox
    	Local $arItems = IniReadSection($sIniFile, "items")
    	If @error Then Return SetError(3, @error, False)
    	Sleep(200) ; Why?
    	For $i = 1 To $arItems[0][0]
    		GUICtrlSetData($idListBox, $arItems[$i][1])
    		If @error Then Return SetError(4, @error, False)
    	Next
    	Return True
    EndFunc   ;==>CreateListBox
    Alles anzeigen

    Das ganze behebt aber nicht dein eigentliches Problem. Dazu ein paar Anmerkungen/Fragen:

    1. Wieso liest du erst die Ini-Datei, dann befüllst du sie mit den aktuellen Dateien (und überschreibst dabei die alten Daten) und schreibst dann die alten Daten in die ListBox? Von dem was ich vom Code/deiner Fragenstellung vermute ergibt das keinen Sinn.
    2. MsgBox(16, "Fehler", "Die INI-Datei konnte nicht gelesen werden.") wird ausgegeben, wenn irgendein Fehler bei Sleep(200) aufgetreten ist??? Bedenke: @error wird bei jeglichem Funktionsaufruf auf 0 zurückgesetzt. Die Zeile kann also nie erreicht werden, da Sleep keine Fehlercode geben kann. Ich habe für meine Code-Änderung angenommen, dass sich die ganzen If @error Zeilen auf IniReadSection beziehen.
    3. Brauchst du die Ini überhaupt? Wenn ja, wofür? Du kannst eigentlich die Daten mit _FileListToArray einlesen und direkt in die ListBox schreiben.
    4. Was für eine Sortierung stellst du dir vor? Weder _FileListToArray noch IniReadSection garantieren, dass irgendeine Reihenfolge der Daten vorliegt. Normalerweise lesen sie von oben nach unten/alphabetisch, aber das kann sich auch aus irgendwelchen Gründen ändern. Vermutlich brauchst du also so oder so ein _ArraySort, oder etwas ähnliches.

  • PNG mit transparenz in PDF einfügen

    • Kanashius
    • 14. Juli 2024 um 00:11

    Auf den ersten BLick schaut es für mich richtig aus, du hast ja auch eig. nur bei CloneArea auf $GDIP_PXF32ARGB gewechselt und bei GraphicsClear auf 0x00FFFFFF.
    Ich würde auf die schnelle 2 Mögliche Probleme sehen:
    1. Unterstützt MPDF 32Bit ARGB Werte (Vielleicht musst du RGBA oder ähnliches verwenden (keine Ahnung ob das mit GDI-Plus geht))
    2. Nutzt du eventuell PDF/A (die Archiv Version von PDF)? Dort sind keine Transparenten Bilder erlaubt, da für die Archivierung alles genau definiert sein soll, was für Probleme sorgen könnte.

  • QRCode UDF

    • Kanashius
    • 13. Juli 2024 um 22:09

    Gern :)

    Ja, der DLL Code ist in Rust geschrieben, wobei ich dabei das Interface programmiert habe und mir angeschaut hab, wie man mit Rust eine DLL erstellt.
    Der Code zum generieren des QRCodes ist von der oben genannten Library.

  • Wifi QRCode Generator

    • Kanashius
    • 2. Juli 2024 um 14:15

    Dieses Skript ermöglicht es QRCodes für den automatischen login von Wifi-Netzwerken zu generieren, wie ihn die aktuellen Smartphones unterstützen.
    Dabei wird die Wifi-SSID und das Wifi-Passwort angegeben und ein entsprechender QRCode erstellt.
    Das Passwort kann auch mit der gewünschten Länge automatisch generiert werden.
    Die Wifi-SSID und das Wifi-Passwort werden auch unter den QRCode geschrieben, wobei eine Schriftart (Consolas) verwendet wird, die die Eindeutige unterscheidung zu anderen Zeichen ermöglicht (O/0,...).
    Die Schriftart-, größe,... kann, ebenso wie anderen Einstellungen, nach dem ersten Ausführen in data\config.ini geändert werden.

    WifiQRCodeGenerator.png

    Dateien

    WifiQRCodeGenerator.zip 158,07 kB – 444 Downloads WifiQRCodeGenerator-Executable.zip 914,64 kB – 386 Downloads
  • QRCode generator cli

    • Kanashius
    • 2. Juli 2024 um 14:10

    Dieses Skript ermöglicht es die QRCode UDF (QRCode UDF) in der Konsole zu nutzen.
    Es ermöglicht das Ausgeben eines QRCode in die Konsole oder als Bilddatei.
    Dabei kann auch ein Bild angegeben werden, dass automatisch in die Mitte des QRCodes gezeichnet wird.
    Die Größe wird dabei automatisch an das "error correction level" angepasst.

    Die aktuellste Version ist 1.1
        
    Hilfe:

    Code
    ================================ QRCode generator - cli ================================
    The QRCode generator cli provides a command line interface to generate qrcodes.
    It allows the user to print the qrcode to the console (if no destination path
    is provided) or to output the qrcode as an image. It also allows the addition
    of another image to be drawn ontop of the qrcode in the middle, with the size
    automatically adjusted accordingly to the error correction level (ECL).
    
    
    SYNOPSIS
    
    qrcodegenerator-cli [OPTION]... [INPUT TEXT] [OPTION]... [DESTINATION] [OPTION]...
    
    
    DESCRIPTION
    
    Generate a qrcode for the given input text.
    The qrcode is printed to the console, or if a DESTINATION is provided, the output is
    saved as an image to that DESTINATION.
    The INPUT TEXT is optional, but then it must be replaced with the flag -t/--text.
    The DESTINATION can be replaced with the flag -d/--out.
    
    -b, --background
            provide the desired value for the background.
            Image output: color as ARGB (Default "0xFFFFFFFF").
            Console output: the desired character/string (Default " ").
    -c, --color
            provide the desired value for the foreground.
            Image output: color as ARGB (Default "0xFF000000").
            Console output: the desired character/string (Default "#").
    -d, --delimeter
            provide a character/string to seperate multiple lines.
            This sequence is then replaced in the input text by \n (@LF)
            This can be changed to \r\n (@CRLF) with the flsg -r.
    -e, --ecl
            provide the error correction level (ECL) (Default "4").
            Possible values:
            Low (up to ~7% loss): 1
            Medium (up to ~15% loss): 2
            Quartile (up to ~25% loss): 3
            High (up to ~30% loss): 4
    -h, --help, help, /?, ?
            Show this help
    -i, --icon
            provide the path to an image. That image will then be drawn at the qrcode.
            It will be scaled to not be larger then the allowed ECL (see argument
            above). Image size in relation to the qrcode and with those ECLs:
            low 5%, medium 13%, quartile 23%, high 28%.
            Note: The icon will not be upscaled, if it is smaller.
            Note: You can change -s/--size to make the qrcode larger => more imagespace.
    -l, --linebreak
            provide the desired character/string to insert after every qrcode line
            (Default "\r\n" or "@CRLF"). This only works with console output.
    -m, --margin
            configure a border around the qrcode (Default "[0,0,0,0]").
            Defined as integer values: [<Top>,<Right>,<Bottom>,<Left>]
            With image output, it defines the border in pixels.
            With console output, it defines the border above/below with "\r\n" (@CRLF) and
            to the left/right with spaces (" ").
    -r
            Toggle from \n (@LF) to \r\n (@CRLF), when using the --delimeter command.
    -s, --size
            provide the desired size for the output.
            Image output: Pixel per rectangle
            Console output: Character/String per rectangle
            NOTE (Image output): Increasing the size changes the output width/height. This
            also influences the size of a possible icon (-i/--icon).
    -t, --text
            provides an alternative to define the input text. This allows the user to be
            sure, the text is not misinterpreted as another argument.
    -o, --out
            provides an alternative to define the destination. This allows the user to be
            sure the destination is not misinterpreted as another argument.
    
    
    ERROR HANDLING
    
    If an error occurres, the program prints an error and exits with an error code.
    Exit codes:
            1  - Missing arguments; at least the input text is required
            2  - Parameter --ecl provided, but value is missing or not one of [1,2,3,4]
            3  - Parameter --color provided, but value is missing
            4  - Parameter --background provided, but value is missing
            5  - Parameter --linebreak provided, but value is missing
            6  - Parameter --icon provided, but value is missing or path does not exist
            7  - Parameter --size provided, but value is missing or not an allowed value
            8  - Parameter --margin provided, but value is missing or not an allowed value
            9  - Parameter --out provided, but value is missing
            10 - Parameter --delimeter provided, but value is missing
            11 - Unknown parameter found
            12 - QRCode generation failed.
            13 - QRCode generation failed because of the input text being to large.
                 Maybe try a lower error correction level (ECL).
            14 - QRCode image file could not be saved. There may be a problem with the path.
            15 - Icon image file could not be loaded as an image
            16 - Drawing (image)/showing (console) the qrcode failed
    
    
    AUTHOR
    
    Kanashius
    Copyright ⌐ 2024 Kanashius (https://wwww.kanashius.com)
    Alles anzeigen

    Changelog:

    Code
    v1.1:
    - Add Flag -d, --delimeter to allow for a delimeter string to be used to add linebreaks to the input text
    - Add Flag -r to toggle from \n (@LF) to \r\n (@CRLF), when using the --delimeter command.

    Dateien

    QRCodeGenerator-CLI.zip 155,9 kB – 380 Downloads QRCodeGenerator-CLI-Executable.zip 677,51 kB – 390 Downloads QRCodeGenerator-CLI_v1.1.zip 161,85 kB – 305 Downloads QRCodeGenerator-CLI-Executable_v1.1.zip 698,11 kB – 360 Downloads
  • QRCode UDF

    • Kanashius
    • 2. Juli 2024 um 14:05

    Diese QRCode UDF ermöglicht es, QRCodes zu generieren und als Bild oder Ausgabe in der Konsole darzustellen.
    Sie bietet Funktionen um ein 2D-Boolean-Array des QRCodes zu erhalten, dieses als Bitmap (_GDIPlus) zu erhalten, oder direkt auf eine GraphicsContext (_GDIPlus) zu zeichnen.
    Dabei wird eine von mir mit Rust erstellte .dll genutzt, welche die "QR Code generator library (Rust)" von Project Nayuki (https://www.nayuki.io/page/qr-code-generator-library) verwendet.

    Aktuell sind folgende Funktionen in der UDF erhalten:

    Code
    _QRCode_StartUp                       - Startup needed before using most other functions (Includes _GDIPlus_Startup)
    _QRCode_Shutdown                      - Shutdown should be called at the and to clean up (Includes _GDIPlus_Shutdown)
    
    _QRCode_GetQRCode                     - Generate a QRCode as 2D-Boolean-Array, where the first index = lines, the second index=cols, normally False=White, True=Black
    _QRCode_GetBitmap                     - Creates a GDIPlus-Bitmap with the QRCode
    _QRCode_DrawQRCode                    - Draws a QRCode on a provides GDIPlus-GraphicsContext
    _QRCode_DrawQRCodeFast                - Same as _QRCode_DrawQRCode, but without error checks and requires brushes for the colors to be provided (=> higher FPS)
    _QRCode_ConsoleWrite                  - Print the QRCode to the console
    _QRCode_GetSize                       - Get the size of the generated QRCode
    _QRCode_GetECLMaxLoss                 - Get the maximum allowed loss before the qrcode becomes unreadable (decimal multiplier)
    
    Possible error correction levels:
    $_QRCode_ECL_LOW = 1
    $_QRCode_ECL_MEDIUM = 2
    $_QRCode_ECL_QUARTILE = 3
    $_QRCode_ECL_HIGH = 4                 - Default
    Alles anzeigen

    Hier ist ein Beispiel, wie die UDF verwendet werden kann:

    AutoIt
    #cs ----------------------------------------------------------------------------
    
     AutoIt Version: 3.3.16.1
     Author:         Kanashius
    
     Script Function:
    	Example script to show the usages of the QRCode UDF.
    
    #ce ----------------------------------------------------------------------------
    #include <Array.au3>
    #include "QRCode.au3"
    
    ; Startup to initialize the dll and call _GDIPlus_Startup
    _QRCode_StartUp()
    If @error Then
    	ConsoleWrite("Error QRCode startup: "&@error&" >> "&@extended&@crlf)
    	Exit
    EndIf
    
    ; Generate a 2D-Array with boolean values representing the QRCode
    ; The $_QRCode_ECL_HIGH provides a high error correction level. But a higher ECL also creates larger QRCodes and allows for less characters. So if any of that is an issue, try decreasing the ECL.
    ; The $_QRCode_ECL_HIGH is the default to be more robust and allow for images to be placed on top of the qrcode (like a logo in the middle) without making the qrcode unreadable.
    ;Local $arQRCode = _QRCode_GetQRCode("A very long String to test", $_QRCode_ECL_HIGH)
    Local $arQRCode = _QRCode_GetQRCode(Binary("0xFEED1337"), $_QRCode_ECL_HIGH)
    If @error Then
    	ConsoleWrite("Error creating QRCode: "&@error&" >> "&@extended&@crlf)
     	Exit
    EndIf
    
    ; Print the QRCode to the console.
    _QRCode_ConsoleWrite($arQrCode, "#", " ", @crlf)
    
    ; Create a Bitmap with the QRCode and a 50 pixel border.
    Local $hBitmap = _QRCode_GetBitmap($arQRCode, 4, 50, 50, 50, 50)
    ; _GDIPlus_ImageSaveToFile($hBitmap, "qrcode.png")
    _GDIPlus_BitmapDispose($hBitmap)
    
    ; ==> GuiExample drawing directly on the graphics context
    _guiExample()
    
    ; Shutdown to close the dll, free memory of structs and call _GDIPlus_Shutdown
    _QRCode_Shutdown()
    If @error Then ConsoleWrite("Error QRCode shutdown: "&@error&" >> "&@extended&@crlf)
    
    Func _guiExample()
    	Local $iWidth = 800, $iHeight = @DesktopHeight-100, $iSpace = 10, $iQRCodePixelSize = 4
    	Local $hGui = GUICreate("QRCode example", $iWidth, $iHeight)
    	 Local $iInput = GUICtrlCreateInput("This is a text example", $iSpace, $iSpace, $iWidth-$iSpace*2, 25)
    
    	; create buffer image
    	Local $iQRCodeAreaLeft = $iSpace, $iQRCodeAreaTop = $iSpace*2+25, $iQRCodeAreaWidth = $iWidth-$iSpace*2, $iQRCodeAreaHeight = $iHeight-$iSpace*3-25
    	Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    	Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iQRCodeAreaWidth, $iQRCodeAreaHeight, $hGraphics)
    	Local $hBitmapGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    	_GDIPlus_GraphicsClear($hBitmapGraphics, 0xFFFFFFFF)
    
    	GUISetState(@SW_SHOW, $hGui)
    	; create brushes for the rectangles
    	Local $hBrushBlack = _GDIPlus_BrushCreateSolid(0xFF000000)
    	Local $hBrushWhite = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
    	Local $hPenBlack = _GDIPlus_PenCreate(0xFF000000, 2)
    	_GDIPlus_GraphicsSetSmoothingMode($hBitmapGraphics, 2)
    
    	; generate the first bottom qrcode
    	Local $arQRCodeFast = _QRCode_GetQRCode("Current date and time: "&@YEAR&"/"&@MON&"/"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC, $_QRCode_ECL_HIGH)
    	If @error Then
    		MsgBox(16, "Error", "QRCode generation failed."&@crlf&"Most probable error is the qrcode.exe not being in the correct directory: "&@error&" >> "&@extended)
    		return false
    	EndIf
    	; save the size of the bottom qrcode
    	Local $arSizeQRCodeFast = _QRCode_GetSize($arQRCodeFast, $iQRCodePixelSize*2)
    	; initialize loop variables
    	Local $iMsg, $sQRCodeText = "", $arSizeQRCode = [0, 0], $PI = 3.141592653589793
    	While 1
    		$iMsg = GUIGetMsg()
    		If $iMsg = -3 Then ExitLoop
    
    		; ==> Top QRCode
    		; draw the top qrcode, if the input changes
    		If GUICtrlRead($iInput)<>$sQRCodeText Then
    			; clear the area of the old qrcode
    			_GDIPlus_GraphicsSetClipRect($hBitmapGraphics, ($iQRCodeAreaWidth-$arSizeQRCode[0])/2, 0, $arSizeQRCode[0], $arSizeQRCode[1])
    			_GDIPlus_GraphicsClear($hBitmapGraphics, 0xFFFFFFFF)
    			_GDIPlus_GraphicsResetClip($hBitmapGraphics)
    
    			; generate the new qrcode
    			$sQRCodeText = GUICtrlRead($iInput)
    			 Local $arQRCode = _QRCode_GetQRCode($sQRCodeText, $_QRCode_ECL_HIGH)
    			if @error Then
    				Local $iErr = @error, $iExt = @extended
    				_GDIPlus_GraphicsClear($hBitmapGraphics, 0xFFFFFFFF)
    				If $iErr=5 Then
    					MsgBox(16, "Error", "QRCode generation failed."&@crlf&"The given Text is ~"&($iExt/8)&" characters to long")
    				Else
    					MsgBox(16, "Error", "QRCode generation failed."&@crlf&"Most probable errors are a to long text or the qrcode.exe not being in the correct directory: "&$iErr&" >> "&$iExt)
    				EndIf
    			Else
    				; save the size of the new qrcode
    				$arSizeQRCode = _QRCode_GetSize($arQRCode, $iQRCodePixelSize)
    
    				; draw the new qrcode
    				Local $iQRCodeLeft = ($iQRCodeAreaWidth-$arSizeQRCode[0])/2
    				_QRCode_DrawQRCode($hBitmapGraphics, $arQRCode, $iQRCodePixelSize, $iQRCodeLeft, 0)
    				If @error Then
    					MsgBox(16, "Error", "QRCode drawing failed: "&@error&" "&@extended)
    					_GDIPlus_GraphicsClear($hBitmapGraphics, 0xFFFFFFFF)
    				EndIf
    			EndIf
    		EndIf
    
    		; ==> Bottom QRCode
    		Local $sText = "Current date and time: "&@YEAR&"/"&@MON&"/"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC&":"&@MSEC
    		Local $iTime = @SEC+@MSEC*0.001
    
    		; generate the qrcode for the new time
    		$arQRCodeFast = _QRCode_GetQRCode($sText, $_QRCode_ECL_HIGH)
    		If @error Then
    			MsgBox(16, "Error", "QRCode generation failed."&@crlf&"Most probable error is the qrcode.exe not being in the correct directory: "&@error&" >> "&@extended)
    			ExitLoop
    		EndIf
    		Local $iTextHeight = 20
    		; clear the area of the old qrcode
    		_GDIPlus_GraphicsSetClipRect($hBitmapGraphics, ($iQRCodeAreaWidth-$arSizeQRCodeFast[0])/2, $iQRCodeAreaHeight-$arSizeQRCodeFast[1]-$iTextHeight, $arSizeQRCodeFast[0], $arSizeQRCodeFast[1]+$iTextHeight)
    		_GDIPlus_GraphicsClear($hBitmapGraphics, 0xFFFFFFFF)
    		_GDIPlus_GraphicsResetClip($hBitmapGraphics)
    		; save the size of the new qrcode
    		$arSizeQRCodeFast = _QRCode_GetSize($arQRCodeFast, $iQRCodePixelSize*2)
    		; draw the time as string above the qrcode
    		_GDIPlus_GraphicsDrawString($hBitmapGraphics, $sText, ($iQRCodeAreaWidth-$arSizeQRCodeFast[0])/2+15, $iQRCodeAreaHeight-$arSizeQRCodeFast[1]-$iTextHeight)
    		; Draw the second qrcode
    		Local $iLeft = ($iQRCodeAreaWidth-$arSizeQRCodeFast[0])/2, $iTop = $iQRCodeAreaHeight-$arSizeQRCodeFast[1]
    		_QRCode_DrawQRCodeFast($hBitmapGraphics, $arQRCodeFast, $hBrushBlack, $hBrushWhite, $iQRCodePixelSize*2, $iLeft, $iTop)
    		; draw the white rectangle in the middle of the qrcode
    		Local $iRectSize = $arSizeQRCodeFast[0]*0.25, $iRectMidX = $iLeft+$arSizeQRCodeFast[0]/2, $iRectMidY = $iTop+$arSizeQRCodeFast[1]/2
    		_GDIPlus_GraphicsFillRect($hBitmapGraphics, $iRectMidX-$iRectSize/2, $iRectMidY-$iRectSize/2, $iRectSize, $iRectSize, $hBrushWhite)
    		; draw the line in the rectangle
    		Local $iTimeSec = Mod($iTime+45, 60)
    		Local $iRad = (360/60*$iTimeSec)*$PI/180
    		_GDIPlus_GraphicsDrawLine($hBitmapGraphics, $iRectMidX, $iRectMidY, $iRectMidX+$iRectSize/2*Cos($iRad), $iRectMidY+$iRectSize/2*Sin($iRad), $hPenBlack)
    
    		; draw bitmap to gui
    		_GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, $iQRCodeAreaLeft, $iQRCodeAreaTop, $iQRCodeAreaWidth, $iQRCodeAreaHeight)
    	WEnd
    	; cleanup time
    	_GDIPlus_GraphicsDispose($hGraphics)
    	_GDIPlus_PenDispose($hPenBlack)
    	_GDIPlus_BrushDispose($hBrushWhite)
    	_GDIPlus_BrushDispose($hBrushBlack)
    	GUIDelete($hGui)
    EndFunc
    Alles anzeigen


    Und ein weiteres Beispiel findet sich in der QRCodeGenerator-CLI: QRCode generator cli
    Das ist eine Konsolenanwendung mit umfangreichen Einstellungsmöglichkeiten zum generieren von QRCodes.

    Ich habe während der Entwicklung in Rust erst eine .exe statt der .dll erstellt. Die war aber langsamer (String parsing in AutoIt,...), deshalb hab ich das verworfen.
    Die in Rust entstandene .exe findet ihr aber bei den Dateien als Rust-Executable (QRCode-Wrapper-Console-Rust-Exe.zip).
    Sie kann in der Konsole mit einem Text aufgerufen werden und gibt den QRCode als 0 (weiß), 1 (schwarz), 2(neue zeile) aus.
    Mit --human wird der QRCode Menschenlesbar ausgegeben und mit --errorlvl low/medium/quartile/high kann das "error correction level" angegeben werden.
    Aber diese Anwendung hat weniger Möglichkeiten, als die vorher erwähnte QRCodeGenerator-cli und ist nur zur Vollständigkeit hier.

    Dateien:
    Die UDF mit allen benötigten Dateien: qrcode.zip
    Der Rust-Quellcode der .dll und .exe: QRCode-Dll-Exe-Rust-Src.zip
    Die Rust-Executable: QRCode-Wrapper-Console-Rust.zip

    Dateien

    qrcode.zip 158,83 kB – 483 Downloads QRCode-Dll-Exe-Rust-Src.zip 24,57 kB – 450 Downloads QRCode-Wrapper-Console-Rust-Exe.zip 181,85 kB – 408 Downloads
  • Ausgabe einer SSH-Sitzung bricht ab

    • Kanashius
    • 27. Juni 2024 um 16:37

    Du erstellst eine ssh session. Um die zu schließen, musst du die Verbindung trennen. Dazu kannst du das Kommando "EXIT" am Ende deines Kommandoaufrufes aufrufe, oder vermutlich auch den STD_IN nutzen.
    Das würde mit einem StdinWrite($iPid, "EXIT") funktionieren.

    ProcessClose versucht einen Prozess auf nette Art zu beenden (Sendet ein Terminations Signal an die Anwendung, die diese vermutlich ignoriert).
    Du könntest den Prozess also notfalls mit der Kommandozeile mit pskill beenden (kann auch mit AutoIt automatisiert werden).

  • Ausgabe einer SSH-Sitzung bricht ab

    • Kanashius
    • 27. Juni 2024 um 11:36

    Das "Unable to read from standard input: Das Handle ist ungültig." kommt vermutlich daher, dass du bei RUN nur angibst, dass $STDOUT_CHILD verwendet werden soll, aber nicht der $STDIN_CHILD.
    Vielleicht will plink.exe aber beides und wirft einen Fehler, wenn kein StandardInputStream vorhanden ist.

    Probier evtl. mal: Run(@ComSpec & " /c " & $sVar4 & " " & $sKonto & "@" & $sHost & " -pw " & $sPwd, @TempDir, @SW_HIDE, BitOr($STDIN_CHILD, $STDOUT_CHILD))
    Evtl. wäre auch $STDERR_CHILD gut, ggf. merged mit dem Output, einfach damit du das auch sehen kannst:
    Run(@ComSpec & " /c " & $sVar4 & " " & $sKonto & "@" & $sHost & " -pw " & $sPwd, @TempDir, @SW_HIDE, BitOr($STDIN_CHILD, $STDERR_MERGED))

  • sortieren nach IP

    • Kanashius
    • 26. Juni 2024 um 17:13
    Zitat von casi4712

    Also ich habs mal durchlaufne lassen und hab in der Logdef mal eine IP auf 192.168.100.5 gesetzt, diese würde ich bei der IP Sortierung aufsteigend auch oben erwarten und nicht unten, denke wir haben uns da missverstanden;)

    Die Sortierung hab ich auch gar nicht implementiert, ich hab nur die Daten aufbereitet.

    Dafür brauchst du aber auch nur ein _ArraySort($arLogData) in Zeile 17 nach dem Local $arLogData = _parseLog($sLogData) einfügen. (Und das #include<Array.au3> natürlich)

    MfG Kanashius

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™