| 
| 
| 
| #155424 - 2006-01-19 04:54 PM  Re: Net Send Scripting. |  
| Arend_   MM club member
 
       
   Registered:  2005-01-17
 Posts: 1896
 Loc:  Hilversum, The Netherlands
 | 
Thx Richard H, Jooel, Shawn and Les  
 It works splendidly now, here's the final code:
 (keep in mind, the dialog is very plain and simple)
 Code:
 
 Break On
 
 $System = CreateObject("Kixforms.System")
 If Not $System
 $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
 Quit()
 EndIf
 $nul = $System.Application.EnableVisualStyles
 
 ; GLOBAL SETUP - PLACE AT SCRIPT START----------------------
 GLOBAL $oAutoIT, $sMessengerTitle, $iControlMessage
 $sMessengerTitle="Messenger-service"
 $iControlMessage=65535
 
 $oAutoIT=CreateObject("AutoItX3.Control")
 If @ERROR OR VarType($oAutoIT)<>9 "Cannot create AutoIT object - no registered perhaps?"+@CRLF Exit @ERROR EndIf
 
 ; Set some useful options.
 $=$oAutoIT.Opt("MouseCoordMode",0)
 $=$oAutoIT.Opt("WinTitleMatchMode",4)
 
 ; Timer to catch messages
 $Timer = $System.Timer
 $Timer.Interval = 1000 ;1000ms = 1s
 $Timer.Tick = "CatchMSG()" ;the event that fires every second
 $Timer.Start
 
 ; END OF GLOBAL SETUP---------------------------------------
 
 $Form1 = $System.Form()
 $Form1.Left = 368
 $Form1.StartPosition = 0  ;FormStartPosition_Manual
 $Form1.Size = $System.Size(240,358) ;(Width,Height)
 $Form1.Text = "LAN Messenger"
 $Form1.Top = 0
 
 $Label1 = $System.Label()
 $Label1.BorderStyle = 0  ;FixedSingle
 $Label1.Left = 24
 $Label1.Text = "Gebruiker"
 $Label1.TextAlign = 16  ;MiddleLeft
 $Label1.Top = 19
 $Label1.Width = 55
 $nul = $Form1.Controls.Add($Label1)
 
 $ComboBox1 = $System.ComboBox()
 $ComboBox1.Height = 21
 $ComboBox1.ItemHeight = 13
 $ComboBox1.Left = 89
 $ComboBox1.Text = "Select..."
 $ComboBox1.Top = 20
 $nul = $Form1.Controls.Add($ComboBox1)
 
 $RichTextBox1 = $System.RichTextBox()
 $RichTextBox1.Height = 171
 $RichTextBox1.Left = 13
 $RichTextBox1.Text = ""
 $RichTextBox1.Top = 68
 $RichTextBox1.Width = 209
 $nul = $Form1.Controls.Add($RichTextBox1)
 
 $TextBox1 = $System.TextBox()
 $TextBox1.Height = 61
 $TextBox1.Left = 13
 $TextBox1.Text = ""
 $TextBox1.Top = 258
 $TextBox1.Width = 125
 $TextBox1.Multiline = -1
 $nul = $Form1.Controls.Add($TextBox1)
 
 $Button1 = $System.Button()
 $Button1.Height = 61
 $Button1.Left = 152
 $Button1.Text = "Send!"
 $Button1.Top = 258
 $Button1.Width = 70
 $Button1.Click = "SendMSG()"
 $nul = $Form1.Controls.Add($Button1)
 
 $Form1.Show  ;Displays the Form
 Init()
 While $Form1.Visible
 $Nul = Execute($Form1.DoEvents())
 Loop
 Exit 0
 
 Function SendMSG()
 Dim $msg, $rcpt, $x
 $msg = $TextBox1.Text
 $rcpt = $ComboBox1.Text
 If $rcpt = "Select..."
 $x = MessageBox("You have to select a user first!","Info",0)
 Goto "end"
 EndIf
 $log = $log + @CRLF + "Jij zegt tegen " + $rcpt + ":" + @CRLF + $msg + @CRLF
 $RichTextBox1.Text = $log
 run "net send $rcpt $msg"
 $TextBox1.Text = ""
 :end
 EndFunction
 
 Function CatchMSG()
 Dim $sMessageText, $sFrom, $sDate, $sTime
 If $oAutoIT.WinExists($sMessengerTitle)
 $sMessageText=$oAutoIT.ControlGetText("last","",$iControlMessage)
 $=$oAutoIt.WinClose("last")
 
 $sMessageText=split($sMessageText,@CRLF)
 $sFrom=Split($sMessageText[0]+"      ")[2]
 $sTo=Split($sMessageText[0]+"      ")[4]
 $sDate=Split($sMessageText[0]+"      ")[6]
 $sTime=Split($sMessageText[0]+"      ")[7]+" "+Split($sMessageText[0]+"      ")[8]
 $sMessageText[0]=""
 $sMessageText=SubStr(Join($sMessageText,@CRLF),5)
 
 $log = $log + @CRLF + $sFrom + " zegt tegen jou:" + @CRLF + $sMessageText + @CRLF
 $RichTextBox1.Text = $log
 EndIf
 EndFunction
 
 Function Init()
 ;ComboBoxbox 1 Info
 $Users = GetObject("WinNT://@ldomain")
 $Users.filter = "User",""
 For Each $User In $Users
 $x = $ComboBox1.Items.Add($User.Name)
 Next
 EndFunction
 
 
 |  
