Moin,
warum benutzt Du nicht $GUI_EVENT_DROPPED?
Moin,
warum benutzt Du nicht $GUI_EVENT_DROPPED?
Ok, nach der Doku ist die 5 für Netzlaufwerke immer falsch.
Was passiert, wenn Du das Skript als normaler Benutzer laufen lässt?
Moin,
die Routine entstammt offenbar den Beispielen für _WinAPI_MoveFileEx(). Leider hast Du Dir für den Parameter $iFlags einen 'unglücklichen' Wert ausgesucht.
5 entspricht $MOVE_FILE_REPLACE_EXISTING (0x0001) + $MOVE_FILE_DELAY_UNTIL_REBOOT (0x0004).
$MOVE_FILE_DELAY_UNTIL_REBOOT ist laut Doku für Dateien auf Netzlaufwerken nicht zulässig. Außerdem soll, wenn eine Datei auf ein anderes Laufwerk kopiert werden soll, das Flag MOVE_FILE_COPY_ALLOWED (0x0002) gesetzt werden.
Ein 'glücklicherer' Wert für $iFlags wäre meiner Meinung nach deshalb 3.
Moin,
So, mit dem folgenden Code geht es:
Code$Homepage = "https://IP-Adresse If Not ProcessExists("firefox.exe") Then ; Wenn Firefox nicht gestartet ist, starte eine Instanz ShellExecute($Homepage) Else ; Wenn Firefox bereits gestartet ist, starte eine neue Instanz Run("C:\Program Files\Mozilla Firefox\firefox.exe -new-window " & $Homepage) EndIf
Wenn immer Firefox in einem neuen Fenster gestartet werden soll, tut es auch:
Nachschlag für UEZ
DllCall($g_hCairoDLL, "none:cdecl", "cairo_move_to", "ptr", $pSurface, "double", $x, "double", $y)
DllCall($g_hCairoDLL, "none:cdecl", "cairo_line_to", "ptr", $pSurface, "double", $iW, "double", $iH)
DllCall($g_hCairoDLL, "none:cdecl", "cairo_stroke", "ptr", $pContext)
Das kann nicht funktionieren, weil Du versuchst, auf $pSurface zu zeichnen.
Moin,
ich habe mich gestern lange und intensiv mit den Beipielen beschäftigt. Dabei hatte ich immer wieder Rückschläge, die ich mir nicht erklären konnte. Kurz vor dem endgültigem Aufgeben entstand dann aber doch noch eine (überwiegend) funktionierende Lösung. Nach verdienter Nachtruhe habe ich die noch etwas aufgebohrt und bin jetzt recht zufrieden damit.
Ich wollte von vornherein ohne Umwege über Bitmaps/BitBlts direkt mit dem DC arbeiten. Nach vielem Try&Error habe ich dann folgendes in der Cairo-Doku gelesen:
ZitatThe resulting surface will always be of format CAIRO_FORMAT_RGB24; should you need another surface format, you will need to create one through cairo_win32_surface_create_with_format() or cairo_win32_surface_create_with_dib().
Windows unterstützt seit Version 8 nur noch 32-Bit (A)RGB. Das scheint nicht so recht zu cairo_win32_surface_create () passen. Ich habe deshalb für Win 10 die Funktion Cairo_CreateWin32SurfaceWithFormat mit $CAIRO_FORMAT_ARGB32 aufgerufen, und siehe, alles lief deutlich besser. Beim Versuch, ein Control als Zeichenfläche zu nutzen, musste ich zunächst feststellen, dass Cairo den gesamten Clientbereich des Elternfensters übermalt. Die Erklärung fand sich hier:
ZitatThe DC will be queried for its initial clip extents, and this will be used as the size of the cairo surface.
Ich habe einfach mal vermutet, dass da etwas nicht passt, und eine passende Clipping-Region gesetzt. Das hatte tatsächlich den gewünschten Erfolg.
Lange Rede, kurzer Sinn, hier kommt das Ergebnis all meiner Mühe. Es läuft hier stabil mit den DLLs aus dem ersten Beitrag mit 32 und 64 Bit:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPISysWin.au3>
#include "Cairo.au3"
AutoItSetOption('MustDeclareVars', 1)
Global Const $fPi = ACos(-1), $fRad = $fPi / 180, $fDeg = 180 / $fPi, $f2PI = $fPi * 2
Global Const $iW = 600, $iH = 400
Global $sTitle = "Cairo Test (" & (@AutoItX64 ? "64" : "32") & " Bit) / FPS: "
Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit
Global $iRX = 0, $iRY = 0, $iRW = 0, $iRH = 0
Global $iDX = 0, $iDY = 0
Global $sShape = ""
_DrawRectangle()
AutoItSetOption("GUIOnEventMode", 1)
Cairo_Test()
AutoItSetOption("GUIOnEventMode", 0)
Func Cairo_Test()
Cairo_Init()
$hGUI = GUICreate($sTitle & "0", $iW + 20, $iH + 55)
GUICtrlCreateLabel('', 10, 10, $iW, $iH)
Local $hSurface = GUICtrlGetHandle(-1)
GUICtrlCreateButton('Rectangle', 10, $iH + 20, 135)
GUICtrlSetOnEvent(-1, '_DrawRectangle')
GUICtrlCreateButton('Arc', 165, $iH + 20, 135)
GUICtrlSetOnEvent(-1, '_DrawArc')
GUICtrlCreateButton('Line', 320, $iH + 20, 135)
GUICtrlSetOnEvent(-1, '_DrawLine')
GUICtrlCreateButton('Stop', 475, $iH + 20, 135)
GUICtrlSetOnEvent(-1, '_StopDrawing')
Local $hClipRgn = _WinAPI_CreateRectRgn(0, 0, $iW, $iH)
GUISetState(@SW_SHOW, $hGUI)
$bExit = False
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
AdlibRegister("CalcFPS", 1000)
Local $t, $tt = 1 / 60, $x, $y, $c
Local $pSurface = 0, $pContext = 0, $hDC = 0
_SetTimerResolution("Min")
Do
If $sShape = 'Stop' Then ContinueLoop
$c = 0.5 + 0.5 * Sin($t)
; Der von GetDC gelieferte DC hat keine Cipping-Region.
; Für Controls muss deshalb eine passende erstellt werden, damit Cairo die Größe erkennt.
; Ansonsten nimmt Cairo den gesamten Clientbereich des GUI-Fensters.
Local $hDC = _WinAPI_GetDC($hSurface)
_WinAPI_SelectClipRgn($hDC, $hClipRgn)
$pSurface = Cairo_CreateWin32SurfaceWithFormat($hDC)
$pContext = Cairo_CreateContext($pSurface)
Cairo_ClearContext($pContext, $c, $c, $c)
; DllCall($g_hCairoDLL, "none:cdecl", "cairo_set_source_rgba", "ptr", $pContext, "double", 0, "double", 0, "double", 0.5 + 0.5 * Cos($t), "double", 1.0)
DllCall($g_hCairoDLL, "none:cdecl", "cairo_set_source_rgb", "ptr", $pContext, "double", 0, "double", 0, "double", 0.5 + 0.5 * Cos($t))
DllCall($g_hCairoDLL, "none:cdecl", "cairo_set_line_width", "ptr", $pContext, "double", 1)
Switch $sShape
Case 'Rectangle'
DllCall($g_hCairoDLL, "none:cdecl", "cairo_rectangle", "ptr", $pContext, "double", $iRX, "double", $iRY, "double", $iRW, "double", $iRH)
Case 'Arc'
DllCall($g_hCairoDLL, "none:cdecl", "cairo_arc", "ptr", $pContext, "double", $iRX, "double", $iRY, "double", $iRW, "double", 0.0, "double", $f2PI)
DllCall($g_hCairoDLL, "none:cdecl", "cairo_fill", "ptr", $pContext)
Case 'Line'
DllCall($g_hCairoDLL, "none:cdecl", "cairo_move_to", "ptr", $pContext, "double", 0, "double", 0)
DllCall($g_hCairoDLL, "none:cdecl", "cairo_line_to", "ptr", $pContext, "double", $iRW, "double", $iRH)
EndSwitch
DllCall($g_hCairoDLL, "none:cdecl", "cairo_stroke", "ptr", $pContext)
; DllCall($g_hCairoDLL, "none:cdecl", "cairo_flush", "ptr", $pSurface)
Cairo_DestroyContext($pContext)
Cairo_DestroySurface($pSurface)
_WinAPI_ReleaseDC($hSurface, $hDC)
$iRX += $iDX
$iRY += $iDY
Switch $sShape
Case 'Rectangle'
$iRX += $iDX
$iRY += $iDY
If ($iRX < 0) Or ($iRX + $iRW) > $iW Then $iDX *= -1
If ($iRY < 0) Or ($iRY + $iRH) > $iH Then $iDY *= -1
Case 'Arc'
$iRX += $iDX
$iRY += $iDY
If (($iRX - $iRW) < 0) Or (($iRX + $iRW) > $iW) Then $iDX *= -1
If (($iRY - $iRW) < 0) Or (($iRY + $iRW) > $iH) Then $iDY *= -1
Case 'Line'
$iRH += $iDY
If $iRH < 0 Then $iDY *= -1
If $iRH > $iH Then $iDY *= -1
EndSwitch
$t += $tt
$iFPS += 1
If $bExit Then ExitLoop
_SleepXS(4)
Until False
_SetTimerResolution("Def")
_WinAPI_DeleteObject($hClipRgn)
GUIDelete($hGUI)
Cairo_Close()
EndFunc
Func _Exit()
$bExit = True
EndFunc ;==>_Exit
Func CalcFPS() ;display FPS
$iShowFPS = $iFPS
$iFPS = 0
WinSetTitle($hGUI, "", $sTitle & $iShowFPS)
EndFunc ;==>CalcFPS
Func _DrawRectangle()
$sShape = 'Rectangle'
$iRX = 0
$iRY = 0
$iRW = 100
$iRH = 100
$iDX = 1
$iDY = 1
EndFunc
Func _DrawArc()
$sShape = 'Arc'
$iRX = 100
$iRY = 100
$iRW = 50
$iRH = 50
$iDX = 1
$iDY = 1
EndFunc
Func _DrawLine()
$sShape = 'Line'
$iRX = 0
$iRY = 0
$iRW = $iW
$iRH = $iH
$iDX = 1
$iDY = 1
EndFunc
Func _StopDrawing()
$sShape = 'Stop'
EndFunc
Func _SleepXS($iMS)
DllCall("Kernel32.dll", "NONE", "Sleep", "UInt", $iMS)
EndFunc
Func _SetTimerResolution($vRes)
Static $iMax = 0, $iMin = 0, $iDef = 0
Local $aCall = 0
If $iDef = 0 Then
$aCall = DllCall("Ntdll.dll", "BOOL", "NtQueryTimerResolution", "UInt*", $iMax, "UInt*", $iMin, "UInt*", $iDef)
If $aCall[0] = 0 Then
$iMax = $aCall[1]
$iMin = $aCall[2]
$iDef = $aCall[3]
Else
Return SetError(1, 0, 0)
EndIf
EndIf
Switch $vRes
Case "Def"
$vRes = $iDef
Case "Max"
$vRes = $iMax
Case "Min"
$vRes = $iMin
Case Else
If IsNumber($vRes) Then
$vRes *= 10000
If $vRes < $iMin Then $vRes = $iMin
If $vRes > $iMax Then $vRes = $iMax
Else
Return SetError(2, 0, 0)
EndIf
EndSwitch
Return Not DllCall("Ntdll.dll", "BOOL", "NtSetTimerResolution", "UInt", $vRes, "UInt", 1, "UInt*", 0)[0]
EndFunc
Alles anzeigen
Moin UEZ
ich bin nicht sicher, meinst Du so etwas?
#AutoIt3Wrapper_UseX64=n
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIGdi.au3>
#include "Cairo.au3"
AutoItSetOption('MustDeclareVars', 1)
Global Const $fPi = ACos(-1), $fRad = $fPi / 180, $fDeg = 180 / $fPi, $f2PI = $fPi * 2
Global Const $iW = 600, $iH = 400, $sTitle = "Cairo Test / FPS: "
Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit
AutoItSetOption("GUIOnEventMode", 1)
Cairo_Test()
AutoItSetOption("GUIOnEventMode", 0)
Func Cairo_Test()
Cairo_Init()
Local $iStride = Cairo_GetStride($iW)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iStride = ' & $iStride & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
$hGUI = GUICreate($sTitle & "0", $iW, $iH)
Local Const $hDC = _WinAPI_GetDC($hGUI)
;~ Local $tBits = DllStructCreate("long[" & $iStride * $iH & "]")
;~ Local Const $hBitmapGDI = _WinAPI_CreateBitmap($iW, $iH, 1, 32, $tBits)
Local Const $hBitmapGDI = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH)
Local Const $hGfxDC = _WinAPI_CreateCompatibleDC($hDC)
Local Const $hObjOld = _WinAPI_SelectObject($hGfxDC, $hBitmapGDI)
GUISetState(@SW_SHOW, $hGUI)
$bExit = False
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
AdlibRegister("CalcFPS", 1000)
Local $pSurface = Cairo_CreateWin32Surface($hGfxDC)
ConsoleWrite("Surface status: " & DllCall($g_hCairoDLL, "long:cdecl", "cairo_surface_status", "ptr", $pSurface)[0] & @CRLF)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $pSurface = ' & $pSurface & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
Local $pContext = Cairo_CreateContext($pSurface)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $pContext = ' & $pContext & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
ConsoleWrite(DllCall($g_hCairoDLL, "str:cdecl", "cairo_status_to_string")[0] & @CRLF)
Local $t, $tt = 1 / 60, $x, $y, $c
Local $tPAINTSTRUCT
Local $iRX = 0, $iRY = 0, $iRW = 100, $iRH = 100
Do
_WinAPI_BeginPaint($hGUI, $tPAINTSTRUCT)
$c = 0.5 + 0.5 * Sin($t)
Cairo_ClearContext($pContext, $c, $c, $c)
DllCall($g_hCairoDLL, "none:cdecl", "cairo_set_source_rgba", "ptr", $pContext, "double", 0, "double", 0, "double", 0.5 + 0.5 * Cos($t), "double", 1.0)
DllCall($g_hCairoDLL, "none:cdecl", "cairo_set_line_width", "ptr", $pContext, "double", $iH / 10)
; DllCall($g_hCairoDLL, "none:cdecl", "cairo_rectangle", "ptr", $pContext, "double", $iW / 4, "double", $iH / 4, "double", $iW / 2, "double", $iH / 2)
DllCall($g_hCairoDLL, "none:cdecl", "cairo_rectangle", "ptr", $pContext, "double", $iRX, "double", $iRY, "double", $iRW, "double", $iRH)
DllCall($g_hCairoDLL, "none:cdecl", "cairo_stroke", "ptr", $pContext)
$iRX += 1
$iRY += 1
If ($iRX + $iRW) > $iW Then $iRX = 0
If ($iRY + $iRH) > $iH Then $iRY = 0
_WinAPI_EndPaint($hGUI, $tPAINTSTRUCT)
$t += $tt
_WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $SRCCOPY)
$iFPS += 1
If $bExit Then ExitLoop
Until Not Sleep(10)
Cairo_DestroyContext($pContext)
Cairo_DestroySurface($pSurface)
_WinAPI_SelectObject($hGfxDC, $hObjOld)
_WinAPI_ReleaseDC($hGUI, $hDC)
_WinAPI_DeleteDC($hGfxDC)
_WinAPI_DeleteObject($hBitmapGDI)
GUIDelete($hGUI)
Cairo_Close()
EndFunc
Func _Exit()
$bExit = True
EndFunc ;==>_Exit_About
Func CalcFPS() ;display FPS
$iShowFPS = $iFPS
$iFPS = 0
WinSetTitle($hGUI, "", $sTitle & $iShowFPS)
EndFunc ;==>CalcFPS
Alles anzeigen
Moin, noch ein Vorschlag, der allerdings statt der MsgBox einen Taskdialog verwendet:
; ===============================================================================================================================
; TASKDIALOG constants
; https://learn.microsoft.com/en-us/windows/win32/controls/task-dialogs
; ===============================================================================================================================
; TASKDIALOG_FLAGS Note: TASKDIALOG_FLAGS is an int
Global Const $TDF_ENABLE_HYPERLINKS = 0x0001
Global Const $TDF_USE_HICON_MAIN = 0x0002
Global Const $TDF_USE_HICON_FOOTER = 0x0004
Global Const $TDF_ALLOW_DIALOG_CANCELLATION = 0x0008
Global Const $TDF_USE_COMMAND_LINKS = 0x0010
Global Const $TDF_USE_COMMAND_LINKS_NO_ICON = 0x0020
Global Const $TDF_EXPAND_FOOTER_AREA = 0x0040
Global Const $TDF_EXPANDED_BY_DEFAULT = 0x0080
Global Const $TDF_VERIFICATION_FLAG_CHECKED = 0x0100
Global Const $TDF_SHOW_PROGRESS_BAR = 0x0200
Global Const $TDF_SHOW_MARQUEE_PROGRESS_BAR = 0x0400
Global Const $TDF_CALLBACK_TIMER = 0x0800
Global Const $TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000
Global Const $TDF_RTL_LAYOUT = 0x2000
Global Const $TDF_NO_DEFAULT_RADIO_BUTTON = 0x4000
Global Const $TDF_CAN_BE_MINIMIZED = 0x8000
Global Const $TDF_NO_SET_FOREGROUND = 0x00010000 ; Win 8+ -> Don't call SetForegroundWindow() when activating the dialog
Global Const $TDF_SIZE_TO_CONTENT = 0x01000000 ; used by ShellMessageBox to emulate MessageBox sizing behavior
; TASKDIALOG_MESSAGES
Global Const $TDM_NAVIGATE_PAGE = 0x0400 + 101
Global Const $TDM_CLICK_BUTTON = 0x0400 + 102 ;wParam = Button ID
Global Const $TDM_SET_MARQUEE_PROGRESS_BAR = 0x0400 + 103 ; wParam = 0 (nonMarque) wParam != 0 (Marquee)
Global Const $TDM_SET_PROGRESS_BAR_STATE = 0x0400 + 104 ; wParam = new progress state
Global Const $TDM_SET_PROGRESS_BAR_RANGE = 0x0400 + 105 ; lParam = MAKELPARAM(nMinRange, nMaxRange)
Global Const $TDM_SET_PROGRESS_BAR_POS = 0x0400 + 106 ; wParam = new position
Global Const $TDM_SET_PROGRESS_BAR_MARQUEE = 0x0400 + 107 ; wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints)
Global Const $TDM_SET_ELEMENT_TEXT = 0x0400 + 108 ; wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
Global Const $TDM_CLICK_RADIO_BUTTON = 0x0400 + 110 ; wParam = Radio Button ID
Global Const $TDM_ENABLE_BUTTON = 0x0400 + 111 ; lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID
Global Const $TDM_ENABLE_RADIO_BUTTON = 0x0400 + 112 ; lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID
Global Const $TDM_CLICK_VERIFICATION = 0x0400 + 113 ; wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus)
Global Const $TDM_UPDATE_ELEMENT_TEXT = 0x0400 + 114 ; wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
Global Const $TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = 0x0400 + 115 ; wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required)
Global Const $TDM_UPDATE_ICON = 0x0400 + 116 ; wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise)
; TASKDIALOG_NOTIFICATIONS
Global Const $TDN_CREATED = 0
Global Const $TDN_NAVIGATED = 1
Global Const $TDN_BUTTON_CLICKED = 2 ; wParam = Button ID
Global Const $TDN_HYPERLINK_CLICKED = 3 ; lParam = (LPCWSTR)pszHREF
Global Const $TDN_TIMER = 4 ; wParam = Milliseconds since dialog created or timer reset
Global Const $TDN_DESTROYED = 5
Global Const $TDN_RADIO_BUTTON_CLICKED = 6 ; wParam = Radio Button ID
Global Const $TDN_DIALOG_CONSTRUCTED = 7
Global Const $TDN_VERIFICATION_CLICKED = 8 ; wParam = 1 if checkbox checked, 0 if not, lParam is unused and always 0
Global Const $TDN_HELP = 9
Global Const $TDN_EXPANDO_BUTTON_CLICKED = 10 ; wParam = 0 (dialog is now collapsed), wParam != 0 (dialog is now expanded)
; TASKDIALOG_ELEMENTS
Global Enum $TDE_CONTENT, $TDE_EXPANDED_INFORMATION, $TDE_FOOTER, $TDE_MAIN_INSTRUCTION
; TASKDIALOG_ICON_ELEMENTS
Global Enum $TDIE_ICON_MAIN, $TDIE_ICON_FOOTER
; Predefined icons
Global Const $TD_WARNING_ICON = -1
Global Const $TD_ERROR_ICON = -2
Global Const $TD_INFORMATION_ICON = -3
Global Const $TD_SHIELD_ICON = -4
; TASKDIALOG_COMMON_BUTTON_FLAGS Note: TASKDIALOG_COMMON_BUTTON_FLAGS is an int
Global Const $TDCBF_OK_BUTTON = 0x0001 ; selected control return value IDOK
Global Const $TDCBF_YES_BUTTON = 0x0002 ; selected control return value IDYES
Global Const $TDCBF_NO_BUTTON = 0x0004 ; selected control return value IDNO
Global Const $TDCBF_CANCEL_BUTTON = 0x0008 ; selected control return value IDCANCEL
Global Const $TDCBF_RETRY_BUTTON = 0x0010 ; selected control return value IDRETRY
Global Const $TDCBF_CLOSE_BUTTON = 0x0020 ; selected control return value IDCLOSE
; ===============================================================================================================================
; TASKDIALOG structures
; Note: TASKDDIALOG structures are aligned by <pshpack1.h>
; ===============================================================================================================================
; TASKDIALOG_BUTTON structure
; https://learn.microsoft.com/en-us/windows/win32/api/Commctrl/ns-commctrl-taskdialog_button
; ===============================================================================================================================
Global Const $tagTASKDIALOG_BUTTON = "ALIGN 1;INT nButtonID;PTR pszButtonText;"
; ===============================================================================================================================
; TASKDIALOGCONFIG structure
; https://learn.microsoft.com/en-us/windows/win32/api/Commctrl/ns-commctrl-taskdialogconfig
; All string pointers (psz...) point to Unicode strings (WSTR)
; ===============================================================================================================================
Global Const $tagTASKDIALOGCONFIG = "ALIGN 1;" & _
"UINT cbSize;" & _
"HWND hwndParent;" & _
"HANDLE hInstance;" & _
"DWORD dwFlags;" & _
"DWORD dwCommonButtons;" & _
"PTR pszWindowTitle;" & _
"PTR pUnion1;" & _ ; HICON hMainIcon | PCWSTR pszMainIcon
"PTR pszMainInstruction;" & _
"PTR pszContent;" & _
"UINT cButtons;" & _
"PTR pButtons;" & _
"INT nDefaultButton;" & _
"UINT cRadioButtons;" & _
"PTR pRadioButtons;" & _
"INT nDefaultRadioButton;" & _
"PTR pszVerificationText;" & _
"PTR pszExpandedInformation;" & _
"PTR pszExpandedControlText;" & _
"PTR pszCollapsedControlText;" & _
"PTR pUnion2;" & _ ; HICON hFooterIcon | PCWSTR pszFooterIcon
"PTR pszFooter;" & _
"PTR pfCallback;" & _
"LONG_PTR lpCallbackData;" & _
"UINT cxWidth;"
; ===============================================================================================================================
Alles anzeigen
#Include <TaskDialogConstants.au3>
Global $Title = "" ; leer -> Skriptname
Global $Main = "Stammdaten - Auswahl"
Global $Content = "Auswahl für Nr. " & "xxxxxx" & " treffen"
Global $Selection = ["Doku öffnen", "Nr.-Druck", "ERP suchen"]
Global $Btn = 0
Global $SelRB = RadioBox($Main, $Selection, $Btn, -1, $Content, $Title)
MsgBox(0, "Ergebnis", $SelRB >= 0 ? "Deine Auswahl: " & $Selection[$SelRB] : "Keine Auswahl!")
Exit
; ======================================================================================================================
; RadioBox
; Creates a task dialog querying the user to select one of several options with radio buttons.
; Parameters:
; $Main - a string to be used for the main instruction
; $Radios - an array of one or more radio button captions to be used for the selection
; $BtnID - ByRef variable to receive the ID of the pressed common button
; 0 - no button (error)
; 1 - OK button
; 2 - CANCEL button
; $DefRadio - (optional) the default radio button:
; -1 - no default button
; 0 - the first button (default)
; n - the button specified by n
; $Content - (optional) a string to be used for the dialog's primary content.
; Default: "" -> no content
; $Title - (optional) a string to be used for the task dialog title
; Default: "" -> the script's file name
; Return values:
; Returns -1 if an error occurred, the user cancelled the dialog, or no radio button is selected.
; Returns the 0-based index of the selected radio button on success.
; ----------------------------------------------------------------------------------------------------------------------
; TaskDialogIndirect -> https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-taskdialogindirect
; TASKDIALOGCONFIG -> https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-taskdialogconfig
; TASKDIALOG_BUTTON -> https://learn.microsoft.com/en-us/windows/win32/api/Commctrl/ns-commctrl-taskdialog_button
; TDF_SIZE_TO_CONTENT = 0x01000000, TDF_ALLOW_DIALOG_CANCELLATION = 8, TDF_NO_DEFAULT_RADIO_BUTTON = 0x4000
; TDCBF_OK_BUTTON = 1, TDCBF_CANCEL_BUTTON = 8
; ======================================================================================================================
Func RadioBox($Main, $Radios, ByRef $BtnID, $DefRadio = 0, $Content = "", $Title = "")
Static $MinRID = 10 ; minimum radio button ID
$BtnID = 0
If Not IsArray($Radios) Then Return SetError(1, 0, -1)
Local $RadioCount = UBound($Radios)
If Not IsInt($DefRadio) Then Return SetError(2, 0, -1)
If Not ($DefRadio <= $RadioCount) Then Return SetError(3, 0, -1)
$DefRadio += $MinRID
If ($Title = "") Then $Title = @ScriptName
Local $Flags = BitOR(0x01000000, $DefRadio < $MinRID ? 0x00004000 : 0) ; TDF_SIZE_TO_CONTENT, TDF_NO_DEFAULT_RADIO_BUTTON
Local $StrArr[$RadioCount] ; needed to store the captions for the radio buttons
Local $tagBtnArr = "ALIGN 1;"
For $I = 0 To $RadioCount - 1
$tagBtnArr &= "INT;PTR;"
$StrArr[$I] = DllStructCreate("WCHAR[" & (StringLen($Radios[$I]) + 1) & "];")
DllStructsetData($StrArr[$I], 1, $Radios[$I])
Next
Local $tBtnArr = DllStructCreate($tagBtnArr)
Local $J
For $I = 0 To $RadioCount - 1
$J = ($I * 2) + 1
DllStructSetData($tBtnArr, $J, $I + $MinRID)
DllStructSetData($tBtnArr, $J + 1, DllStructGetPtr($StrArr[$I]))
Next
Local $pBtnArr = DllStructGetPtr($tBtnArr)
Local $tMain = DllStructCreate("WCHAR[" & (StringLen($Main) + 1) & "];")
DllStructsetData($tMain, 1, $Main)
Local $pMain = DllStructGetPtr($tMain)
Local $pTitle = 0
If $Title <> "" Then
Local $tTitle = DllStructCreate("WCHAR[" & (StringLen($Title) + 1) & "];")
DllStructsetData($tTitle, 1, $Title)
$pTitle = DllStructGetPtr($tTitle)
EndIf
Local $pContent = 0
If $Content <> "" Then
Local $tContent = DllStructCreate("WCHAR[" & (StringLen($Content) + 1) & "];")
DllStructsetData($tContent, 1, $Content)
$pContent = DllStructGetPtr($tContent)
EndIf
; TASKDIALOGCONFIG structure
Local $tTDC = DllStructCreate($tagTASKDIALOGCONFIG)
DllStructSetData($tTDC, "cbSize", DllStructGetSize($tTDC))
DllStructSetData($tTDC, "hwndParent", 0)
DllStructSetData($tTDC, "dwFlags", $Flags)
DllStructSetData($tTDC, "dwCommonButtons", 9)
DllStructSetData($tTDC, "pszWindowTitle", $pTitle)
DllStructSetData($tTDC, "pszMainInstruction", $pMain)
DllStructSetData($tTDC, "pszContent", $pContent)
DllStructSetData($tTDC, "cRadioButtons", $RadioCount)
DllStructSetData($tTDC, "pRadioButtons", $pBtnArr)
DllStructSetData($tTDC, "nDefaultRadioButton", $DefRadio > $MinRID ? $DefRadio : 0)
Local $pTDC = DllStructGetPtr($tTDC)
Local $RID = 0 ; ID of the selected radio button
Local $aCall = DllCall("Comctl32.dll", "UInt", "TaskDialogIndirect", "PTR", $pTDC, "INT*", $BtnID, "INT*", $RID, "PTR", 0)
$BtnID = $aCall[2]
Select
Case @Error Or ($aCall[0] <> 0)
Return SetError(3, 0, -1)
Case $aCall[3] = 0
Return -1
Case $aCall[2] <> 1
Return -1
Case Else
Return $aCall[3] - $MinRID
EndSelect
EndFunc
Alles anzeigen
Vielleicht gefällt es dir ?
Moin hipfzwirgel,
@ Velted: beim Abbruch stand immer die Zahl 1 in der Variable drin. Da er beim D bereits ausgestiegen ist.
Ich habe nach dem Inhalt der Variablen $tKEYHOOKS.vkCode gefragt. Ich glaube nicht, dass die mit Inhalt 1 zum Abbruch führt. Aber ...
Ich glaube wir können das Thema nun als erledigt betrachten, da das Problem ja ohnehin schon gelöst ist.
Danke für die Info.
Was steht denn beim Abbruch mit dem NFC-Leser in $tKEYHOOKS.vkCode?
Moin,
Global $sHex = "1D70536A031080"
Global $sRev = ""
Global $iPos = 14 - 1
While $iPos > 0
$sRev &= StringMid($sHex, $iPos, 2)
$iPos -= 2
Wend
Global $iSNR = Dec($sRev, 2)
MsgBox(0, "SN", "Hex: " & $sHex & @LF & "Rev: " & $sRev & @LF & "Dez: " & $iSNR)
ZitatAlles anzeigen---------------------------
SN
---------------------------
Hex: 1D70536A031080
Rev: 8010036A53701D
Dez: 36046403873763357
---------------------------
OK
---------------------------
?
Moin, auch wenn ich die auf Spiele ausgerichteten Skripte nicht gern unterstütze: Ich kann Dein Problem nicht finden.
Du verwaltest eine "bisherige Gesamtspielzeit" in der Registrierung. Die kannst Du beim Start des Skripts einlesen. Sie kann sich nicht verändern.
Das Skript startet das Spiel. Du musst Dir also nur einmal den Startzeitpunkt merken.
Wenn Du auf "Aktuelle Spielzeit" drückst, musst Du die Differenz zur Startzeit berechnen. Wie Du sagst, klappt das bereits.
Wenn Du auf "Aktuelle Gesamtzeit" drückst, musst Du die "Aktuelle Spielzeit" berechnen und den beim Start des Skripts eingelesenen Wert aus der Registrierung addieren.
Wenn das Spiel (btw. das Skript?) beendet wird, musst Du die "Aktuelle Spielzeit" berechnen, den beim Start des Skripts eingelesenen Wert aus der Registrierung addieren und das Ergebnis in die Registrierung zurückschreiben.
Wo klemmt es?
Moin,
ob mit oder ohne Webdriver, für mich ist noch offen, wann und wie auf F9/F10 reagiert werden soll.
In den bisher eingestellten Beispielen wird der aktuelle Schleifendurchlauf 'in aller Ruhe' beendet. Das ursprüngliche Beispiel aus Beitrag #1 enthält mehrfach
Das könnte dann schon ein Weilchen dauern, bis das 'Durchschalten' durch die Dashboards beendet wird.
DivineFaith, soll das so sein? Wenn nicht, was genau soll geschehen?
Moin,
... Diese Website hat mehrere Dashboards, welche ich mit einem ganz einfachem Autoit Skript, mit hilfe von einfachen MouseMove und MouseClick befehlen durchschalte. Dies funktioniert auch ohne Probleme.
Wie Moombas schon sagte, wenn es ohne Probleme funktioniert, muss es im Original deutlich anders aussehen. Beruhen die Fehler im eingestellten Beispiel auf mangelnder Erfahrung mit AutoIt oder sind die Auslassungen gewollt?
(#Persistent erinnert mich stark an AutoHotkey).
ich beschäftige mich auch noch mit AHK. Ich kann Dir versichern, dass es nicht am Control liegt.
Auf der Suche nach 'künstlichen' Verzögerungen bin ich vorhin auf Folgendes gestoßen:
ZitatOpt WinWaitDelay
Alters how long a script should briefly pause after a successful window-related operation.
Time in milliseconds to pause (default=250).
Das ist doch wohl auch nicht mehr ernst gemeint. Oder arbeiten mit AutoIt nur Menschen, deren Rechner ständig am Anschlag laufen?
auch mit dem AdlibRegister()läuft das hier nur dann stabil, wenn der time Parameter mit dem Defaultwert (250 ms) arbeitet oder auf mindestens 200 ms gesetzt wird. Im Jahre 2024 ist das für einen normalen Computer eine kleine Ewigkeit. Ich kann mir das nicht erklären und gehe mal von einem Bug aus.
Moin,
hier (Win 10 - AutoIt 3.3.16.1) zeigt sich exakt das beschriebene Verhalten:
Beim ersten Klick auf den Button bleiben die Ränder des Edits als weiße Linien im Label sichtbar. Wenn ich das Edit vorher disable, braucht es ein Sleep() von mindestens 140 ms, damit die Ränder nicht mehr durchschlagen. Für mich läuft da etwas mit stark angezogener Handbremse.
#include-once
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
Opt("MustDeclareVars", 1)
Global $idBtn_Anzeigen, $idEdiText, $hGUI_Hauptfenster, $GUI_Msg, $idLbl_Wartehinweis
; Das Fenster des GUI erstellen.
$hGUI_Hauptfenster = GUICreate("TEST TEST TEST", 830, 185, -1, -1)
GUISetBkColor(0x3680FF)
; Das Textfenster (Edit-Control) erstellen.
$idEdiText = GUICtrlCreateEdit("", 30, 30, 768, 40, BitOR($ES_CENTER, $ES_MULTILINE))
; Das Label mit dem Wartehinweis erstellen.
$idLbl_Wartehinweis = GUICtrlCreateLabel("", 214, 23, 372, 89)
GUICtrlSetBkColor(-1, 0x707070)
GUICtrlSetState(-1, $GUI_HIDE)
$idBtn_Anzeigen = GUICtrlCreateButton("Label anzeigen.", 250, 128, 310, 40, BitOR($SS_CENTER, $BS_PUSHLIKE))
GUICtrlSetFont(-1, 12, 400, 0, "Tahoma")
GUICtrlSetBkColor(-1, 0x00FF00)
GUISetState(@SW_SHOW, $hGUI_Hauptfenster)
While 1
$GUI_Msg = GUIGetMsg()
Switch $GUI_Msg
Case $GUI_EVENT_CLOSE ; Symbol <Fenster schließen>
GUIDelete($hGUI_Hauptfenster)
ExitLoop
Case $idBtn_Anzeigen ; Button <Label anzeigen.>
; Das Label für den Wartehinweis anzeigen.
GUICtrlSetState($idEdiText, $GUI_DISABLE)
Sleep(140)
GUICtrlSetState($idLbl_Wartehinweis, $GUI_SHOW)
;GUICtrlSetState($idEdiText, $GUI_HIDE)
EndSwitch
WEnd
Exit
Alles anzeigen
Ich möchte ein Fenster mit Daten ohne Buttons anzeigen und wenn man irgendwo ins Fenster klickt, sollen die Buttons erscheinen - also vorher versteckt. Und auf Klick auf einen Button sollen diese wieder ausgeblendet werden. Geht das?
Moin,
das ließe sich eventuell auch mit einem Contextmenü -> GUICtrlCreateContextMenu mit wenig Aufwand lösen.
Moin,
ich finde funkey's StringInStr() Lösung sehr gut, weil sie der Funktion von StringReplace() sehr nahe kommt. Ich hatte das verworfen, weil mir nicht eingefallen ist, dass der zweite Parameter von StringReplace() auch eine Positionsangabe sein kann.
Wenn es aber eine StringSplit() basierte Lösung sein soll, bevorzuge ich meine in Beitrag #5 vorgeschlagene Variante, weil sie ressourcenschonender ist, wenn der String nicht ausschließlich aus dem zu ersetzenden Zeichen besteht.
Local $sString = "1234567890123456789012345678901234567890123456789012345678901"
Local $sSearch = "1" ; gesuchtes Zeichen
Local $aRepl[4] = ["1", "a", "j", "t"] ; Ersetzungszeichen
Local $sInStr = _StringReplaceRandom1($sString, $sSearch, $aRepl)
Local $sSplit = _StringReplaceRandom2($sString, $sSearch, $aRepl)
MsgBox(0, "Result", "Original:" & @CRLF & $sString & @CRLF & _
"StringInStr:" & @CRLF & $sInStr & @CRLF & _
"StringSplit:" & @CRLF & $sSplit)
Func _StringReplaceRandom1($sString, $sSearch, $aRepl)
Local $iMax = UBound($aRepl) - 1, $iPos = 0
DO
$iPos = StringInStr($sString, $sSearch, 0, 1, $iPos + 1)
If $iPos Then $sString = StringReplace($sString, $iPos, $aRepl[Random(0, $iMax, 1)], 1)
Until $iPos = 0
Return $sString
EndFunc
Func _StringReplaceRandom2($sString, $sSearch, $aRepl)
Local $iMax = UBound($aRepl) - 1, $sOut = ""
Local $aSplit = StringSplit($sString, $sSearch, 3)
For $sSplit In $aSplit
$sOut &= $aRepl[Random(0, $iMax, 1)] & $sSplit
Next
Return StringTrimLeft($sOut, 1)
EndFunc
Alles anzeigen
Guten Rutsch!