allez, je me lance...
Voici un petit prog pour utiliser Net Send sur un réseau local.
J'avoue qu'il n'est pas parfait, loin de là, et que j'utilise sûrement des détours monstrueux pour arriver à mes fins, mais ce script me facilite la vie...
► Afficher le texte
Code : Tout sélectionner
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Process.au3>
#include <Services.au3>
#include <GUIListBox.au3>
#include <GuiComboBoxEx.au3>
;----------VARIABLES------------------------------------------------
Global $contact
Global $LST01
Global $mess
Global $add
Global $stat
Global $messenger
Global $messcolor
;-------------------------------------------------------------------
etatservice() ;Vérifie l'état du service de messagerie
If Not FileExists("sylnet.ini") Then
MsgBox(48, "INI ?", "La bibliothèque de contact n'a pas été trouvée.")
Exit
EndIf
$contact = IniReadSection("sylnet.ini", "contact")
If @error Then
MsgBox(16, "paramètre incorrect", "Le fichier INI ne contient pas de section [contact].")
Exit
EndIf
;----------GUI------------------------------------------------------
$Form1 = GUICreate("SYLNET", 633, 427, -1, -1)
$Group1 = GUICtrlCreateGroup("Destinataires : ", 24, 16, 193, 385)
$LST01 = GUICtrlCreateList("", 40, 40, 161, 344, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
For $i = 1 To $contact[0][0]
GUICtrlSetData($LST01, $contact[$i][0])
Next
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Message : ", 240, 16, 369, 137)
$TXT01 = GUICtrlCreateInput("", 256, 40, 337, 21)
$Label6 = GUICtrlCreateLabel("Message généré automatiquement...", 256, 40, 176, 17)
GUICtrlSetState(-1, $GUI_HIDE)
$CKB01 = GUICtrlCreateCheckbox("Bombe amorcée...", 256, 80, 105, 17)
$Label2 = GUICtrlCreateLabel("Quantité à envoyer :", 448, 83, 100, 17)
GUICtrlSetState(-1, $GUI_DISABLE)
$TXT02 = GUICtrlCreateInput("", 552, 80, 41, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$CKB02 = GUICtrlCreateCheckbox("Compte à rebours automatique...", 256, 112, 177, 17)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label6 = GUICtrlCreateLabel("Message généré automatiquement...", 256, 40, 176, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label1 = GUICtrlCreateLabel("Copyright SDE", 24, 408, 73, 17)
$Group3 = GUICtrlCreateGroup("Système", 240, 176, 369, 113)
$Label3 = GUICtrlCreateLabel("Etat du service de messagerie :", 256, 206, 152, 17)
$Label4 = GUICtrlCreateLabel($messenger, 432, 200, 152, 28)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, $messcolor)
$Button1 = GUICtrlCreateButton("Activer / désactiver", 320, 248, 201, 25, $WS_GROUP)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button2 = GUICtrlCreateButton("ENVOYER", 512, 320, 97, 81, $WS_GROUP)
$Group4 = GUICtrlCreateGroup("Options", 240, 312, 249, 89)
$CKB04 = GUICtrlCreateCheckbox("Envoi différé", 256, 336, 161, 25)
$TXT03 = GUICtrlCreateInput("", 397, 369, 41, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label7 = GUICtrlCreateLabel("Délai :", 357, 372, 34, 17)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label8 = GUICtrlCreateLabel("Sec.", 443, 372, 26, 17)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label5 = GUICtrlCreateLabel("Version 2.0", 552, 408, 57, 17)
GUISetState (@SW_SHOW)
;-------------------------------------------------------------------
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE ;Fermeture avec la p'tite croix
Annuler()
Case $Button1 ;Commande du service de messagerie
action()
Case $Button2 ;Envoi du ou des messages
envoyer()
Case $CKB01
If _IsChecked($CKB01) then
GUICtrlSetState($Label2, $GUI_ENABLE)
GUICtrlSetState($TXT02, $GUI_ENABLE)
GUICtrlSetState($CKB02, $GUI_ENABLE)
Else
GUICtrlSetState($Label2, $GUI_DISABLE)
GUICtrlSetState($TXT02, $GUI_DISABLE)
GUICtrlSetState($CKB02, $GUI_DISABLE)
GUICtrlSetState($TXT01, $GUI_SHOW)
GUICtrlSetState($Label6, $GUI_HIDE)
Guictrlsetstate($CKB02,$GUI_UNCHECKED)
EndIf
Case $CKB02
If _IsChecked($CKB02) then
GUICtrlSetState($TXT01, $GUI_HIDE)
GUICtrlSetState($Label6, $GUI_SHOW)
Else
GUICtrlSetState($TXT01, $GUI_SHOW)
GUICtrlSetState($Label6, $GUI_HIDE)
EndIf
Case $CKB04
If _IsChecked($CKB04) then
pas_integre()
GUICtrlSetState($Label7, $GUI_ENABLE)
GUICtrlSetState($TXT03, $GUI_ENABLE)
GUICtrlSetState($Label8, $GUI_ENABLE)
Else
GUICtrlSetState($Label7, $GUI_DISABLE)
GUICtrlSetState($TXT03, $GUI_DISABLE)
GUICtrlSetState($Label8, $GUI_DISABLE)
EndIf
EndSwitch
WEnd
;----------FONCTIONS------------------------------------------------
Func etatservice()
$etatserv = _Service_GetState("messenger", "localhost")
If $etatserv = "Running" Then
$messenger = "ACTIVE"
$messcolor = 0x0054E3
Else
$messenger = "DESACTIVE"
$messcolor = 0xff0000
EndIf
EndFunc
;-------------------------------------------------------------------
Func Annuler()
Exit
EndFunc
;-------------------------------------------------------------------
Func _IsChecked($control) ;Fonction pour voir si la checkbox est cochée
Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc
;-------------------------------------------------------------------
Func envoyer()
$mess = GUICtrlRead($TXT01)
$aShowItems = _GUICtrlListBox_GetSelItemsText($LST01)
For $i = 1 To $aShowItems[0]
$add = IniRead ("Sylnet.ini", "contact", $aShowItems[$i], " ")
If _IsChecked($CKB01) then
bombe()
Else
simple()
EndIf
Next
EndFunc
;-------------------------------------------------------------------
Func simple()
_RunDos ("net send "& $add & " " & $mess)
EndFunc
;-------------------------------------------------------------------
Func bombe()
$count = GUICtrlRead($TXT02)
If $count > 15 then $count = 15 ;On limite quand-même histoire de ne pas saturer le réseau...
If _IsChecked($CKB02) then
$clics = $count
For $i = 1 To $count
$mess = "Plus que " & $clics & " clics..."
_RunDos ("net send "& $add & " " & $mess)
$clics = $clics - 1
sleep(100)
Next
Else
For $i = 1 To $count
_RunDos ("net send "& $add & " " & $mess)
Next
EndIf
EndFunc
;-------------------------------------------------------------------
Func action()
$stat = GUICtrlRead($Label4)
If $stat = "ACTIVE" Then
;_Service_Stop("messenger", "localhost")
chargement("Arrêt ", 1000, "net stop messenger") ;Il faut 20 secondes pour l'arrêter
etatservice()
GUICtrlSetData($Label4, $messenger)
GUICtrlSetColor($Label4, $messcolor)
Sleep(500)
If $messenger = "ACTIVE" Then
MsgBox(16, "Attention", "Vous n'avez pas les droits nécessaires" & @LF & "pour réaliser cette action.")
Else
TrayTip("Sylnet", "Service de messagerie desactivé", 5, 1)
EndIf
Else
;_Service_Start("messenger", "localhost")
chargement("Démarrage ", 1000, "net start messenger") ;Il faut 6 secondes pour le démarrer
etatservice()
GUICtrlSetData($Label4, $messenger)
GUICtrlSetColor($Label4, $messcolor)
Sleep(500)
If $messenger = "DESACTIVE" Then
MsgBox(16, "Attention", "Vous n'avez pas les droits nécessaires" & @LF & "pour réaliser cette action.")
Else
TrayTip("Sylnet", "Service de messagerie activé", 5, 1)
EndIf
EndIf
EndFunc
;-------------------------------------------------------------------
Func pas_integre()
MsgBox(64, "Info", "Pas encore intégré...")
EndFunc
;-------------------------------------------------------------------
Func chargement($action,$temps,$commande)
#Region ### START Koda GUI section ### Form=C:\Documents and Settings\s.defosse\Mes documents\Divers\Sylnet\Syl-net\GUIChargement.kxf
$Form2 = GUICreate("Sevice de messagerie", 226, 100, -1, -1, BitOR($WS_CAPTION, $WS_BORDER))
$Label1 = GUICtrlCreateLabel($action & "du service en cours...", 32, 16, 161, 17, BitOR($SS_CENTER,$SS_CENTERIMAGE))
$Progress1 = GUICtrlCreateProgress(24, 48, 169, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
For $i = 0 to 25
GUICtrlSetData($Progress1, $i)
sleep($temps / 100)
Next
_RunDos ($commande)
For $i = 26 to 100
GUICtrlSetData($Progress1, $i)
sleep($temps / 100)
Next
GUISetState(@SW_HIDE)
EndFunc
Il faut également créer un fichier Sylnet.ini dans le dossier du script avec:
Code : Tout sélectionner
[contact]
destinataire1=ip1
destinataire2=ip2
destinataire3=ip3
...
..
.
Je rappel que Net Send ne fonctionne ni sous Vista, ni sous 7.
Voilà, n'hésitez surtout pas à me faire part de vos remarques et améliorations, Dieu sait qu'il doit y en avoir un paquet...
Bon amusement.
Maf