GUI vor Controlclicks schützen

  • Hallo,

    ich hab mal eben eine kleine Funktion erstellt. Vielleicht kann es ja jemand gebrauchen

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $Form1 = GUICreate("Form1", 213, 69, 192, 124)
    $Button1 = GUICtrlCreateButton("Button1", 128, 8, 75, 25, $WS_GROUP)
    $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 8, 8, 97, 17)
    $Label1 = GUICtrlCreateLabel("Label1", 8, 40, 36, 17)
    $Radio1 = GUICtrlCreateRadio("Radio1", 88, 40, 113, 17)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Case $Button1
    If _IsPressedByMouse($Form1, $Button1) = True Then MsgBox(0, "", "Ja")

    [/autoit] [autoit][/autoit] [autoit]

    Case $Checkbox1
    If _IsPressedByMouse($Form1, $Checkbox1) = True Then MsgBox(0, "", "Ja")

    [/autoit] [autoit][/autoit] [autoit]

    Case $Label1
    If _IsPressedByMouse($Form1, $Label1) = True Then MsgBox(0, "", "Ja")

    [/autoit] [autoit][/autoit] [autoit]

    Case $Radio1
    If _IsPressedByMouse($Form1, $Radio1) = True Then MsgBox(0, "", "Ja")

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _IsPressedByMouse($GUIHandle, $ControlHandle)
    $GCursoInfo = GUIGetCursorInfo($GUIHandle)
    If IsArray($GCursoInfo) Then
    If $ControlHandle = $GCursoInfo[4] Then
    Return True
    EndIf
    Return False
    Else
    Return SetError(1)
    EndIf
    EndFunc ;==>_IsPressedByMouse

    [/autoit]
  • Hmm man kann aber nur einen Input als Passworteingabe erstellen. Bei klick auf einem Button wird das dann überprüft.
    Aber das ist auch oft bei Antivirenprogrammen so. Ich nehme mal Kaspersky als Beispiel. Mit AutoIt hast du damit KEINEN Zugriff auf einem Control. Nicht mal aufm Traymenü. Wie machen die das eig? Mit Treibern oder wie?


    Edit:

    Hi, ich hab mal ein kleines Beispielscript erstellt. Vielleicht kann man es noch verbessern :)

    Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $Form1 = GUICreate("Form1", 139, 62)
    $Label1 = GUICtrlCreateLabel("Gib bitte 'Hallo' ein.", 8, 8, 125, 17)
    $Input1 = GUICtrlCreateInput("", 8, 32, 121, 21)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    ControlFocus($Form1, "", $Label1)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Case $Input1
    If ControlGetFocus($Form1) = "Edit1" And WinGetTitle("") = "Form1" Then
    If GUICtrlRead($Input1) = "Hallo" Then
    MsgBox(0, "", "Ohne Controlclick etc. Super!!!")
    Exit
    EndIf
    Else
    MsgBox(0, "", "Bitte kein Control* nutzen!")
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _IsPressedByMouse($GUIHandle, $ControlHandle)
    $GCursoInfo = GUIGetCursorInfo($GUIHandle)
    If IsArray($GCursoInfo) Then
    If $ControlHandle = $GCursoInfo[4] Then
    Return True
    EndIf
    Return False
    Else
    Return SetError(1)
    EndIf
    EndFunc ;==>_IsPressedByMouse

    [/autoit]
  • Gute idee! Alledrings hilft das doch nicht gegen controlsettext

    Ja ich frag mich auch ganz oft wie kaspersky mache sachen macht! Z.B. das er immer erkennt wenn man eine Datei öffnet du die voher überprüft und wenn es ein virus ist das öffnen verhindert oder das man den Prozess nicht einfach beenden kann, dann sthet da ja immer "Zugriff verweigert"

    mfg. Jam00