| Top |  |  |  |  
| 
| 
| #155428 - 2006-01-19 05:57 PM  Re: Net Send Scripting. |  
| Arend_   MM club member
 
       
   Registered:  2005-01-17
 Posts: 1896
 Loc:  Hilversum, The Netherlands
 | 
Oh! I thought you were referring to the Incomming messages  Yeah the outgoing is very primitive, usually once I get something to work for myself I leave it at what it is
  I only really clean up and script nice when it's for someone else   |  
| Top |  |  |  |  
| 
| 
| #155430 - 2006-01-19 06:33 PM  Re: Net Send Scripting. |  
| Arend_   MM club member
 
       
   Registered:  2005-01-17
 Posts: 1896
 Loc:  Hilversum, The Netherlands
 | 
LOL, well you we're helping me in the first place  Besides, yeah I am gettin kinda comfortable, whenever help is needed there is always someone around to help, you don't find that very often anymore. So to express my gratitude I've cleaned it up, still the Dialog is a simple one
  
 Code:
 
 Break On
 
 $System = CreateObject("Kixforms.System")
 If Not $System
 $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
 Quit()
 EndIf
 $nul = $System.Application.EnableVisualStyles
 
 GLOBAL $oAutoIT, $sMessengerTitle, $iControlMessage, $log
 $sMessengerTitle="Messenger-service"
 $iControlMessage=65535
 
 $oAutoIT=CreateObject("AutoItX3.Control")
 If @ERROR OR VarType($oAutoIT)<>9
 ? "Cannot create AutoIT object - no registered perhaps?" + @CRLF
 Exit @ERROR
 EndIf
 
 ; Set some useful options.
 $=$oAutoIT.Opt("MouseCoordMode",0)
 $=$oAutoIT.Opt("WinTitleMatchMode",4)
 
 ; Timer to catch messages
 $Timer = $System.Timer
 $Timer.Interval = 1000 ;1000ms = 1s
 $Timer.Tick = "CatchMSG()" ;the event that fires every second
 $Timer.Start
 
 $Form1 = $System.Form()
 $Form1.Left = 368
 $Form1.StartPosition = 0  ;FormStartPosition_Manual
 $Form1.Size = $System.Size(240,358) ;(Width,Height)
 $Form1.Text = "LAN Messenger"
 $Form1.Top = 0
 
 $Label1 = $System.Label()
 $Label1.BorderStyle = 0  ;FixedSingle
 $Label1.Left = 24
 $Label1.Text = "Gebruiker"
 $Label1.TextAlign = 16  ;MiddleLeft
 $Label1.Top = 19
 $Label1.Width = 55
 $nul = $Form1.Controls.Add($Label1)
 
 $ComboBox1 = $System.ComboBox()
 $ComboBox1.Height = 21
 $ComboBox1.ItemHeight = 13
 $ComboBox1.Left = 89
 $ComboBox1.Text = "Select..."
 $ComboBox1.Top = 20
 $nul = $Form1.Controls.Add($ComboBox1)
 
 $RichTextBox1 = $System.RichTextBox()
 $RichTextBox1.Height = 171
 $RichTextBox1.Left = 13
 $RichTextBox1.Text = ""
 $RichTextBox1.Top = 68
 $RichTextBox1.Width = 209
 $nul = $Form1.Controls.Add($RichTextBox1)
 
 $TextBox1 = $System.TextBox()
 $TextBox1.Height = 61
 $TextBox1.Left = 13
 $TextBox1.Text = ""
 $TextBox1.Top = 258
 $TextBox1.Width = 125
 $TextBox1.Multiline = -1
 $nul = $Form1.Controls.Add($TextBox1)
 
 $Button1 = $System.Button()
 $Button1.Height = 61
 $Button1.Left = 152
 $Button1.Text = "Send!"
 $Button1.Top = 258
 $Button1.Width = 70
 $Button1.Click = "SendMSG()"
 $nul = $Form1.Controls.Add($Button1)
 
 $Form1.Show  ;Displays the Form
 Init()
 While $Form1.Visible
 $Nul = Execute($Form1.DoEvents())
 Loop
 Exit 0
 
 Function SendMSG()
 Dim $msg, $rcpt, $x
 $msg = $TextBox1.Text
 $rcpt = $ComboBox1.Text
 If $rcpt = "Select..."
 $x = MessageBox("You have to select a user first!","Info",0)
 Goto "end"
 EndIf
 $log = $log + @CRLF + "You said to " + $rcpt + ":" + @CRLF + $msg + @CRLF
 $RichTextBox1.Text = $log
 shell "%comspec% /c net send $rcpt $msg > nul"
 $TextBox1.Text = ""
 :end
 EndFunction
 
 Function CatchMSG()
 Dim $sMessageText, $sFrom, $sTo, $sDate, $sTime
 If $oAutoIT.WinExists($sMessengerTitle)
 $sMessageText=$oAutoIT.ControlGetText("last","",$iControlMessage)
 $=$oAutoIt.WinClose("last")
 $sMessageText=split($sMessageText,@CRLF)
 $sFrom=Split($sMessageText[0]+"      ")[2]
 $sTo=Split($sMessageText[0]+"      ")[4]
 $sDate=Split($sMessageText[0]+"      ")[6]
 $sTime=Split($sMessageText[0]+"      ")[7]+" "+Split($sMessageText[0]+"      ")[8]
 $sMessageText[0]=""
 $sMessageText=SubStr(Join($sMessageText,@CRLF),5)
 $log = $log + @CRLF + $sFrom + " says to you:" + @CRLF + $sMessageText + @CRLF
 $RichTextBox1.Text = $log
 EndIf
 EndFunction
 
 Function Init()
 Dim $Users, $User
 $Users = GetObject("WinNT://@ldomain")
 $Users.filter = "User",""
 For Each $User In $Users
 $x = $ComboBox1.Items.Add($User.Name)
 Next
 EndFunction
 
 
 |  
| Top |  |  |  |  
 Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
 
 | 
| 
 
| 0 registered
and 456 anonymous users online. 
 | 
 |  |