Hallo zusammen,
ich habe folgendes Sript erstellt. Dort möchte ich erreichen, dass sich ein Fenster nach einer gewissen, durch eine Variable definierte Zeit, schließt.
Nach mehreren Tests habe ich herausgefunden, dass der Timer nicht auf die Funktion zugreifen kan bzw. die Funktion an den Problemen schuld ist. Ich wollte mit dem Timer eine zweite Funktion aufrufen, die eine Variable verändert. Die erste Funktion, in der sich der Timer befindet, testet per Schleife, ob die Variable den Wert enthält und wenn ja, schließt sie das Fenster.
Gibt es evtl. auch die Möglichkeit, dass man, sollte dies alles nicht klappen, man die Fensterschließung per Timer auch ohne zusätzliche Funktion erreicht?
Noch eine Anmerkung: Das Sript ist so ausgelegt, dass es in ein anderes eingebunden werden muss (durch den include-Befehl). Habe noch ein zweites Sript angehängt, mit dem ich teste, ob die Einbindung klappt bzw. das Sript überhaupt geht...
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]AutoIt Version: 3.3.2.0
Author: Florian Kurrle
Sript Version: 2.1
Version: 1.0-The important changes
2.0-English is mainlanguage and icons are included
Script Function:
Creates a Window, where you can enter a PIN with your mouse and which can output the PIN as variable
Syntax: _PIN_Win([left[, top[, timeout]]])
timeout = the time to close the window in milliseconds
Return values: Success 1
Failure 0 and set @error to 1. This can happend only when passing wrong parameters.
Usage: #include <PIN_Fenster.au3> (when it's in the stadart include-path)
#include "path\PIN_Fenster.au3" (when it isn't in the standart include-path)
$_PIN is the entered PIN
When you press the E-button, you delete the entered PIN
When you press the C-butto, you confirm the entered PIN
#ce ----------------------------------------------------------------------------
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#Include <Timers.au3>
#include-once
;Declares the PIN and the exit-var
Global $_PIN, $_Exit, $TimeID
#Region GUI/Func
Func _PIN_Win($left = -1, $top = -1, $timeout = "", $_Exit = 0)
If Not IsNumber($timeout) Or $timeout < 0 Then Return SetError(1, 0, 0)
If $left < -1 Or $top < -1 Then Return SetError(1, 0, 0)
Local $btn, $msg, $btn1, $btn2, $btn3, $btn4, $btn5, $btn6, $btn7, $btn8, $btn9, $btn0, $E, $OldCoord, $hGUI
$OldCoord = Opt("GUICoordMode", 0)
$_PIN = "" ;PIN is deleting
$_Exit = 0
$hGUI = GUICreate("", 109.5, 148, $left, $top)
$_IDD = _Timer_SetTimer($hGUI, $timeout, "_PIN_Exit", -1); The timer is starting
$TimeID = _Timer_GetTimerID($_IDD);;;; ---Für Testzwecke
MsgBox(0, $_IDD, $TimeID) ;;;; ---Für Testzwecke
;Button1
$btn1 = GUICtrlCreateButton("", -1, -1, 37, 37, 0x0040)
GUICtrlSetImage(-1, "../Images/_1.ico")
;Button2
$btn2 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
GUICtrlSetImage(-1, "../Images/_2.ico")
;Button3
$btn3 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
GUICtrlSetImage(-1, "../Images/_3.ico")
;Button4
$btn4 = GUICtrlCreateButton("", -74, 37, 37, 37, 0x0040)
GUICtrlSetImage(-1, "../Images/_4.ico")
;Button5
$btn5 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
GUICtrlSetImage(-1, "../Images/_5.ico")
;Button6
$btn6 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
GUICtrlSetImage(-1, "../Images/_6.ico")
;Button7
$btn7 = GUICtrlCreateButton("", -74, 37, 37, 37, 0x0040)
GUICtrlSetImage(-1, "../Images/_7.ico")
;Button8
$btn8 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
GUICtrlSetImage(-1, "../Images/_8.ico")
;Button9
$btn9 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
GUICtrlSetImage(-1, "../Images/_9.ico")
;Button0
$E = GUICtrlCreateButton("", -74, 37, 37, 37, 0x0040)
GUICtrlSetImage(-1, "../Images/_E.ico")
;E-Button
$btn0 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
GUICtrlSetImage(-1, "../Images/_0.ico")
;C-Button (OK-Button)
$btn = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
GUICtrlSetImage(-1, "../Images/_C.ico")
GUISetState()
;Check which buttons are pressed and react proportionally
$msg = 0
While 1
$msg = GUIGetMsg()
If $msg == $GUI_EVENT_CLOSE Then Exit
Select
Case $msg = $btn
ExitLoop
Case $msg = $btn1
$_PIN &= 1
Case $msg = $btn2
$_PIN &= 2
Case $msg = $btn3
$_PIN &= 3
Case $msg = $btn4
$_PIN &= 4
Case $msg = $btn5
$_PIN &= 5
Case $msg = $btn6
$_PIN &= 6
Case $msg = $btn7
$_PIN &= 7
Case $msg = $btn8
$_PIN &= 8
Case $msg = $btn9
$_PIN &= 9
Case $msg = $btn0
$_PIN &= 0
Case $msg = $E
$_PIN = ""
Case $_Exit = 1
ExitLoop
EndSelect
WEnd
GUIDelete()
Opt("GUICoordMode", $OldCoord)
EndFunc
Func _PIN_Exit(ByRef $_Exit)
$_Exit = 1
EndFunc
#EndRegion GUI/Func
Sript, in welches das vorherige beispielsweise eingebunden wird:
Spoiler anzeigen
#include "..\PINPad.au3"
_PIN_Win(100, 300, 1000);The window is 100 pixels left and 300 pixels top
MsgBox(64, "", $_PIN) ;output the entered PIN
[/autoit]Vielen Dank schonmal!
LG FKFK