Chat: Nachricht an alle Server schicken ?!?

  • 1. Subnetz anpingen, so dass du alle PCs erhältst.
    2. In Forschleife befehle senden

    zu 1. ja hab ich mit [ gelöst ] alle computer im netz auflisten

    zu2. genau da ischs problem. hab das komplette client script in ne schleife gepackt:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <array.au3>
    #include <_PingAll.au3>
    #include <INet.au3>
    #include <ArrayMore.au3>
    ;$IP = @IPAddress1
    ;MsgBox ("","","Die Server-Ip ist: " & $IP )
    ClipPut(@IPAddress1)
    $aPingAll = _PingAll(20, 50, "", "", "", "", "", 0, 0, 0, 0, 0, 5, " ", "1", "0", 0, 0)
    ;_PingAll($ipstart, $ipend, $iprange = "", $port01 = "", $port02 = "", $port03 = "", $port04 = "",
    ;$radim = 0, $winxp = 1, $vnc = 1, $ShowName = 1, $ShowMac = 1, $dealy = 100, $slash = "|", $yes = 1, $no = 0, $showprog = 1, $showbevore = 1)
    _Array2DEmptyDel($aPingAll,0) ;_Array2DEmptyDel(ByRef $avArray [, $Col=0])
    _ArrayDelete($aPingAll, 0); Erstes Element aus dem Array löschen
    $sUbound = (UBound($aPingAll) -1)
    if $aPingAll[$sUbound] = "" then _ArrayDelete($aPingAll,($sUbound))
    ;_ArrayDisplay($aPingAll, "ipadress gesamt")

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

    for $x =0 to UBound($aPingAll) -1 ;
    $IP = $aPingAll[$x]
    ;MsgBox("","$IP",$IP)

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

    $Port = 31758
    $ConnectedSocket = TCPConnect($IP, $Port)
    If $ConnectedSocket = -1 Then
    MsgBox(16, "Error", "Es ist bei dem Verbindungsversuch ein Fehler aufgetreten, vermutlich ist kein Server gestartet!")
    Exit
    EndIf
    call ("_senden")
    ;HotKeySet("^s", "_Senden") ; ctrg + s
    While 1
    $Empfang = TCPRecv($ConnectedSocket, 9999)
    If $Empfang <> "" Then
    MsgBox(0, "Nachricht", $Empfang)
    EndIf
    Sleep(500)
    WEnd
    Func _Senden()
    $Nachricht = InputBox("Nachricht senden Client", "Schreibe deine Nachricht")
    If $Nachricht <> "" Then
    TCPSend($ConnectedSocket, $Nachricht)
    EndIf
    EndFunc ;==>_Senden

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

    next

    [/autoit]
  • also ich möchte das dieser teil des scripts mehrmals wiederholt wird, d.h. es sollen alle PC's die Nachricht nacheinander bekommen

    Spoiler anzeigen
    [autoit]

    for $x =0 to UBound($aPingAll) -1 ;
    $IP = $aPingAll[$x]
    ;MsgBox("","$IP",$IP)
    next
    for $z =0 to UBound($ip) -1

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

    $Port = 31758
    $ConnectedSocket = TCPConnect($IP, $Port)
    If $ConnectedSocket = -1 Then
    MsgBox(16, "Error", "Es ist bei dem Verbindungsversuch ein Fehler aufgetreten, vermutlich ist kein Server gestartet!")
    Exit
    EndIf
    call ("_senden")
    ;HotKeySet("^s", "_Senden") ; ctrg + s
    While 1
    $Empfang = TCPRecv($ConnectedSocket, 9999)
    If $Empfang <> "" Then
    MsgBox(0, "Nachricht", $Empfang)
    EndIf
    Sleep(500)
    WEnd
    Func _Senden()
    $Nachricht = InputBox("Nachricht senden Client", "Schreibe deine Nachricht")
    If $Nachricht <> "" Then
    TCPSend($ConnectedSocket, $Nachricht)
    EndIf
    EndFunc ;==>_Senden
    next

    [/autoit]

    hab jetzt mehrer varianten mit for schleifen versucht aber ich bekomm jedesmal die Fehlermeldung "For statment has no matching 'Next' statment"

    deshalb noch mal meine Frage wie kann ich das in eine Schleife Packen , egal ob While oder For :huh:

  • Eine Func darf nicht in eine Schleife!

    Spoiler anzeigen
    [autoit]

    for $x =0 to UBound($aPingAll) -1 ;
    $IP = $aPingAll[$x]
    ;MsgBox("","$IP",$IP)
    next
    for $z =0 to UBound($ip) -1

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

    $Port = 31758
    $ConnectedSocket = TCPConnect($IP, $Port)
    If $ConnectedSocket = -1 Then
    MsgBox(16, "Error", "Es ist bei dem Verbindungsversuch ein Fehler aufgetreten, vermutlich ist kein Server gestartet!")
    Exit
    EndIf
    call ("_senden")
    ;HotKeySet("^s", "_Senden") ; ctrg + s
    While 1
    $Empfang = TCPRecv($ConnectedSocket, 9999)
    If $Empfang <> "" Then
    MsgBox(0, "Nachricht", $Empfang)
    EndIf
    Sleep(500)
    WEnd
    next
    Func _Senden()
    $Nachricht = InputBox("Nachricht senden Client", "Schreibe deine Nachricht")
    If $Nachricht <> "" Then
    TCPSend($ConnectedSocket, $Nachricht)
    EndIf
    EndFunc ;==>_Senden

    [/autoit]

    mfg. Jam00

  • Ja, genau, außerdem drück in Scite mal STRG + T, wirkt ware Wunder ;) Dann seihst du was du falsch machst (S. Tidy)

  • ok - danke für die hilfe

    Eine Func darf nicht in eine Schleife!

    *Blöde Frage:* warum ??? - hab ine inem andern script von mir auch eine func in einer if-schleife :S und es funktioniert ?(

  • alles klar :D

    leider funktioniert das script aber nicht

    korrigiertes script
    [autoit]

    #include <GUIConstants.au3>
    #include <array.au3>
    #include <_PingAll.au3>
    #include <INet.au3>
    #include <ArrayMore.au3>
    ;$IP = @IPAddress1
    ;MsgBox ("","","Die Server-Ip ist: " & $IP )
    ClipPut(@IPAddress1)
    $aPingAll = _PingAll(20, 50, "", "", "", "", "", 0, 0, 0, 0, 0, 5, " ", "1", "0", 0, 0)
    ;_PingAll($ipstart, $ipend, $iprange = "", $port01 = "", $port02 = "", $port03 = "", $port04 = "",
    ;$radim = 0, $winxp = 1, $vnc = 1, $ShowName = 1, $ShowMac = 1, $dealy = 100, $slash = "|", $yes = 1, $no = 0, $showprog = 1, $showbevore = 1)
    _Array2DEmptyDel($aPingAll, 0) ;_Array2DEmptyDel(ByRef $avArray [, $Col=0])
    _ArrayDelete($aPingAll, 0); Erstes Element aus dem Array löschen
    $sUbound = (UBound($aPingAll) - 1)
    If $aPingAll[$sUbound] = "" Then _ArrayDelete($aPingAll, ($sUbound))
    _ArrayDisplay($aPingAll, "ipadress gesamt")

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

    For $x = 0 To UBound($aPingAll) - 1 ;
    $IP = $aPingAll[$x]
    MsgBox("","$IP",$IP)
    Next
    For $z = 0 To UBound($IP) - 1

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

    $Port = 31758
    $ConnectedSocket = TCPConnect($IP, $Port)
    If $ConnectedSocket = -1 Then
    MsgBox(16, "Error", "Es ist bei dem Verbindungsversuch ein Fehler aufgetreten, vermutlich ist kein Server gestartet!")
    Exit
    Else
    msgBox("", "Erfolg","$ConnectedSocket: "& $ConnectedSocket)
    EndIf

    Call("_Senden")
    ;HotKeySet("^s", "_Senden") ; ctrg + s
    While 1
    $Empfang = TCPRecv($ConnectedSocket, 9999)
    If $Empfang <> "" Then
    MsgBox(0, "Nachricht", $Empfang)
    EndIf
    Sleep(500)
    WEnd
    Next

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

    Func _Senden()
    $Nachricht = InputBox("Nachricht senden Client", "Schreibe deine Nachricht")
    If $Nachricht <> "" Then
    TCPSend($ConnectedSocket, $Nachricht)
    EndIf
    EndFunc ;==>_Senden

    [/autoit]
  • wenn die Func einen Wert zurückgibt, gegen den du prüfen kannst klar....

    Spoiler anzeigen
    [autoit]

    If myfunc() Then
    MsgBox(0,"","geht doch ;-)")
    EndIf

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

    Func myfunc()
    Return(1)
    EndFunc

    [/autoit]

    MfG Schnuffel

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

    über mich...

    ich habe meine Erfahrungen hauptsächlich gesammelt in (grobe Übersicht):

    - RibbonBar Automation
    - MySQL Nutzung
    - GUIs in vielerlei Ausprägung
    - Nutzung von Powershell / Batch in AutoIt
    - Windows Automatisierung

    außerhalb von AutoIt:

    - Sprachen: PS, Batch, php, html(5), javascript, (perl eingeschränkt), vbs
    - Powershell (AD, WPF inkl. Multi-Threading, ...)
    - Deployment-Automatisierung ohne SCCM
    - Office-Nutzung mit COM-Object (AutoIt, PowerShell)
    - ActiveDirectory und alles was damit zusammenhängt
    - Hyper-V Clustering (Converged / Hyper Converged)
    - Serverhardware (Konfiguration, Aufbau, Architektur, Betrieb)

    Lieblingsthema:

    günstige Automatisierung von Vorgängen, für die andere Firmen viel Geld nehmen

    more to come ...

    • Offizieller Beitrag

    DArf in eine If-Abfrage eine Funktion rein??

    Nein darf es nicht. Der Funktionsaufruf schon ,aber nicht die Funktion selbst.