[strike]
hallo ihr lieben,
ich schreibe mir immoment ein kleines script und habe ein paar probleme dabei ein nicht klickbares overlay zu erstellen auf dem durch einen hotkey ein countdown timer erstellt wird, der nach ablauf des timers wieder verschindet.
mein code bisher:
Spoiler anzeigen
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
HotKeySet("{NUMPAD0}", "d")
HotKeySet("{NUMPAD9}", "On_Exit")
Global $TimeLabel, $_Seconds, $TimeTicks, $_SecCalc, $_Countdown, $SS_CENTER, $hGUI, $aRadio[5], $hButton, $res, $d_timer, $x_pos_d, $y_pos_d
$hGUI = GUICreate("LJT", 150, 190)
$x_pos_b = 100
$y_pos_b = 100
; gui zum auswählen einer bildschirmauflösung (der timer soll später an eine feste stelle auf dem desktop kommen und bei veränderter auflösung auch noch richtig platziert werden -> damit ich das script auch auf meinem laptop nutzen kann :))))->
[/autoit] [autoit][/autoit] [autoit]GUICtrlCreateLabel("Choose your resolution", 10, 10, 150, 20)
[/autoit] [autoit][/autoit] [autoit]GUIStartGroup()
For $i = 0 To 4
Local $res[5] = ["2560 x 1440", "1920 x 1080", "1600 x 900", "1280 x 720", "1024 x 768"]
$aRadio[$i] = GUICtrlCreateRadio($res[$i], 55, 30 + ($i * 20), 100, 20)
Next
GUICtrlSetState($aRadio[0], $GUI_CHECKED)
$hButton = GUICtrlCreateButton("Start Timer", 35, 150, 80, 30)
[/autoit] [autoit][/autoit] [autoit]GUISetState()
[/autoit] [autoit][/autoit] [autoit]While 1
[/autoit] [autoit][/autoit] [autoit]Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $hButton
GUISetState(@SW_HIDE, $hGUI)
For $i = 0 To 4
If GUICtrlRead($aRadio[$i]) = 1 Then
$res = $i
ExitLoop
EndIf
Next
Timer()
EndSwitch
WEnd
[/autoit] [autoit][/autoit] [autoit]; gui timer auf dem nicht klickbarem overlay->
[/autoit] [autoit][/autoit] [autoit]Func Timer()
Local $hRectangle_GUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
Local $hMaster_Mask = _WinAPI_CreateRectRgn(0, 0, 0, 0)
$TimeLabel = GUICtrlCreateLabel ( "", $x_pos_b, $y_pos_b, 100, 50, $SS_CENTER )
GUICtrlSetFont ( -1, 8, 200 )
_WinAPI_SetWindowRgn($hRectangle_GUI, $hMaster_Mask)
GUISetState()
EndFunc
; countdown checkfunktion berechnet die sekunden und alarmiert bei 20/1 sekunde/n->
[/autoit] [autoit][/autoit] [autoit]Func _Check ()
$_Countdown -= TimerDiff ( $TimeTicks )
$TimeTicks = TimerInit ( )
$_SecCalc = Int ( $_Countdown / 1000 )
If $_SecCalc <= 0 Then
GUICtrlSetData ( $TimeLabel, "" )
Else
If $_SecCalc <> $_Seconds Then
$_Seconds = $_SecCalc
GUICtrlSetData ( $TimeLabel, StringFormat ("u", $_Seconds ) )
If $_Seconds = 20 or $_Seconds = 1 Then
Beep ( 1200, 100 )
EndIf
EndIf
EndIf
EndFunc
; d funktion setzt die countdownzeit und statet den countdown->
[/autoit] [autoit][/autoit] [autoit]Func d()
$d_timer = 360000
$_Countdown = $d_timer
$TimeTicks = TimerInit ()
While 1
_Check()
Sleep (200)
WEnd
EndFunc
Func On_Exit()
[/autoit] [autoit][/autoit] [autoit]Exit
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit]wie ihr sicher gemerkt habt bin ich mit gui's noch nicht so bewandert
[/strike]
UPDATE + updated code:
nachdem in einer gui die bildschirmauflösung ausgewählt wurde, sollen
auf knopfdruck in einem "durchklickbaren" und transparentem overlay
Countdowntimer erstellt werden die von z.b. 300 sek bis 0 zählen und bei
20 sek und 1 sek einen warnton abgeben. Bei 0 sekunden soll der timer
wieder verschwinden.
-> soweit funktioniert der code auch [unterschiedliche koordinaten je
nach auflösung sind noch nicht vergeben worden, aber an dieser stelle
erstmal auch nicht nötig (das auswahlfenster am anfang ist somit auch immoment noch sinnfrei)]
Das problem: es können zwar alle 6 timer gestartet werden, aber visuell
werden nur die änderungen von dem zuletzt geklickten timer angezeigt.
(-> anscheinend kann autoit funktionen in meinem skript nicht 6 mal parallel laufen lassen)
hat da jemand von euch eine elegante lösung?
auch generell andere anmerkungen/verbesserungsvorschläge zum code sind erwünscht
Spoiler anzeigen
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
HotKeySet("{NUMPADDOT}", "b")
HotKeySet("{NUMPAD0}", "d")
HotKeySet("{NUMPAD1}", "o_b")
HotKeySet("{NUMPAD3}", "t_b")
HotKeySet("{NUMPAD4}", "o_r")
HotKeySet("{NUMPAD6}", "t_r")
HotKeySet("{NUMPAD9}", "On_Exit")
Global $SS_CENTER, $hGUI, $aRadio[5], $hButton, $res
Global $TimeLabel_d, $TimeLabel_b, $TimeLabel_ob, $TimeLabel_or, $TimeLabel_tb, $TimeLabel_tr, $TimeLabel
Global $TimeTicks_d, $TimeTicks_b, $TimeTicks_ob, $TimeTicks_or, $TimeTicks_tb, $TimeTicks_tr, $TimeTicks
Global $_SecCalc_d, $_SecCalc_b, $_SecCalc_ob, $_SecCalc_or, $_SecCalc_tb, $_SecCalc_tr, $_SecCalc
Global $_Seconds_d, $_Seconds_b, $_Seconds_ob, $_Seconds_or, $_Seconds_tb, $_Seconds_tr, $_Seconds
Global $x_pos_b, $y_pos_b, $x_pos_d, $y_pos_d, $x_pos_ob, $y_pos_ob, $x_pos_or, $y_pos_or, $x_pos_tb, $y_pos_tb, $x_pos_tr, $y_pos_tr
$hGUI = GUICreate("LJT", 150, 190)
[/autoit] [autoit][/autoit] [autoit]$x_pos_d = 1825
$y_pos_d = 990
$x_pos_b = 1738
$y_pos_b = 884
$x_pos_ob = 1720
$y_pos_ob = 929
$x_pos_or = 1788
$y_pos_or = 996
$x_pos_tb = 1842
$y_pos_tb = 945
$x_pos_tr = 1772
$y_pos_tr = 877
GUICtrlCreateLabel("Choose your resolution", 10, 10, 150, 20)
[/autoit] [autoit][/autoit] [autoit]GUIStartGroup()
For $i = 0 To 4
Local $res[5] = ["2560 x 1440", "1920 x 1080", "1600 x 900", "1280 x 720", "1024 x 768"]
$aRadio[$i] = GUICtrlCreateRadio($res[$i], 55, 30 + ($i * 20), 100, 20)
Next
GUICtrlSetState($aRadio[0], $GUI_CHECKED)
$hButton = GUICtrlCreateButton("Start Overlay", 35, 150, 80, 30)
[/autoit] [autoit][/autoit] [autoit]GUISetState()
[/autoit] [autoit][/autoit] [autoit]While 1
[/autoit] [autoit][/autoit] [autoit]Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $hButton
GUISetState(@SW_HIDE, $hGUI)
For $i = 0 To 4
If GUICtrlRead($aRadio[$i]) = 1 Then
$res = $i
ExitLoop
EndIf
Next
Timer()
EndSwitch
WEnd
[/autoit] [autoit][/autoit] [autoit]; -------------
[/autoit] [autoit][/autoit] [autoit]Func Timer()
Local $hRectangle_GUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST + $WS_EX_LAYERED + $WS_EX_TRANSPARENT)
Local $hMaster_Mask = _WinAPI_CreateRectRgn(0, 0, @DesktopWidth, @DesktopHeight)
$TimeLabel_d = GUICtrlCreateLabel ( "", $x_pos_d, $y_pos_d, 20, 15, $SS_CENTER )
$TimeLabel_b = GUICtrlCreateLabel ( "", $x_pos_b, $y_pos_b, 20, 15, $SS_CENTER )
$TimeLabel_ob = GUICtrlCreateLabel ( "", $x_pos_ob, $y_pos_ob, 20, 15, $SS_CENTER )
$TimeLabel_or = GUICtrlCreateLabel ( "", $x_pos_or, $y_pos_or, 20, 15, $SS_CENTER )
$TimeLabel_tb = GUICtrlCreateLabel ( "", $x_pos_tb, $y_pos_tb, 20, 15, $SS_CENTER )
$TimeLabel_tr = GUICtrlCreateLabel ( "", $x_pos_tr, $y_pos_tr, 20, 15, $SS_CENTER )
GUISetFont ( -1, 8, 200 )
GuiCtrlSetColor($TimeLabel_d, 0xFF00FF)
GuiCtrlSetColor($TimeLabel_b, 0xFF00FF)
GuiCtrlSetColor($TimeLabel_ob, 0x0000FF)
GuiCtrlSetColor($TimeLabel_or, 0xFF0000)
GuiCtrlSetColor($TimeLabel_tb, 0x0000FF)
GuiCtrlSetColor($TimeLabel_tr, 0xFF0000)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($hRectangle_GUI, 0xABCDEF, 255)
GUISetState()
EndFunc
Func _Check ($timer, $TimeTicks, $TimeLabel, $_SecCalc, $_Seconds)
$timer -= TimerDiff ( $TimeTicks )
$TimeTicks = TimerInit ( )
$_SecCalc = Int ( $timer / 1000 )
If $_SecCalc <= 0 Then
GUICtrlSetData ( $TimeLabel, "" )
Else
If $_SecCalc <> $_Seconds Then
$_Seconds = $_SecCalc
GUICtrlSetData ( $TimeLabel, StringFormat ("%02u", $_Seconds ) )
If $_Seconds = 20 or $_Seconds = 1 Then
Beep ( 1200, 100 )
EndIf
EndIf
EndIf
EndFunc
Func d()
$d_timer = 360000
$TimeTicks_d = TimerInit ()
While 1
_Check($d_timer, $TimeTicks_d, $TimeLabel_d, $_SecCalc_d, $_Seconds_d)
Sleep (200)
WEnd
EndFunc
Func b()
$b_timer = 420000
$TimeTicks_b = TimerInit ()
While 1
_Check($b_timer, $TimeTicks_b, $TimeLabel_b, $_SecCalc_b, $_Seconds_b)
Sleep (200)
WEnd
EndFunc
Func o_b()
$ob_timer = 300000
$TimeTicks_ob = TimerInit ()
While 1
_Check($ob_timer, $TimeTicks_ob, $TimeLabel_ob, $_SecCalc_ob, $_Seconds_ob)
Sleep (200)
WEnd
EndFunc
Func o_r()
$or_timer = 300000
$TimeTicks_or = TimerInit ()
While 1
_Check($or_timer, $TimeTicks_or, $TimeLabel_or, $_SecCalc_or, $_Seconds_or)
Sleep (200)
WEnd
EndFunc
Func t_b()
$tb_timer = 300000
$TimeTicks_tb = TimerInit ()
While 1
_Check($tb_timer, $TimeTicks_tb, $TimeLabel_tb, $_SecCalc_tb, $_Seconds_tb)
Sleep (200)
WEnd
EndFunc
Func t_r()
$tr_timer = 300000
$TimeTicks_tr = TimerInit ()
While 1
_Check($tr_timer, $TimeTicks_tr, $TimeLabel_tr, $_SecCalc_tr, $_Seconds_tr)
Sleep (200)
WEnd
EndFunc
Func On_Exit()
[/autoit] [autoit][/autoit] [autoit]Exit
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit]viele grüße