Überprüfen, ob Joystick, Maus o.ä. angeschlossen wurde

  • Hi, gibt es eine Möglichkeit, zu überprüfen, ob ein Joystick, eine Maus (also Geräte, die keinen Laufwerksbuchstaben besitzen) o.ä. angeschlossen wurde? Mit USB-Sticks kann man das ja z.B. so machen:

    [autoit]

    $a = Drivegetserial ("E:\")
    ; irgendein Code
    ; ...
    ; ...
    If Drivegetserial ("E:\") = $a Then
    ; weiß ich, dass mein Stick angeschlossen wurde.

    [/autoit]
  • MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    ein paar Infos ...

    Wer mehr als "nur" Hilfe benötigt, kann sich gern im Forum "Programmieranfragen" an uns wenden. Wir helfen in allen Fällen, die die Forenregeln zulassen.

    Für schnelle Hilfe benötigen wir ein ! lauffähiges ! Script, dass wir als Demonstration des Problems testen können. Wer von uns erwartet ein Teilscript erstmal lauffähig zu bekommen, der hat
    1. keine wirkliche Not
    2. keinen Respekt vor Menschen die ihm in ihrer Freizeit Ihre Hilfe anbieten
    3. oder ist einfach nur faul und meint wir coden das für ihn

    In solchen Fällen erlaube ich mir, die Anfrage einfach zu ignorieren. ;)

  • Eventuell kannst du das auch über die Registry abfragen: HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USB
    Dort werden alle per USB angeschlossenen Werte gespeichert. Bin mir aber gerade nicht sicher, ob sich die Schlüsselwerte ändern, wenn du das USB gerät ein-/aussteckst.

  • Dashier hilft dir evtl zum Überprüfen des Joysticks:

    Spoiler anzeigen
    [autoit]

    ;____________________________________________________________________
    ; Original program by Ejoc ;
    ; Improved by Adam1213 (autoit 3.2 compatiblity + improved labels ;
    ;____________________________________________________________________

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

    #include <GUIConstants.au3>

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

    ;_________________ SETUP_____________________________________
    Local $joy,$coor,$h,$s,$msg

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

    $joy = _JoyInit()

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

    dim $labels_text[8]=['X', 'Y', 'Z', 'R', 'U', 'V', 'POV', 'Buttons']
    dim $labels_no=UBound($labels_text)
    dim $labels[$labels_no]
    dim $labels_value[$labels_no]
    ;__________ CONFIG ____________________________________________
    ;---------- Find the max length of the longest label --------------
    $label_len=0
    for $text in $labels_text
    $len=stringlen($text)
    if $len>$label_len then
    $label_len=$len
    endif
    next
    $label_len*=6
    ;_____________ GUI _______________________________________________
    GUICreate('Joystick Test', 200, 200)
    GUICtrlCreateLabel('Joystick', 40, 20, 100, 20)

    for $i=0 to $labels_no-1
    GuiCtrlCreatelabel($labels_text[$i]&':', 10, 60+$i*12, $label_len, 12)
    $labels[$i]=GuiCtrlCreatelabel('', 10+$label_len, 60+$i*12, 70, 12)
    $labels_value[$i]=''
    next
    GUISetState()
    ;_____________________________________________________________________

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

    while 1
    $coord=_GetJoy($joy,0)
    for $i=0 to UBound($coord)-1
    if $coord[$i]<>$labels_value[$i] then
    GUICtrlSetData($labels[$i], $coord[$i])
    $labels_value[$i]=$coord[$i]
    endif
    next
    sleep(10)
    $msg =GUIGetMSG()
    if $msg = $GUI_EVENT_CLOSE Then Exitloop
    WEnd

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

    $lpJoy=0 ; Joyclose

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

    ;======================================
    ; _JoyInit()
    ;======================================
    Func _JoyInit()
    Local $joy
    Global $JOYINFOEX_struct = "dword[13]"

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

    $joy=DllStructCreate($JOYINFOEX_struct)
    if @error Then Return 0
    DllStructSetData($joy, 1, DllStructGetSize($joy), 1);dwSize = sizeof(struct)
    DllStructSetData($joy, 1, 255, 2) ;dwFlags = GetAll
    return $joy
    EndFunc

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

    ;======================================
    ; _GetJoy($lpJoy,$iJoy)
    ; $lpJoy Return from _JoyInit()
    ; $iJoy Joystick # 0-15
    ; Return Array containing X-Pos, Y-Pos, Z-Pos, R-Pos, U-Pos, V-Pos,POV
    ; Buttons down
    ;
    ; *POV This is a digital game pad, not analog joystick
    ; 65535 = Not pressed
    ; 0 = U
    ; 4500 = UR
    ; 9000 = R
    ; Goes around clockwise increasing 4500 for each position
    ;======================================
    Func _GetJoy($lpJoy,$iJoy)
    Local $coor,$ret

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

    Dim $coor[8]
    DllCall("Winmm.dll","int","joyGetPosEx", _
    "int",$iJoy, _
    "ptr",DllStructGetPtr($lpJoy))

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

    if Not @error Then
    $coor[0] = DllStructGetData($lpJoy,1,3)
    $coor[1] = DllStructGetData($lpJoy,1,4)
    $coor[2] = DllStructGetData($lpJoy,1,5)
    $coor[3] = DllStructGetData($lpJoy,1,6)
    $coor[4] = DllStructGetData($lpJoy,1,7)
    $coor[5] = DllStructGetData($lpJoy,1,8)
    $coor[6] = DllStructGetData($lpJoy,1,11)
    $coor[7] = DllStructGetData($lpJoy,1,9)
    EndIf

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

    return $coor
    EndFunc

    [/autoit]

    mfg BB

    "IF YOU'RE GOING TO KILL IT
    OPEN SOURCE IT!"

    by Phillip Torrone

    Zitat von Shoutbox

    [Heute, 11:16] Andy: ....böseböseböseböse....da erinnere ich mich daran, dass man den Puschelschwanz eines KaRnickels auch "Blume" nennt....ob da eins zum anderen passt? :rofl: :rofl: :rofl: :rofl:

    https://autoit.de/index.php?page…leIt#post251138

    Neon Snake

  • Schnuffel: Damit geht das anscheinend - aber ich möchte es ja in AutoIt verwirklichen.
    Scritch: He, danke, da lässt sich bestimmt etwas draus machen.
    @BB: Das habe ich auch schon gefunden, ich weiß aber nicht recht, wie ich meine Idee damit umsetzen soll.

  • Zitat

    ich weiß aber nicht recht, wie ich meine Idee damit umsetzen soll.

    Was ist denn Deine Idee?
    Vielleicht gibt es ja dann eher einen Ansatz ...

    MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    ein paar Infos ...

    Wer mehr als "nur" Hilfe benötigt, kann sich gern im Forum "Programmieranfragen" an uns wenden. Wir helfen in allen Fällen, die die Forenregeln zulassen.

    Für schnelle Hilfe benötigen wir ein ! lauffähiges ! Script, dass wir als Demonstration des Problems testen können. Wer von uns erwartet ein Teilscript erstmal lauffähig zu bekommen, der hat
    1. keine wirkliche Not
    2. keinen Respekt vor Menschen die ihm in ihrer Freizeit Ihre Hilfe anbieten
    3. oder ist einfach nur faul und meint wir coden das für ihn

    In solchen Fällen erlaube ich mir, die Anfrage einfach zu ignorieren. ;)