MP3 rein, Netzwerk aus, hat jemand eine Ahnung? (Titel editiert)

  • hallo leute bald weihnachten , :thumbup:

    habe eine frage an euch kann man vielleicht mit autoit ein programm schreiben womit wenn man mpr3player im usbpot steckt, dass das netzwerk automatisch aus geht?? ?(

    hat jemand eine ahnung wie man das schreibt?? ?(

    Vilen dank für jede antwort!!!!! ;) :D

    Edit GtaSpider: Da hat wohl jemand die Feststelltaste vergessen beim Titelschreiben ;) Es bringt nichts wenn du den Titel großschreibst, dir wird dadurch nicht schneller geholfen.

    Einmal editiert, zuletzt von GtaSpider (22. Dezember 2008 um 14:40)

  • Hab mal ein paar Skripte kombiniert und das ist dabei herausgekommen:

    Quellen: Desktopsperre - USB-Stick zum ent-/sperren des Desktop
    NetworkConnection ---> http://www.autoitscript.com/forum/index.php?showtopic=71925&view=findpost&p=525659


    Spoiler anzeigen
    [autoit]

    ;~ _RegID()
    ;~ Exit

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

    Global Const $WM_DEVICECHANGE = 0x0219
    Global $USB_ID = 'USB\Vid_0d7d&Pid_1400\07450E6000DD' ;hier die ID eintragen, die RegID ausgibt!

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

    GUICreate("USB-Netzwerk-Deaktivierer")
    GUIRegisterMsg($WM_DEVICECHANGE, 'MY_WM_DEVICECHANGE')

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

    HotKeySet('!q', '_Ende')

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

    While 1
    Sleep(500)
    WEnd

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

    Func MY_WM_DEVICECHANGE($hWnd, $Msg, $wParam, $lParam)
    If _USB_mounted($USB_ID) Then
    _LAN_Connection(0)
    Else
    _LAN_Connection(1)
    EndIf
    EndFunc ;==>MY_WM_DEVICECHANGE

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

    Func _USB_mounted($Serial)
    For $count = 0 To RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usbstor\Enum', 'count') -1
    If $Serial = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usbstor\Enum', $count) Then Return 1
    Next
    Return 0
    EndFunc ;==>_USB_mounted

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

    ; From: http://www.autoitscript.com/forum/index.ph…ndpost&p=525659
    ; Modifiziert: funkey
    Func _LAN_Connection($Toggle, $sConnectionName = "LAN-Verbindung", $sNetworkFolder = "Netzwerkverbindungen")
    $ssfCONTROLS = 3
    $sEnableVerb = "&Aktivieren"
    $sDisableVerb = "&Deaktivieren"
    $shellApp = ObjCreate("shell.application")
    $oControlPanel = $shellApp.Namespace($ssfCONTROLS)
    $oNetConnections = "nothing"

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

    For $folderitem In $oControlPanel.items
    If $folderitem.name = $sNetworkFolder Then
    $oNetConnections = $folderitem.getfolder
    ExitLoop
    EndIf
    Next
    If $oNetConnections = "nothing" Then
    ;~ MsgBox(48, "Error", "Couldn't find " & $sNetworkFolder & " folder")
    Return SetError(1, 0, 0)
    EndIf

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

    $oLanConnection = "nothing"
    For $folderitem In $oNetConnections.items
    If StringLower($folderitem.name) = StringLower($sConnectionName) Then
    $oLanConnection = $folderitem
    ExitLoop
    EndIf
    Next
    If $oLanConnection = "nothing" Then
    ;~ MsgBox(48, "Error", "Couldn't find '" & $sConnectionName & "' item")
    Return SetError(2, 0, 0)
    EndIf

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

    $bEnabled = True
    $oEnableVerb = "nothing"
    $oDisableVerb = "nothing"
    $s = "Verbs: " & @CRLF
    For $verb In $oLanConnection.verbs
    $s = $s & @CRLF & $verb.name

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

    ;enables
    If $verb.name = $sEnableVerb And $Toggle = 1 Then
    $oEnableVerb = $verb
    $oEnableVerb.DoIt
    ExitLoop

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

    ;disables
    ElseIf $verb.name = $sDisableVerb And $Toggle = 0 Then
    $oDisableVerb = $verb
    $oDisableVerb.DoIt
    ExitLoop
    Else
    ;~ MsgBox(48, "Error", "Tried to disable when already disabled" & @CRLF & "or enable when already enabled")
    Return SetError(3, 0, 0)
    EndIf
    Next
    Sleep(1000)
    EndFunc ;==>_LAN_Connection

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

    Func _RegID()
    MsgBox(0, "", 'Falls der USB-Stick momentan eingesteckt ist,' & @CRLF & 'bitte entfernen und dann auf [Ok] klicken!')
    $count = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usbstor\Enum', 'count')
    MsgBox(0, "", 'Bitte jetzt den USB-Stick einstecken!' & @CRLF & 'Er wird automatisch erkannt.', 5)
    While RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usbstor\Enum', 'count') = $count
    Sleep(100)
    WEnd
    $count = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usbstor\Enum', 'count')
    $sID = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usbstor\Enum', $count - 1)
    ConsoleWrite(@CRLF & $sID & @CRLF)
    MsgBox(0, "", 'Dieser USB-Stick ist nun zum ent-/sperren des Desktop registriert!', 5)
    EndFunc ;==>_RegID

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

    Func _Ende()
    Exit
    EndFunc ;==>_Ende

    [/autoit]

    Edit: Registry-Schlüssel von ControlSet001 auf CurrentControlSet geändert.

  • Vielen vielen dank :rock: :D :D :P der schnellen antwort echt super :thumbup: von dir
    aber wo muss ich das srip einfügen damit es immer funkt??

  • Vielen vielen dank :rock: :D :D :P der schnellen antwort echt super :thumbup: von dir
    aber wo muss ich das srip einfügen damit es immer funkt??

    vielleicht am einfachsten in den Autostart Ordner kopieren oder zumindest einen Link zum Programm ?!? :huh:
    wenn das gemeint ist ?(

    ---
    In "Independence Day" konnten die Windows-Erdcomputer problemlos mit denen der Außerirdischen kommunizieren. Was sagt uns das über unseren lieben Bill Gates? :D
    ---

  • erstmals danke für die ganze hilfe die ich bekomme!! ;) :D
    meine frage war nur ob ich den skrip in ein bestimmten ordner einfügen sollte :)
    dann hätte ich noch eine frage wie sinde ich die id vom usb pot?? ?( ?( (ich weiß mit autoit info aber wo soll ich drauf) ?(