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. UEZ

Beiträge von UEZ

  • Toolbar Desktop v0.83 build 2025-10-08 beta

    • UEZ
    • 14. Juli 2023 um 19:17

    Kanashius du hast recht, ich habe vergessen, dass die Monitore auch übereinander sein können. Im Büro sind sie nebeneinander. Werde nächste Woche im Büro weiter machen.

  • Toolbar Desktop v0.83 build 2025-10-08 beta

    • UEZ
    • 14. Juli 2023 um 16:21

    Kanashius ich habe eine neue Version hochgeladen. Kannst du bitte nochmals testen, ob das Fenster jetzt auf allen Monitoren angezeigt wird?

    Danke.

  • Toolbar Desktop v0.83 build 2025-10-08 beta

    • UEZ
    • 14. Juli 2023 um 14:48
    Zitat von Moombas

    Nur den unteren Teil mit den Empfehlungen würde ich noch gerne ganz los werden

    Danke für dein Feedback, aber was meinst du damit?

    Zitat von Kanashius

    Funktioniert mit WIN10 (v10.0.19045).

    Verbesserungsvorschläge:

    Technisch:

    - Wird immer auf dem Hauptbildschirm eingeblendet. Evtl. anpassen, wenn die Maus auf nem anderen Bildschirm ist.

    - Du ließt die Dateien von @DesktopDir und @DesktopCommonDir. Hat mich etwas verwirrt, weil plötzlich nen haufen Shortcuts von Programmen aufgetaucht sind, die unter Public->Desktop zu finden sind, die ich aber auf meinem schon ewig gelöscht hatte. Keine Ahnung, ob das gewollt ist.

    Optisch:

    - Schrift-/Icongröße könnte man noch an die DPI anpassen. Hab grad in den Quellcode geschaut: Es wird der falsche Monitor gelesen. Es macht ggf. Sinn, mit _WinAPI_GetMonitorInfo den Primären Bildschirm herauszufinden, oder mit _WinAPI_MonitorFromPoint den aktuellen (Mauspositions) Bildschirm wenn du das Fenster auf mehreren Bildschirmen anzeigen lassen willst.

    - Es gibt nen schmalen Spalt zwischen der Taskleiste und dem Fenster (ca. 5px). Keine Ahnung, ob das gewollt ist, oder ob mit WIN11 die Höhe verändert wurde, oder ob es daran liegt, dass sich meine Taskleiste automatisch ausblendet.

    Alles anzeigen

    Danke auch für dein Feedback.

    Manchmal werden Icons unter @DesktopCommonDir gespeichert, was ich auch benötige, deshalb beide Pfade. Ich bin gerade dabei auf Multi-Monitor Systemen das Fenster an die entsprechende Stelle zu bekommen.

    Der Spalt ist Absicht, da sonst das Fenster direkt auf der Taskleiste aufliegt.

  • Toolbar Desktop v0.83 build 2025-10-08 beta

    • UEZ
    • 14. Juli 2023 um 13:40

    Seit Windows11 gibt es keine Möglichkeit mehr, den Desktop in der Taskleiste als Shortcut zu integrieren. Daher dieses Tool, um schnell die Desktop Icons zu starten.

    Die App läuft am besten kompiliert.

    AutoIt: Toolbar Desktop.au3
    Der Source Code überschreitet die 40.000 Zeichengrenze. ¯\_(ツ)_/¯
    -=> https://www.autoitscript.com/forum/topic/210707-toolbar-desktop-v080-build-2023-08-19-beta

    Da ich nur Windows11 benutze, weiß ich nicht, wie die App auf anderen System läuft. Ich wäre euch dankbar, wenn ihr die App testen und Feedback geben könntet. :)

    Download: Toolbar Desktop v0.83 build 2025-10-08 beta

    Dateien

    Toolbar Desktop v0.80 build 2023-08-19 beta.zip 613,25 kB – 519 Downloads
  • CMD Window hooken / subclassen in Freebasic

    • UEZ
    • 21. Juni 2023 um 19:59

    Ich suche einen Weg, wie ich in Freebasic den als CMD kompilierten Code hooken / subclassen kann, sodass ich die WM_* Codes abfragen kann. Die Exe startet nicht im Terminal Fenster, sondern im CMD Fenster, gestartet über die Conhost.exe.

    Code
    #Include "win\shlobj.bi"
    #Include "win\tlhelp32.bi"
    #Include "windows.bi"
    
    Function _WinAPI_GetBinaryType(sFilename As String) As DWORD
        Dim As DWORD lpBinaryType
        If GetBinaryTypeW(sFilename, @lpBinaryType) = 0 Then Return -1 'https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getbinarytypew
        Return lpBinaryType
    End Function
    
    Function _WinAPI_FindFile(sPath As String, sFilename As String) As String
        Dim As WIN32_FIND_DATA FindFileData
        Dim As HANDLE hFind
        Static As String sFile, sTmp
        hFind = FindFirstFile(sPath, @FindFileData)
        If hFind = INVALID_HANDLE_VALUE Then Return ""
        While FindNextFile(hFind, @FindFileData) <> 0
            If FindFileData.cFileName <> ".." Then
                If (FindFileData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY Then Return _WinAPI_FindFile(Left(sPath, InStrRev(sPath, "\")) & FindFileData.cFileName & "\*", sFilename)
                sTmp = Rtrim(sPath, "*") & sFilename
                Dim As Dword lpBinaryType = _WinAPI_GetBinaryType(sTmp) 
                If FindFileData.cFileName = sFilename And (lpBinaryType = 6 Or lpBinaryType = 0) Then sFile = sTmp
            Endif
        Wend
        
        FindClose(hFind)
        Return sFile
    End Function
    
    Function _WinAPI_IsOSx86() As Boolean 'https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getnativesysteminfo?redirectedfrom=MSDN
        Dim As SYSTEM_INFO lpSystemInfo
        GetNativeSystemInfo(@lpSystemInfo)
        Return lpSystemInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL
    End Function
    
    Function _WinAPI_GetParentProcess(iPID As Integer = 0) As Integer
        Dim As DWORD pid = Iif(iPID = 0, GetCurrentProcessId(), iPID), pid_parent = 0
        Dim As HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
        Dim As PROCESSENTRY32 tPROCESSENTRY32
        tPROCESSENTRY32.dwSize = Sizeof(tPROCESSENTRY32)
        Process32First(hSnapshot, @tPROCESSENTRY32)
        While TRUE
            If tPROCESSENTRY32.th32ProcessID = pid Then
                pid_parent = tPROCESSENTRY32.th32ParentProcessID
                Exit While
            End If
            Process32Next(hSnapshot, @tPROCESSENTRY32)
        Wend
        CloseHandle(hSnapshot)
        Return pid_parent
    End Function
    
    Function _WinAPI_GetProcessName(iPid As DWORD) As String
        Dim As HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, iPid)
        If hSnapshot = 0 Then Return ""
        Dim As PROCESSENTRY32W tPROCESSENTRY32W
        tPROCESSENTRY32W.dwSize = Sizeof(PROCESSENTRY32W)
        Process32FirstW(hSnapshot, @tPROCESSENTRY32W)
        While True
            If tPROCESSENTRY32W.th32ProcessID = iPid Then Exit While
            If Process32NextW(hSnapshot,  @tPROCESSENTRY32W) = 0 Then Exit While
        Wend
        CloseHandle(hSnapshot)
        Return tPROCESSENTRY32W.szExeFile
    End Function
    
    Function _WinAPI_TerminateProcess(iPID As Integer, iExitCode As Integer = 0, bInheritHandle As Boolean = True) As Boolean
        Dim As Long dwDesiredAccess = PROCESS_TERMINATE
        Dim As Handle hProcess = OpenProcess(dwDesiredAccess, bInheritHandle, iPID)
        If hProcess = Null Then Return False
        TerminateProcess(hProcess, iExitCode)
        CloseHandle(hProcess)
        Return True
    End Function
    
    Sub GetCommandLineArguments(Byref sArguments As String)
        Dim As Ubyte i = 1
        Dim As String s
        While True
            s = Command(i)
            If Len(s) = 0 Then Exit While
            sArguments &= s & " "
            i += 1
        Wend
    End Sub
    
    Sub SetConsoleSize(cols As Long, lines As Long)
        Shell "MODE CON: COLS=" + Str(cols) + "LINES=" + Str(lines)
    End Sub
    
        
    Declare Function RtlGetVersion Lib "NtDll.dll" Alias "RtlGetVersion" (OsVersionInformation As RTL_OSVERSIONINFOW) As Long
    
    Dim As RTL_OSVERSIONINFOW OS
    OS.dwOSVersionInfoSize = Sizeof(RTL_OSVERSIONINFOW)
    RtlGetVersion(OS)
    
    Dim Shared As HWND hConsole
    Dim As Handle hStdOut, hStdIn
    
    AllocConsole()
    
    hStdOut = GetStdHandle(STD_OUTPUT_HANDLE)
    hStdIn = GetStdHandle(STD_INPUT_HANDLE)
    hConsole = GetConsoleWindow()
    SetConsoleSize(80, 15)
    
    Dim As Integer iStyle = GetWindowLong(hConsole, GWL_STYLE)
    
    Dim As Wstring * 4096 sClassname
    GetClassNameW(hConsole, @sClassname, 4096)
    
    Dim As String sArguments = " "
    GetCommandLineArguments(sArguments)
    
    'Restert exe if it is in a Terminal Window
    If (SendMessageW(hConsole, WM_GETICON, Iif(OS.dwBuildNumber < 9200, 1, 0), 0) = 0 And sClassname = "PseudoConsoleWindow") And Command(1) <> "restart" Then 'restart app in CMD window
        #ifdef __FB_64BIT__
            Shell("conhost.exe """ &  Command(0) & """ restart" & sArguments)
        #Else
            If _WinAPI_IsOSx86() = False Then
                Dim As String sConhost = _WinAPI_FindFile("C:\Windows\WinSxS\amd64_microsoft-onecore-console-host-core_*", "conhost.exe")
                'If sConhost <> "" Then Shell("""" & sConhost & """" & " """ & Command(0) & """ restart" & sArguments)
                If sConhost <> "" Then 
                    Shell(sConhost & " """ & Command(0) & """ restart" & sArguments)
                Else
                    ? "Couldn't find conhost.exe"
                    Sleep
                Endif
            Else
                Shell("conhost.exe """ &  Command(0) & """ restart" & sArguments)
            Endif
        #endif 
        FreeConsole()
        End 1000
    Endif
    
    If Command(1) = "restart" Then
        Dim As String exeName = Mid(Command(0), Instrrev(Command(0), "/") + 1, Len(Command(0)))
        Dim As Ubyte countParentPIDs = 0
        Dim As Integer iPID, parentPID = _WinAPI_GetParentProcess()
        While True
            iPID = _WinAPI_GetParentProcess(parentPID)
            If _WinAPI_GetProcessName(iPID) <> "cmd.exe" Then 
                parentPID = iPID
                countParentPIDs += 1
                If countParentPIDs > 5 Then Exit While
            Else
                _WinAPI_TerminateProcess(iPID, 0, True)
                Exit While
            Endif
        Wend
    Endif
    
    
    Dim As CONSOLE_FONT_INFO tFontInfo
    GetCurrentConsoleFont(hStdOut, False, @tFontInfo)
    Dim As COORD tFonts = GetConsoleFontSize(hStdOut, tFontInfo.nFont)
    
    
    Dim Shared As Integer iOldStyle
    iOldStyle = GetWindowLong(hConsole, GWL_STYLE)
    SetWindowLong(hConsole, GWL_STYLE, iOldStyle And Not WS_MAXIMIZEBOX And Not WS_VSCROLL And Not WS_HSCROLL) 'Not WS_SIZEBOX And
    
    Dim Shared As LONG_PTR g_OldWndProc
    
    Function WindowProc(hWnd As HWND, uMsg As UINT, wParam As WPARAM, lParam As LPARAM) As LRESULT
        Select Case uMsg
            Case WM_CLOSE
                PostQuitMessage(0)
            Case WM_WINDOWPOSCHANGING
                Dim As WINDOWPOS Ptr tWinPos
                tWinPos = Cast(WINDOWPOS Ptr, lParam)
                ? tWinPos->cx, tWinPos->cy
                Return 0
        End Select
        ? hWnd, hConsole, uMsg
        Return CallWindowProc(Cast(WNDPROC, g_OldWndProc), hwnd, uMsg, wParam, lParam)
    End Function
    
    g_OldWndProc =  SetWindowLongPtr(hConsole, GWLP_WNDPROC, Cast(LONG_PTR, @WindowProc))
    
    ? g_OldWndProc
    
    Dim msg As MSG
    
    While GetMessage(@msg, 0, 0, 0)
        TranslateMessage(@msg)
        DispatchMessage(@msg)
    Wend
    SetWindowLongPtr(hCOnsole, GWLP_WNDPROC, Cast(LONG_PTR, @g_OldWndProc))
    FreeConsole()
    Alles anzeigen

    Wenn jemand eine Lösung in Autoit hat, dann kann ich den Code entsprechend umwandeln.

    Danke im Voraus.

  • AutoIt Windows Screenshooter v1.84 Build 2019-08-18

    • UEZ
    • 8. Juni 2023 um 21:38

    Ich bin eigentlich nicht der Fan von automatisierten Mouse geklicke, zumal das Aufnehmen "unsichtbar" stattfinden sollte, aber Danke. :thumbup:

  • AutoIt Windows Screenshooter v1.84 Build 2019-08-18

    • UEZ
    • 8. Juni 2023 um 21:03

    MojoeB danke für den Tipp. Da war ich schon und ich habe WebView2 zum Fliegen bekommen, nur fehlt mir noch die Screencapture Funktion.

    Microsoft Edge - WebView2, embed web code in your native application

  • AutoIt Windows Screenshooter v1.84 Build 2019-08-18

    • UEZ
    • 6. Juni 2023 um 09:13
    Zitat von Moombas

    Ist Edge nicht auch Chromium basiert?

    Da müsste doch prinzipiell das Gleiche funktionieren wie für Chrome wo ich mir gut vorstellen kann das es schon eine Chrome udf gibt, habe aber noch nicht danach geschaut zumal ich nicht genau weiß, was ihr davon bräuchtet und die Einzige die ich nun gesehen habe benötigt ein Add-In für Chrome.

    Aber evtl. mit der Webdriver au3: https://www.autoitscript.com/forum/topic/20…age-screenshot/

    Vielen Dank für den Hinweis. Ich habe es probiert und es funktioniert mit MSEdge, aber dazu benötigt man msedgedriver.exe, das 12.8 MB groß ist.

    Interessanter ist die WebView2 API, aber ich weiß momentan noch nicht, ob's jemand als UDF implementiert hat.

    Muss mir den Thread https://www.autoitscript.com/forum/topic/20…ve-application/ mal genauer anschauen.

  • AutoIt Windows Screenshooter v1.84 Build 2019-08-18

    • UEZ
    • 5. Juni 2023 um 22:29

    Ich recherchiere mal, ob's irgendwie über die MS Edge Engine funktioniert.

  • AutoIt Windows Screenshooter v1.84 Build 2019-08-18

    • UEZ
    • 5. Juni 2023 um 08:53

    Probiere mal den Anhang, ob du eine Webseite abfotografieren kannst. Windows Screenshooter.au3 benötigt die anderen Includes, d.h. in den gleichen Ordner kopieren und von dort aus starten.

    Dateien

    Windows Screenshooter.au3 423,04 kB – 246 Downloads
  • AutoIt Windows Screenshooter v1.84 Build 2019-08-18

    • UEZ
    • 4. Juni 2023 um 15:21

    Hi Tweaky,

    ich glaube, dass es daran liegt, dass die IE Engine nicht mehr funktioniert und das Screenshooten von Webseite benutzt dazu die IE Engine. Meine lokale Version v1.85 Build 2021-06-12 macht zwar unter Win11 22H2 einen Screenshot von Autoit.de, sieht aber bescheiden aus.

  • Basic Image Editor als Erweiterung für ein Screenshot Tool

    • UEZ
    • 24. Mai 2023 um 11:03

    Wie gesagt, ist die Version nur ein "Proof-of-Concept" Version und ich würde dem Status höchstens ein "Alpha" geben, da vieles nicht richtig funktioniert bzw. nicht implementiert ist.

    Ich weiß nicht, wie aufwändig es ist, aus dem Windows Screenshooter den Image Editor zu extrahieren.

    Ich habe auch keine Ambitionen diesen Image Editor weiterzuentwickeln - sorry.

  • Basic Image Editor als Erweiterung für ein Screenshot Tool

    • UEZ
    • 24. Mai 2023 um 10:09
    Zitat von gmmg

    Außerdem wäre die Frage, wie ich es hinbekomme, dass er beim start keinen Screenshot macht, sondern ich eine BMP Datei übergeben kann.

    In Zeile 26 wird ein Bildschirm Foto erstellt und benutzt. Einfach den Bereich durch folgenden Code ersetzen:

    AutoIt
    Opt("MustDeclareVars", 1)
    
    Global $sFile = FileOpenDialog("Select an image", "", "Images (*.jpg;*.bmp;*.png;*.gif)")
    If @error Then Exit MsgBox(16, "Error", "No image has been selected")
    Global Const $dll = DllOpen("user32.dll")
    _GDIPlus_Startup()
    Global $ghGDIPDll = $__g_hGDIPDll
    Global $aDPI = _GDIPlus_GraphicsGetDPIRatio()
    ;~ Global $hBMP_Screen = _ScreenCapture_Capture("", 0, 0, 1920, 1080)
    ;~ Global $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($hBMP_Screen)
    ;~ _WinAPI_DeleteObject($hBMP_Screen)
    Global $hBmp = _GDIPlus_ImageLoadFromFile($sFile)
    Global $bW = _GDIPlus_ImageGetWidth($hBmp)
    Global $bH = _GDIPlus_ImageGetHeight($hBmp)
    Alles anzeigen
    Zitat von gmmg

    AutoIt Windows Screenshooter v1.84 Build 2019-08-18\AutoIt Windows Screenshooter\_Source\Windows Screenshooter.au3"(122,107) : error: $GDIP_WrapModeTileFlipXY previously declared as a 'Const'.

    Global Enum $GDIP_WrapModeTile, $GDIP_WrapModeTileFlipX, $GDIP_WrapModeTileFlipY, $GDIP_WrapModeTileFlipXY,

    Einfach die Zeile auskommentieren, da die Variablen bereits deklariert sind. Zu der damaligen Zeit war dies nicht der Fall.

    Die Funktion

    AutoIt
    Func Save_Bitmap()
        Return 1
    EndFunc

    kannst du versuchen mit "Leben" zu füllen, um das Resultat in eine Bilddatei zu speichern.

  • Basic Image Editor als Erweiterung für ein Screenshot Tool

    • UEZ
    • 23. Mai 2023 um 15:54

    Der Editor war nie als eigenständiges Tool gedacht, sondern nur als "Proof-of-Concept" Version. Die stabilere Version ist im Windows Screenshooter Tool integriert.

    Diese ältere Version scheint einigermaßen zu funktionieren: Basic Image Editor.au3

  • MsgBox hooken und Countdown hinzufügen

    • UEZ
    • 28. April 2023 um 13:10

    funkey : Prima, werde es testen und mich melden, falls ich was finde...

  • MsgBox hooken und Countdown hinzufügen

    • UEZ
    • 27. April 2023 um 17:08
    Zitat von funkey

    Hallo,

    hab das mal in meine HookDlgBox-UDF eingebaut.

    HookDlgBox.au3
    AutoIt
    #include-once
    #include <WinAPI.au3>
    #include <Timers.au3>
    
    Global Const $tagCBT_CREATEWND = "ptr lpcs;HWND tagCBT_CREATEWND"
    Global Const $tagCREATESTRUCT = "ptr lpCreateParams;handle hInstance;HWND hMenu;HWND hwndParent;int cy;int cx;int y;int x;LONG style;ptr lpszName;ptr lpszClass;DWORD dwExStyle"
    
    Global $g__hProcDlgBox = DllCallbackRegister("__DlgBox_CbtHookProc", "LRESULT", "int;WPARAM;LPARAM")
    Global $g__TIdDlgBox = _WinAPI_GetCurrentThreadId()
    Global $g__hHookDlgBox = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($g__hProcDlgBox), 0, $g__TIdDlgBox)
    
    Global Const $g__MaxDlgBtns = 5 ; maximum of 5 buttons to rename text
    Global Const $g__MaxDlgItemId = 11 ; maximun ID of buttons to search is 11 as this is the maximun used in Messagebox
    
    Global $g__DlgBoxPosX, $g__DlgBoxPosY, $g__DlgBoxWidth, $g__DlgBoxHeight
    Global $g__aDlgBoxBtnText[$g__MaxDlgBtns]
    
    Global $g__DlgBtnCount = 0
    Global $g_DlgBoxTimeout = 0
    Global $g_DlgBoxTimeCtrlNum, $g_DlgBoxTimeCtrlId
    Global $g_DlgBoxTimerId
    
    _DlgBox_SetDefaults()
    
    OnAutoItExitRegister("__DlgBox_UnregisterHook")
    
    
    Func _DlgBox_SetButtonNames($TxtBtn1 = Default, $TxtBtn2 = Default, $TxtBtn3 = Default, $TxtBtn4 = Default, $TxtBtn5 = Default)
        $g__aDlgBoxBtnText[0] = $TxtBtn1
        $g__aDlgBoxBtnText[1] = $TxtBtn2
        $g__aDlgBoxBtnText[2] = $TxtBtn3
        $g__aDlgBoxBtnText[3] = $TxtBtn4
        $g__aDlgBoxBtnText[4] = $TxtBtn5
    
        $g__DlgBtnCount = @NumParams
    EndFunc   ;==>_DlgBox_SetButtonNames
    
    Func _DlgBox_SetPosition($x = Default, $y = Default) ;only for MsgBox, not working and not needed for InputBox
        $g__DlgBoxPosX = $x
        $g__DlgBoxPosY = $y
    EndFunc   ;==>_DlgBox_SetPosition
    
    Func _DlgBox_SetSize($w = Default, $h = Default)
        $g__DlgBoxWidth = $w
        $g__DlgBoxHeight = $h
    EndFunc   ;==>_DlgBox_SetSize
    
    Func _DlgBox_SetDefaults()
        $g__DlgBoxPosX = Default
        $g__DlgBoxPosY = Default
        $g__DlgBoxWidth = Default
        $g__DlgBoxHeight = Default
        For $i = 0 To UBound($g__aDlgBoxBtnText) - 1
            $g__aDlgBoxBtnText[$i] = Default
        Next
        $g_DlgBoxTimeout = 0
    EndFunc   ;==>_DlgBox_SetDefaults
    
    Func _DlgBox_SetTimeOut($iTimeout = 0, $CtrlId = 1)
        $g_DlgBoxTimeout = $iTimeout
        $g_DlgBoxTimeCtrlNum = $CtrlId
    EndFunc
    
    Func __DlgBox_CbtHookProc($nCode, $wParam, $lParam)
        Local $tcw, $tcs
        Local $iSearch = 0
        Local $ahBtn[$g__DlgBtnCount]
        If $nCode < 0 Then
            Return _WinAPI_CallNextHookEx($g__hHookDlgBox, $nCode, $wParam, $lParam)
        EndIf
    
        Switch $nCode
            Case 3 ;5=HCBT_CREATEWND
                If _WinAPI_GetClassName(HWnd($wParam)) = "#32770" Then ;Dialog window class
                    $tcw = DllStructCreate($tagCBT_CREATEWND, $lParam)
                    $tcs = DllStructCreate($tagCREATESTRUCT, DllStructGetData($tcw, "lpcs"))
    
                    If $g__DlgBoxPosX <> Default Then DllStructSetData($tcs, "x", $g__DlgBoxPosX)
                    If $g__DlgBoxPosY <> Default Then DllStructSetData($tcs, "y", $g__DlgBoxPosY)
                    If $g__DlgBoxWidth <> Default Then DllStructSetData($tcs, "cx", $g__DlgBoxWidth)
                    If $g__DlgBoxHeight <> Default Then DllStructSetData($tcs, "cy", $g__DlgBoxHeight)
    
                    If $g_DlgBoxTimeout <> 0 Then
                        $g_DlgBoxTimerId = _Timer_SetTimer(HWnd($wParam), 1000, "_UpdateTime")
                    EndIf
                EndIf
            Case 5 ;5=HCBT_ACTIVATE
                If _WinAPI_GetClassName(HWnd($wParam)) = "#32770" Then ;Dialog window class
                    For $i = 1 To $g__MaxDlgItemId
                        If IsHWnd(_WinAPI_GetDlgItem($wParam, $i)) Then
                            If $g_DlgBoxTimeout > 0 Then
                                If $iSearch == $g_DlgBoxTimeCtrlNum - 1 Then
                                    $g_DlgBoxTimeCtrlId = $i
                                    If $g__aDlgBoxBtnText[$iSearch] <> Default Then _WinAPI_SetDlgItemText($wParam, $i, $g__aDlgBoxBtnText[$iSearch] & " [" & $g_DlgBoxTimeout & "]")
                                Else
                                    If $g__aDlgBoxBtnText[$iSearch] <> Default Then _WinAPI_SetDlgItemText($wParam, $i, $g__aDlgBoxBtnText[$iSearch])
                                EndIf
                            Else
                                If $g__aDlgBoxBtnText[$iSearch] <> Default Then _WinAPI_SetDlgItemText($wParam, $i, $g__aDlgBoxBtnText[$iSearch])
                            EndIf
    
                            $iSearch += 1
                            If $iSearch >= UBound($ahBtn) Then ExitLoop
                        EndIf
                    Next
                EndIf
            Case 4 ;4=HCBT_DESTROYWND
                If _WinAPI_GetClassName(HWnd($wParam)) = "#32770" Then ;Dialog window class
                    _Timer_KillTimer(HWnd($wParam), $g_DlgBoxTimerId)
                    $g_DlgBoxTimeout = 0
                EndIf
        EndSwitch
        Return _WinAPI_CallNextHookEx($g__hHookDlgBox, $nCode, $wParam, $lParam)
    EndFunc   ;==>__DlgBox_CbtHookProc
    
    Func _UpdateTime($hWnd, $iMsg, $iIDTimer, $iTime)
        #forceref $hWnd, $iMsg, $iIDTimer, $iTime
    ;~     ConsoleWrite($hWnd&" - "&$iMsg&" - "&$iIDTimer&" - "&$iTime & @CRLF)
    
        $g_DlgBoxTimeout -= 1
        _WinAPI_SetDlgItemText($hWnd, $g_DlgBoxTimeCtrlId, $g__aDlgBoxBtnText[$g_DlgBoxTimeCtrlNum - 1] & " [" & $g_DlgBoxTimeout & "]")
        If $g_DlgBoxTimeout <= 0 Then
            WinClose($hWnd)
        EndIf
    EndFunc   ;==>_UpdateTime
    
    
    Func __DlgBox_UnregisterHook()
        _WinAPI_UnhookWindowsHookEx($g__hHookDlgBox)
        DllCallbackFree($g__hProcDlgBox)
    EndFunc   ;==>__DlgBox_UnregisterHook
    
    Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString)
        Local $aRet = DllCall('user32.dll', "int", "SetDlgItemText", _
                "hwnd", $hDlg, _
                "int", $nIDDlgItem, _
                "str", $lpString)
        Return $aRet[0]
    EndFunc   ;==>_WinAPI_SetDlgItemText
    Alles anzeigen
    HookDlgBox Timeout Beispiel
    AutoIt
    #include "HookDlgBox.au3"
    
    Global $Timeout = 5
    
    _DlgBox_SetTimeOut($Timeout, 1)
    _DlgBox_SetButtonNames("one", "two", "three")
    
    Global $iRet1 = MsgBox(3, "Test 1", "Custom button texts", $Timeout)
    ConsoleWrite($iRet1 & @CRLF)
    
    
    Global $iRet2 = MsgBox(3, "Test 2", "Custom button texts", $Timeout)
    ConsoleWrite($iRet2 & @CRLF)
    
    _DlgBox_SetTimeOut($Timeout, 2)
    
    Global $iRet3 = MsgBox(3, "Test 3", "Custom button texts")
    ConsoleWrite($iRet3 & @CRLF)
    
    _DlgBox_SetTimeOut($Timeout, 3)
    
    Global $iRet4 = MsgBox(3, "Test 4", "Custom button texts")
    ConsoleWrite($iRet4 & @CRLF)
    Alles anzeigen

    Dieses Beispiel funktioniert nicht:

    AutoIt
    #include <MsgBoxConstants.au3>
    #include "HookDlgBox.au3"
    
    Global $Timeout = 5
    
    _DlgBox_SetTimeOut($Timeout, 1)
    _DlgBox_SetButtonNames("Exit")
    MsgBox(BitOR($MB_TOPMOST, $MB_ICONINFORMATION), "Information", "View has been refreshed!", $Timeout)

    Anscheinend geht es nur mit $MB_YESNOCANCEL.

  • MsgBox hooken und Countdown hinzufügen

    • UEZ
    • 27. April 2023 um 14:34

    Velted : stimmt, danke für den Hinweis.

  • MsgBox hooken und Countdown hinzufügen

    • UEZ
    • 27. April 2023 um 14:04

    funkey :thumbup:

  • MsgBox hooken und Countdown hinzufügen

    • UEZ
    • 27. April 2023 um 11:17

    Oscar danke für deine Alternative!

    Das hier funktioniert jetzt:

    AutoIt
    ;Coded by UEZ build 2023-04-27 beta
    
    #include <Timers.au3>
    #include <WinAPIConstants.au3>
    #include <WinAPIGdi.au3>
    #include <WinAPIProc.au3>
    #include <WinAPISys.au3>
    #include <WindowsConstants.au3>
    
    Global $HCBT_ACTIVATE = 5, $g_hMsgBoxHook, $g_hMod, $g_hThreadID, $g_hSubMsgBox, $g_SubMsgBox, $g_lPrevWnd, $g_HWND, $g_idTImer, $g_
    Global $g_Time = 5
    
    Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString) ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setdlgitemtextw
        Local $aRet = DllCall("user32.dll", "int", "SetDlgItemText", "hwnd", $hDlg, "int", $nIDDlgItem, "str", $lpString)
        If @error Then Return SetError(@error, @extended, 0)
        Return $aRet[0]
    EndFunc   ;==>_WinAPI_SetDlgItemText
    
    Func _SubMsgBoxProc($hwnd, $iMsg, $wParam, $lParam)
        Switch $iMsg
            Case $WM_SHOWWINDOW
            Case $WM_CTLCOLORDLG, $WM_CTLCOLORSTATIC
    ;~             Local $tLOGBRUSH = DllStructCreate("uint lbStyle;long lbColor;ulong_ptr lbHatch")
    ;~             _WinAPI_SetBkColor($wParam, 0xFEDCBA)
    ;~             $tLOGBRUSH.lbColor = 0xFEDCBA
    ;~             DllCall("gdi32.dll", "handle", "CreateBrushIndirect", "struct*", $tLOGBRUSH)
    ;~             Return 0
            Case $WM_TIMER
                Local $sText = "Exit [" & $g_Time & "]"
                $g_Time -= 1
    ;~             ControlSetText($g_HWND, "", "[CLASS:Button; INSTANCE:1]", $sText)
                _WinAPI_SetDlgItemText($hWnd, $IDOK + 1, $sText)
                ConsoleWrite($g_Time & @CRLF)
    
                If $g_Time < 0 Then
                    _Timer_KillTimer($g_HWND, $g_idTImer)
                    _WinAPI_SetWindowLong($hwnd, $GWL_WNDPROC, $g_lPrevWnd)
                    GUIDelete($hwnd)
                EndIf
                Return 0
            Case $WM_DESTROY
                _Timer_KillTimer($g_HWND, $g_idTImer)
                _WinAPI_SetWindowLong($hwnd, $GWL_WNDPROC, $g_lPrevWnd)
        EndSwitch
        Return _WinAPI_CallWindowProc($g_lPrevWnd, $hWnd, $iMsg, $wParam, $lParam)
    EndFunc   ;==>_SubMsgBoxProc
    
    Func _CBTHookProc($nCode, $wParam, $lParam)
        If $nCode < 0 Then Return _WinAPI_CallNextHookEx($g_hMsgBoxHook, $nCode, $wParam, $lParam)
        Switch $nCode
            Case $HCBT_ACTIVATE
                $g_HWND = HWnd($wParam)
                If _WinAPI_GetClassName($g_HWND) = "#32770" Then
                    $g_idTImer = _Timer_SetTimer($g_HWND, 1000)
                    _WinAPI_SetDlgItemText($wParam, $IDOK, "Exit [" & $g_Time & "]")
                    $g_lPrevWnd = _WinAPI_SetWindowLong($g_HWND, $GWL_WNDPROC, DllCallbackGetPtr($g_SubMsgBox))
                EndIf
        EndSwitch
        Return _WinAPI_CallNextHookEx($g_hMsgBoxHook, $nCode, $wParam, $lParam)
    EndFunc   ;==>_CBTHookProc
    
    
    $g_SubMsgBox = DllCallbackRegister("_SubMsgBoxProc", "long", "hwnd;uint;wparam;lparam")
    $g_MsgProc = DllCallbackRegister("_CBTHookProc", "int", "uint;wparam;lparam")
    $g_hMod = _WinAPI_GetModuleHandle(0)
    $g_hThreadID = _WinAPI_GetCurrentThreadId()
    $g_hMsgBoxHook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($g_MsgProc), Null, $g_hThreadID)
    MsgBox(0, "Test", "This is a test message box with a counter!", $g_Time + 2)
    _WinAPI_UnhookWindowsHookEx($g_hMsgBoxHook)
    _WinAPI_UnhookWindowsHookEx($g_lPrevWnd)
    DllCallbackFree($g_SubMsgBox)
    DllCallbackFree($g_MsgProc)
    Alles anzeigen


    Kürzere Version angelehnt an funkey's Methode:

    AutoIt
    ;Coded by UEZ build 2023-04-29 beta
    
    #include <Timers.au3>
    #include <WinAPIConstants.au3>
    #include <WinAPIGdi.au3>
    #include <WinAPIProc.au3>
    #include <WinAPISys.au3>
    #include <WindowsConstants.au3>
    
    Const $HCBT_CREATEWND = 3, $HCBT_DESTROYWND = 4, $HCBT_ACTIVATE = 5, $g_iFlagDefault = BitOR($MB_TOPMOST, $MB_ICONINFORMATION)
    Global $g_hMsgBoxHook, $g_hSubMsgBox, $g_idTImer, $g_sBtn1_Txt = "Close", $g_sBtn2_Txt, $g_sBtn3_Txt
    Global $g_Timeout = 0
    
    Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString) ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setdlgitemtextw
        Local $aRet = DllCall("user32.dll", "int", "SetDlgItemText", "hwnd", $hDlg, "int", $nIDDlgItem, "str", $lpString)
        If @error Then Return SetError(@error, @extended, 0)
        Return $aRet[0]
    EndFunc   ;==>_WinAPI_SetDlgItemText
    
    Func _TimerProc($hwnd, $iMsg, $wParam, $lParam)
        If $g_Timeout <= 1 Then
            WinClose($hwnd)
        Else
            $g_Timeout -= 1
            _WinAPI_SetDlgItemText($hWnd, $IDOK + 1, $g_sBtn1_Txt & " [" & $g_Timeout & "]")
        EndIf
    EndFunc   ;==>_TimerProc
    
    Func _CBTHookProc($nCode, $wParam, $lParam)
        If $nCode < 0 Then Return _WinAPI_CallNextHookEx($g_hMsgBoxHook, $nCode, $wParam, $lParam)
        Local Const $hHWND = HWnd($wParam)
        Switch $nCode
            Case $HCBT_ACTIVATE
                If _WinAPI_GetClassName($hHWND) = "#32770" Then
                    If $g_Timeout Then $g_idTImer = _Timer_SetTimer($hHWND, 1000, "_TimerProc")
                    _WinAPI_SetDlgItemText($wParam, $IDOK, $g_Timeout ? $g_sBtn1_Txt & " [" & $g_Timeout & "]" : $g_sBtn1_Txt)
                EndIf
            Case $HCBT_DESTROYWND
                If _WinAPI_GetClassName($hHWND) = "#32770" Then _Timer_KillTimer($hHWND, $g_idTImer)
        EndSwitch
        Return _WinAPI_CallNextHookEx($g_hMsgBoxHook, $nCode, $wParam, $lParam)
    EndFunc   ;==>_CBTHookProc
    
    Func MsgBoxEx($sText, $sTitle = Default, $iTimeout = 0, $iFlag = Default, $sBtn_Txt = Default, $hParentHWND = "")
        If $sBtn_Txt <> Default Then $g_sBtn1_Txt = $sBtn_Txt
        If $iFlag = Default Then $iFlag = $g_iFlagDefault
        $g_Timeout = $iTimeout
        $g_MsgProc = DllCallbackRegister("_CBTHookProc", "int", "uint;wparam;lparam")
        Local Const $hThreadID = _WinAPI_GetCurrentThreadId()
        $g_hMsgBoxHook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($g_MsgProc), Null, $hThreadID)
        If $sTitle = Default Then $sTitle = "Information"
        Local Const $iReturn = MsgBox($iFlag, $sTitle, $sText, $iTimeout, $hParentHWND)
        _WinAPI_UnhookWindowsHookEx($g_hMsgBoxHook)
        DllCallbackFree($g_MsgProc)
        Return $iReturn
    EndFunc   ;==>MsgBoxEx
    
    ConsoleWrite(MsgBoxEx("This is a test", "Information", 5) & @CRLF)
    Alles anzeigen
  • MsgBox hooken und Countdown hinzufügen

    • UEZ
    • 26. April 2023 um 23:57

    Ich möchte gerne einen Countdown in das Ok Button hinzufügen, das die vorgebene Zeit herunter zählt. Man könnte dies natürlich mit einer eigen gebastelten GUI realisieren, aber will ich nicht. ;)

    Das habe ich soweit zusammen gebastelt, funktioniert leider nicht und meine Augen fallen gerade zu:

    AutoIt
    #include <WindowsConstants.au3>
    #include <WinAPIConstants.au3>
    #include <WinAPISys.au3>
    #include <WinAPIProc.au3>
    #include <Timers.au3>
    
    Global $tagCWPSTRUCT = "long lParam;long wParam;uint message;hwnd hwnd"
    Global $HCBT_ACTIVATE = 5, $g_hMsgBoxHook, $g_hMod, $g_hThreadID, $g_hSubMsgBox, $g_SubMsgBox, $g_lPrevWnd, $g_BtnID, $g_HWND, $g_idTImer
    Global $g_Time = 5
    
    Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString) ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setdlgitemtextw
        Local $aRet = DllCall("user32.dll", "int", "SetDlgItemText", "hwnd", $hDlg, "int", $nIDDlgItem, "str", $lpString)
        If @error Then Return SetError(@error, @extended, 0)
        Return $aRet[0]
    EndFunc   ;==>_WinAPI_SetDlgItemText
    
    Func _SubMsgBoxProc($hwnd, $iMsg, $wParam, $lParam)
        Switch $iMsg
            Case $WM_SHOWWINDOW
            Case $WM_TIMER
                _WinAPI_SetDlgItemText($g_BtnID, $IDOK, "OK [" & $g_Time & "]")
                $g_Time -= 1
                If $g_Time < 0 Then
                    _Timer_KillTimer($g_idTImer, $g_HWND)
                    _WinAPI_SetWindowLong($hwnd, $GWL_WNDPROC, $g_lPrevWnd)
                EndIf
                Return 0
            Case $WM_DESTROY
                _Timer_KillTimer($g_idTImer, $g_HWND)
                ;_WinAPI_SetWindowLong($hwnd, $GWL_WNDPROC, $g_lPrevWnd)
        EndSwitch
        Return _WinAPI_CallWindowProc($g_lPrevWnd, $hWnd, $iMsg, $wParam, $lParam)
    EndFunc
    
    Func _CBTHookProc($nCode, $wParam, $lParam)
        If $nCode < 0 Then Return _WinAPI_CallNextHookEx($g_hMsgBoxHook, $nCode, $wParam, $lParam)
        Local $tCWP = DllStructCreate($tagCWPSTRUCT, $lParam)
        Switch $nCode
            Case $HCBT_ACTIVATE
                $g_HWND = HWnd($wParam)
                If _WinAPI_GetClassName($g_HWND) = "#32770" Then
                    $g_idTImer = _Timer_SetTimer($g_HWND, 1000)
                    $g_BtnID = HWnd($wParam) ;_WinAPI_GetDlgItem($wParam, 1)
                    _WinAPI_SetDlgItemText($g_BtnID, $IDOK, "OK [" & $g_Time & "]")
                    $g_lPrevWnd = _WinAPI_SetWindowLong($g_HWND, $GWL_WNDPROC, DllCallbackGetPtr($g_SubMsgBox))
                EndIf
        EndSwitch
        Return _WinAPI_CallNextHookEx($g_hMsgBoxHook, $nCode, $wParam, $lParam)
    EndFunc
    
    
    $g_SubMsgBox = DllCallbackRegister("_SubMsgBoxProc", "long", "hwnd;uint;wparam;lparam")
    $g_MsgProc = DllCallbackRegister("_CBTHookProc", "int", "uint;wparam;lparam")
    $g_hMod = _WinAPI_GetModuleHandle(0)
    $g_hThreadID = _WinAPI_GetCurrentThreadId()
    $g_hMsgBoxHook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($g_MsgProc), Null, $g_hThreadID)
    MsgBox(0, "Test", "This is a test message box!")
    _WinAPI_UnhookWindowsHookEx($g_hMsgBoxHook)
    _WinAPI_UnhookWindowsHookEx($g_lPrevWnd)
    DllCallbackFree($g_SubMsgBox)
    DllCallbackFree($g_MsgProc)
    Alles anzeigen

    Könnt ihr den Fehler sehen?

    :sleeping:

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™