1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. nuts

Beiträge von nuts

  • TCP Send / Recv

    • nuts
    • 1. April 2011 um 12:57

    Hallo zusammen,


    ich möchte im Netzwerk eine Kommunikation zwischen 2 Rechnern ermöglichen.
    Beide PC's sollen dabei sowohl Nachrichten empfangen alsauch senden können.

    Ich hab mir dazu mal die TCP-Funktionen angesehen und diese etwas umgebaut.

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>

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

    Opt('MustDeclareVars', 1)

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

    ;==============================================
    ;==============================================
    ;SERVER!! Start Me First !!!!!!!!!!!!!!!
    ;==============================================
    ;==============================================

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

    Global $IP=@IPAddress1
    Global $Port=33891

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

    HotKeySet("{F2}", "_Send")
    HotKeySet("{F3}", "_Exit")

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

    Example()

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

    func _exit()
    ConsoleWrite("exit" &@crlf)
    exit
    endfunc

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

    func _send()
    ; Set Some reusable info
    ;--------------------------
    Local $ConnectedSocket, $szData
    ; Set $szIPADDRESS to wherever the SERVER is. We will change a PC name into an IP Address
    ; Local $szServerPC = @ComputerName
    ; Local $szIPADDRESS = TCPNameToIP($szServerPC)
    Local $nPORT = 33892

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

    ; Start The TCP Services
    ;==============================================
    TCPStartup()

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

    ; Initialize a variable to represent a connection
    ;==============================================
    $ConnectedSocket = -1

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

    ;Attempt to connect to SERVER at its IP and PORT 33891
    ;=======================================================
    $ConnectedSocket = TCPConnect($IP, $nPORT)

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

    ; If there is an error... show it
    If @error Then
    MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error)
    ; If there is no error loop an inputbox for data
    ; to send to the SERVER.
    Else

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

    $szData = InputBox("Ich bin Server 1", @LF & @LF & "Enter data to transmit to the SERVER 2:")
    If @error Or $szData = "" Then Return

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

    TCPSend($ConnectedSocket, $szData)
    EndIf

    endfunc

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

    Func Example()
    ; Set Some reusable info
    ; Set your Public IP address (@IPAddress1) here.
    ; Local $szServerPC = @ComputerName
    ; Local $szIPADDRESS = TCPNameToIP($szServerPC)
    Local $szIPADDRESS = @IPAddress1
    Local $nPORT = 33891
    Local $MainSocket, $GOOEY, $edit, $ConnectedSocket, $szIP_Accepted
    Local $msg, $recv

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

    ; Start The TCP Services
    ;==============================================
    TCPStartup()

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

    ; Create a Listening "SOCKET".
    ; Using your IP Address and Port 33891.
    ;==============================================
    $MainSocket = TCPListen($szIPADDRESS, $nPORT)

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

    ; If the Socket creation fails, exit.
    If $MainSocket = -1 Then Exit

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

    ; Create a GUI for messages
    ;==============================================
    $GOOEY = GUICreate("My Server 1 (IP: " & $szIPADDRESS & ")", 300, 200)
    $edit = GUICtrlCreateEdit("", 10, 10, 280, 180)
    GUISetState()

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

    ; Initialize a variable to represent a connection
    ;==============================================
    $ConnectedSocket = -1

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

    ;Wait for and Accept a connection
    ;==============================================
    Do
    $ConnectedSocket = TCPAccept($MainSocket)
    Until $ConnectedSocket <> -1

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

    ; Get IP of client connecting
    $szIP_Accepted = SocketToIP($ConnectedSocket)

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

    ; GUI Message Loop
    ;==============================================
    While 1
    $msg = GUIGetMsg()

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

    ; GUI Closed
    ;--------------------
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop

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

    ; Try to receive (up to) 2048 bytes
    ;----------------------------------------------------------------
    $recv = TCPRecv($ConnectedSocket, 2048)

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

    ; If the receive failed with @error then the socket has disconnected
    ;----------------------------------------------------------------
    If @error Then ExitLoop

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

    ; Update the edit control with what we have received
    ;----------------------------------------------------------------
    If $recv <> "" Then
    GUICtrlSetData($edit, $szIP_Accepted & " > " & $recv & @CRLF & GUICtrlRead($edit))
    _Send()
    endif

    WEnd

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

    If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)

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

    TCPShutdown()
    EndFunc ;==>Example

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

    ; Function to return IP Address from a connected socket.
    ;----------------------------------------------------------------------
    Func SocketToIP($SHOCKET)
    Local $sockaddr, $aRet

    $sockaddr = DllStructCreate("short;ushort;uint;char[8]")

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

    $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _
    "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr))
    If Not @error And $aRet[0] = 0 Then
    $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3))
    If Not @error Then $aRet = $aRet[0]
    Else
    $aRet = 0
    EndIf

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

    $sockaddr = 0

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

    Return $aRet
    EndFunc ;==>SocketToIP

    [/autoit]
    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>

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

    Opt('MustDeclareVars', 1)

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

    Global $IP=@IPAddress1
    Global $Port=33891

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

    HotKeySet("{F2}", "_Send")
    HotKeySet("{F3}", "_Exit")

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

    _send()
    Example()

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

    func _exit()
    exit
    endfunc

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

    func _send()
    ; Set Some reusable info
    ;--------------------------
    Local $ConnectedSocket, $szData
    ; Set $szIPADDRESS to wherever the SERVER is. We will change a PC name into an IP Address
    ; Local $szServerPC = @ComputerName
    ; Local $szIPADDRESS = TCPNameToIP($szServerPC)

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

    ; Start The TCP Services
    ;==============================================
    TCPStartup()

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

    ; Initialize a variable to represent a connection
    ;==============================================
    $ConnectedSocket = -1

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

    ;Attempt to connect to SERVER at its IP and PORT 33891
    ;=======================================================
    $ConnectedSocket = TCPConnect($IP, $PORT)

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

    ; If there is an error... show it
    If @error Then
    MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error)
    ; If there is no error loop an inputbox for data
    ; to send to the SERVER.
    Else

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

    $szData = InputBox("Ich bin Server2", @LF & @LF & "Enter data to transmit to the SERVER 1:")
    If @error Or $szData = "" Then Return

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

    TCPSend($ConnectedSocket, $szData)
    EndIf

    endfunc

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

    Example()

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

    Func Example()
    ; Set Some reusable info
    ; Set your Public IP address (@IPAddress1) here.
    ; Local $szServerPC = @ComputerName
    ; Local $szIPADDRESS = TCPNameToIP($szServerPC)
    Local $szIPADDRESS = @IPAddress1
    Local $nPORT = 33892
    Local $MainSocket, $GOOEY, $edit, $ConnectedSocket, $szIP_Accepted
    Local $msg, $recv

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

    ; Start The TCP Services
    ;==============================================
    TCPStartup()

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

    ; Create a Listening "SOCKET".
    ; Using your IP Address and Port 33891.
    ;==============================================
    $MainSocket = TCPListen($szIPADDRESS, $nPORT)

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

    ; If the Socket creation fails, exit.
    If $MainSocket = -1 Then Exit

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

    ; Create a GUI for messages
    ;==============================================
    $GOOEY = GUICreate("My Server 2(IP: " & $szIPADDRESS & ")", 300, 200)
    $edit = GUICtrlCreateEdit("", 10, 10, 280, 180)
    GUISetState()

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

    ; Initialize a variable to represent a connection
    ;==============================================
    $ConnectedSocket = -1

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

    ;Wait for and Accept a connection
    ;==============================================
    Do
    $ConnectedSocket = TCPAccept($MainSocket)
    Until $ConnectedSocket <> -1

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

    ; Get IP of client connecting
    $szIP_Accepted = SocketToIP($ConnectedSocket)

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

    ; GUI Message Loop
    ;==============================================
    While 1
    $msg = GUIGetMsg()

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

    ; GUI Closed
    ;--------------------
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop

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

    ; Try to receive (up to) 2048 bytes
    ;----------------------------------------------------------------
    $recv = TCPRecv($ConnectedSocket, 2048)

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

    ; If the receive failed with @error then the socket has disconnected
    ;----------------------------------------------------------------
    If @error Then ExitLoop

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

    ; Update the edit control with what we have received
    ;----------------------------------------------------------------
    If $recv <> "" Then
    GUICtrlSetData($edit, $szIP_Accepted & " > " & $recv & @CRLF & GUICtrlRead($edit))
    _Send()
    endif
    WEnd

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

    If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)

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

    TCPShutdown()
    EndFunc ;==>Example

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

    ; Function to return IP Address from a connected socket.
    ;----------------------------------------------------------------------
    Func SocketToIP($SHOCKET)
    Local $sockaddr, $aRet

    $sockaddr = DllStructCreate("short;ushort;uint;char[8]")

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

    $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _
    "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr))
    If Not @error And $aRet[0] = 0 Then
    $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3))
    If Not @error Then $aRet = $aRet[0]
    Else
    $aRet = 0
    EndIf

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

    $sockaddr = 0

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

    Return $aRet
    EndFunc ;==>SocketToIP

    [/autoit]

    Es scheint zu funktionieren, allerdings nur genau einmal :(
    Worin liegt mein Denkfehler?

    Gruß nuts

    P.S. Danke schonmal für die Antworten

  • SuperMario Gameplay und Download

    • nuts
    • 5. Februar 2011 um 05:11

    Naja als Mitentwickler war der post jetzt nicht "soooo" unangebracht.
    Wieso hier jetzt jeder zweite Post gemaßregelt werden muss verstehe ich nicht!

  • Offizielles AutoIt Pokerstars Turnier (15.02.2011)

    • nuts
    • 3. Februar 2011 um 00:52

    Ich bin auch dabei. :thumbup:

  • Was genau ist eigentlich "BitOr"?

    • nuts
    • 14. Januar 2011 um 14:50
    [autoit]

    Läuft das etwa über BitAnd?

    [/autoit]


    Genau.

    Hier mal ein einfaches Beispiel (hat Bugfix so ähnlich imho mal irgendwo gepostet)

    [autoit]


    Dim $count
    $test = BitOR(1,2,4)
    ConsoleWrite($test&@CRLF)
    For $i = 2 To 0 Step -1
    $count = BitAND($test, 2 ^ $i)
    If $count Then
    ConsoleWrite($count & @CRLF)
    EndIf
    Next

    [/autoit]
  • Devcon - Unverständliche Rückgabeparamter

    • nuts
    • 14. Januar 2011 um 14:40

    Ich hab mal versucht diese Vorgehensweise in eine allgemeine Funktion zu packen:

    Spoiler anzeigen
    [autoit]


    Func _RunEx($sCmd, $iflag = 7)
    ; eukalyptus
    ; mod. nuts
    ;
    ; $iflag 1 => return Exitcode (String)
    ; $iflag 2 => return StdoutRead (String)
    ; $iflag 4 => return StderrRead (String)
    ; $iflag 7 (default) => return Exitcode & StdoutRead & StderrRead (Array)
    ; $iflag 3 return Exitcode & StdoutRead (Array)
    ; $iflag 5 return Exitcode & StderrRead (Array)
    ; $iflag 6 return StdoutRead & StderrRead (Array)

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

    Local $sErr = "", $sOut = ""
    Local $hPID = Run($sCmd, @SystemDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD))

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

    Local $hProc = _WinAPI_OpenProcess(0x0400, 0, $hPID)
    While 1
    $sOut &= StdoutRead($hPID)
    If @error Then ExitLoop
    WEnd
    While 1
    $sErr &= StderrRead($hPID)
    If @error Then ExitLoop
    WEnd
    Local $aexit = DllCall("kernel32", "hwnd", "GetExitCodeProcess", "handle", $hProc, "dword*", 0)
    If @error Or Not IsArray($aexit) Then
    _WinAPI_CloseHandle($hProc)
    Return SetError(1, 0, False)
    EndIf
    _WinAPI_CloseHandle($hProc)

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

    Switch $iflag
    Case 7
    Return StringSplit($sOut & "|" & $sErr & "|" & $aexit[2], "|")
    Case 1
    Return $aexit[2]
    Case 2
    Return $sOut
    Case 4
    Return $sErr
    Case 3
    Return StringSplit($aexit[2] & "|" & $sOut, "|")
    Case 5
    Return StringSplit($aexit[2] & "|" & $sErr, "|")
    Case 6
    Return StringSplit($sOut & "|" & $sErr, "|")
    EndSwitch

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

    EndFunc ;==>_RunEx

    [/autoit]
  • Devcon - Unverständliche Rückgabeparamter

    • nuts
    • 14. Januar 2011 um 01:22

    Sau stark!
    Das scheint zu klappen :)

    Danke!

  • Devcon - Unverständliche Rückgabeparamter

    • nuts
    • 14. Januar 2011 um 00:46

    Wirklich elegant ist das echt nicht mehr (aber trotzdem danke).

    Hier gibts noch was über die winapi:
    http://www.autoitscript.com/forum/topic/17…code-and-stdio/

    Die dort angesprochene Möglichkeit den stdout in eine datei umzuleiten ist mir aber ohne .bat nicht möglich :(

  • Devcon - Unverständliche Rückgabeparamter

    • nuts
    • 14. Januar 2011 um 00:06

    Mhm ganz so einfach ists wohl doch nicht.
    Mit Runwait bekomme ich den Exitcode verliere aber die Rückmeldung von StdoutRead :(

    Zitat

    StdOut in eine Datei umlenken " > Log.txt"


    Wie geht das denn genau?

  • String in String löschen

    • nuts
    • 13. Januar 2011 um 14:48

    "ABC|QWERTZ|LOLWUT|ASDF|BAUM"

    soll zu

    "ABC|QWERTZ|LOLWUT|BAUM"

    werden?

  • Devcon - Unverständliche Rückgabeparamter

    • nuts
    • 13. Januar 2011 um 12:23
    Zitat von eukalyptus

    aber du könntest RunWait verwenden


    So gehts - danke :D

  • Devcon - Unverständliche Rückgabeparamter

    • nuts
    • 13. Januar 2011 um 11:58

    Geht es auch mit dem parameter restart?
    Die Nachricht, dass ein Neustart nötig ist kommt z.B. wenn die Hardware in Benutzung ist.
    Ich nehm dazu die Soundkarte und spiele ein mp3 ab.

    Das funktioniert bei mir nämlich dann nicht :(


    P.S: Vielleicht ganz interessant: devcon basiert scheinbar auf der setupAPI
    http://msdn.microsoft.com/en-us/library/ff550855.aspx


    Edit\
    Nach deiner Variante bekommt man aber auch nicht den Exitcode :?:

  • Devcon - Unverständliche Rückgabeparamter

    • nuts
    • 13. Januar 2011 um 10:44

    Genau so ists bei mir auch :(

    Also ein Bug oder wir verstehen das nicht richtig. ?(

  • Devcon - Unverständliche Rückgabeparamter

    • nuts
    • 13. Januar 2011 um 10:29

    Hm ich verstehs nicht ganz :(
    Den Stdout bekommen ich doch schon?

  • Devcon - Unverständliche Rückgabeparamter

    • nuts
    • 13. Januar 2011 um 10:05

    Hm?
    Nee DVB-S Hardware 8)

    Mit BitOR($STDOUT_CHILD, $STDERR_CHILD) gehts leider auch nicht ($STDOUT_CHILD+ $STDERR_CHILD wie in der Hilfe beschrieben klappt auch nicht).

    [autoit]


    $run = Run($devcon & ' restart ' & $ID, @SystemDir, @SW_HIDE,BitOR($STDOUT_CHILD, $STDERR_CHILD)) ; refresh
    While 1
    $msg_err &= StderrRead($run, true)
    If @error Then ExitLoop
    WEnd
    While 1
    $msg &= StdoutRead($run)
    If @error Then ExitLoop
    WEnd
    If $writelog Then _FileWriteLog($ci_log, 'Devcon return Message: ' &StringReplace($msg, @cr, @LF), 1)
    If $writelog Then _FileWriteLog($ci_log, 'Devcon return Error: ' & $msg_err, 1)

    [/autoit]

    So sieht das .log aus.

    Code
    2011-01-13 10:00:56 : Devcon return Error: 
    2011-01-13 10:00:56 : Devcon return Message: HDAUDIO\FUNC_01&VEN_10EC&DEV_0272&SUBSYS_15580771&REV_1000\4&1ABBB45C&0&0001: Requires reboot
    
    
    Not all of 1 device(s) restarted, at least one requires reboot to complete the operation.


    Bei einem angeforderten reboot müsste laut Doku doch eine 1 zurückgegeben werden? ?(

  • Devcon - Unverständliche Rückgabeparamter

    • nuts
    • 12. Januar 2011 um 23:07

    Ich formuliere die Frage mal um:

    Weiss jemand wie man den Fehlerstatus von devcon auslesen kann?
    s. hier unter Hinweise: http://support.microsoft.com/kb/311272

    so gings leider nicht:

    [autoit]


    $run = Run($devcon & ' restart ' & $ID, @SystemDir, @SW_HIDE, $STDERR_MERGED) ; refresh
    While 1
    $msg_err &= StderrRead($run)
    If @error Then ExitLoop
    WEnd
    While 1
    $msg &= StdoutRead($run)
    If @error Then ExitLoop
    WEnd
    If $writelog Then _FileWriteLog($ci_log, 'Devcon return Message: ' &StringReplace($msg, @cr, @LF), 1)
    If $writelog Then _FileWriteLog($ci_log, 'Devcon return Error: ' & $msg_err, 1)

    [/autoit]
  • WinXP - Wie lange sollte der AutoIt Support noch gehen?

    • nuts
    • 12. Januar 2011 um 18:36
    Zitat von Raupi


    Was mir auffällt ist, das Win7 sehr viel Fehlertolleranter ist als WinXP. Quellcodes die auf Win7 einwandfrei laufen,
    müssen bei WinXp umständlich angepaßt werden um einwandfrei zu laufen. Das komische daran ist, das diese Anpassungen
    sogar richtig sind, aber Win7 die Fehler ignoriert oder gar ausbessert. Stellt sich also die Frage was man will, richtigen Code
    schreiben, oder einfach hinnehmen das Win7 es nicht so genau nimmt?


    Kannst du dafür mal ein Beispiel machen?


    @topic:
    Die Skripte für die Arbeit laufen alle @WinXP, da sie auch darunter geschrieben wurden. Das bleibt so bis mind. Ende 2012 (geplanter Wechsel auf Win7).
    Die privaten Skripte sind mittlerweile @Win7 geschrieben, allerdings hat sich bis jetzt noch keiner mit WinXP beschwert.
    Ich prüfe auch nicht ob ein Skript unter XP läuft. Sollte es doch mal Probleme geben kommt es eben darauf an ob ich Zeit, Lust und das Know-how habe das Skript WinXP fähig zu machen.

  • Devcon - Unverständliche Rückgabeparamter

    • nuts
    • 12. Januar 2011 um 13:24

    Hallo zusammen,


    ich hab ein Skirpt um via devcon bestimmte Hardware zu reseten.
    Dabei verwende ich die Parameter: "diabale & enable" oder "restart" (Problem besteht bei beiden Möglichkeiten)

    Spoiler anzeigen
    [autoit]

    Func _Devcon($aID, $mode)
    If Not FileExists($devcon) Then
    If $writelog Then _FileWriteLog($ci_log, 'Devcon.exe nicht gefunden - Programm beendet', 1)
    _Exit()
    EndIf
    Local $ID, $run, $msg
    Switch $mode
    Case 1

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

    For $i = 1 To $aID[0][0]
    $ID = "@" & $aID[$i][1]
    $run = Run($devcon & ' restart ' & $ID, @SystemDir, @SW_HIDE, $STDOUT_CHILD) ; refresh
    While 1
    $msg &= StdoutRead($run)
    If @error Then ExitLoop
    WEnd
    If $writelog Then _FileWriteLog($ci_log, 'Devcon return Message: ' & $msg, 1)
    Sleep(1000) ;1 Sekunde warten
    $msg = ''
    Next

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

    Case 0
    For $i = 1 To $aID[0][0]
    $ID = "@" & $aID[$i][1]
    $run = Run($devcon & ' disable ' & $ID, @SystemDir, @SW_HIDE, $STDOUT_CHILD) ; deaktivieren
    While 1
    $msg &= StdoutRead($run)
    If @error Then ExitLoop
    WEnd
    If $writelog Then _FileWriteLog($ci_log, 'Devcon return Message: ' & $msg, 1)

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

    Sleep(4000) ;4 Sekunden warten

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

    $run = Run($devcon & ' enable ' & $ID, @SystemDir, @SW_HIDE, $STDOUT_CHILD) ; aktivieren
    $msg = ""
    While 1
    $msg &= StdoutRead($run)
    If @error Then ExitLoop
    WEnd
    If $writelog Then _FileWriteLog($ci_log, 'Devcon return Message: ' & $msg, 1)
    Sleep(1000) ;1 Sekunde warten
    $msg = ''
    Next
    EndSwitch

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

    EndFunc ;==>_Devcon

    [/autoit]

    Manchmal kommt es jedoch vor, dass Devcon einen reboot vom System anfordert.
    Die Rückgabenachricht sieht dann so aus:

    Code
    PCI\VEN_18C3&DEV_0720&SUBSYS_DD0018C3&REV_01\4&3694E160&0&00A9: Disabled on reboot
    The 1 device(s) are ready to be disabled. To disable the devices, restart the
    
    
    devices or reboot the system


    Ein wirkliches Muster kann ich nicht erkennen. Das Problem tritt auch relativ selten auf. :S
    Welche Gründe kann es dafür geben?

    Gruß nuts

  • Mainboard für mittelgroßen Homeserver

    • nuts
    • 11. Januar 2011 um 18:03

    Beim NT kannste noch etwas sparen: http://geizhals.at/deutschland/a543091.html
    Sollte ITX nicht Pflicht sein könnte man beim Mainboard und Gehäuse auch noch was machen.

  • Globale Variablen - besser vermeiden

    • nuts
    • 4. Januar 2011 um 01:37

    Hm ok.
    Das ist imho doch eher Standard (keine globale vars in UDF's usw.)

    Aber wie macht ihr das dann z.B. mit einer aufwendigen Main GUI?

  • Globale Variablen - besser vermeiden

    • nuts
    • 3. Januar 2011 um 13:16
    Zitat von floschlo

    In C++ , sollte man Globals aber vermeiden, darum beziehe ich den Beitrag einfach mal auf C++. . .


    FLOSCHLO


    Gibts dazu auch eine plausible Begründung?

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™