#155406 - 2006-01-16 05:43 PM
Re: Net Send Scripting.
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
Actually it does get it from the messagebox, I found this script on one of the forum archives (modified it for the new AutoITX3.dll but it doesn't work.
Code:
break on ;$=setconsole("minimize")
$autoIt=CreateObject("AutoItX3.Control") ? @error do if $AutoIt.IfWinExist("Messenger-service", "") $x=$AutoIt.WinActivate("Messenger-service", "") $x=$AutoIt.Send("^c") $x=$AutoIt.WinClose("Messenger-service", "") $Paste=$AutoIt.ClipGet() $text=split($paste,@crlf) $header = split($text[3]) $body = "" for $l = 5 to ubound($text) - 4 $body = $body + @crlf + $text[$l] next $from = $header[2] $to = $header[4] $date = $header[6] $time = $header[7] + " " + $header[8] $body = substr($body,3) ? $from ? $body ? "----" endif sleep 1 until @error
|
Top
|
|
|
|
#155409 - 2006-01-16 06:11 PM
Re: Net Send Scripting.
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
I got it from this post: Re: capture net send messages
Basically the problem I see, is it Can not find the type of class "Messenger-service" eventhough that is what the popp message is called in the Title of it and in the TaskManager.
Edited by apronk (2006-01-16 06:21 PM)
|
Top
|
|
|
|
#155411 - 2006-01-17 10:29 AM
Re: Net Send Scripting.
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
This works for me, note the use of "ControlGetText" to get the message text rather than the kludgy cut'n'paste method.
Code:
Break ON $=SetOption("Explicit","ON") Dim $oAutoIT Dim $sTitle,$sMessageText Dim $iControlMessage Dim $sFrom,$sTo,$sDate,$sTime $sTitle="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) While "True" "Waiting for "+$sTitle+" window to appear..."+@CRLF $=$oAutoIT.WinWait($sTitle) $sMessageText=$oAutoIT.ControlGetText("last","",$iControlMessage) $=$oAutoIt.WinClose("last") ; Parse message text $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) "From :"+$sFrom+@CRLF "To :"+$sFrom+@CRLF "Body is: "+$sMessageText+@CRLF "------------------"+@CRLF ; Give the window a chance to close... Sleep 0.2 Loop
|
Top
|
|
|
|
#155412 - 2006-01-17 12:32 PM
Re: Net Send Scripting.
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
Perfect, Thx Richard I should have picked up on the WinWait property.
btw for the ones with dutch OS's the name of the window is "Messenger-service" and on english OS's "Messenger service" don't ask me why.
|
Top
|
|
|
|
#155417 - 2006-01-18 08:48 AM
Re: Net Send Scripting.
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
Yeah I'll have to look into socket support, probably a better idea in the end anyway. However I do have an idea. like mIRC it would be handy if kixforms of kix itself could watch events for instance:
Code:
on SockOpen:*:{ if $socketname = "somesocketnamehere" ;do stuff endif }
But probably won't see the light of day since if you would implement such a thing it has to look trough your scripts and see if a script waits for such an event, so you would have to load your script into kix or kixforms memory.
If you want to see an example of my idea goto my site SphinxScript and download the SSFserv addon, open the .mrc file in notepad and search for "sockopen"
|
Top
|
|
|
|
#155418 - 2006-01-18 10:19 AM
Re: Net Send Scripting.
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
It's not a problem to include it in a GUI script, you just need to use a non-blocking check.
The example script I gave you blocks simply because that is most efficient for that script, but there is no reason that you shouldn't call the routine in your GUI polling loop if you use (say) ".WinExists" instead of ".WinWait".
The code to get the message will be identical.
For example: Code:
; GLOBAL SETUP - PLACE AT SCRIPT START---------------------- GLOBAL $oAutoIT, $sMessengerTitle, $iControlMessenger $sMessengerTitle="Messenger Service" $iControlMessenger=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) ; END OF GLOBAL SETUP--------------------------------------- ; Check for new message function Function udfCheckForMessage() If $oAutoIT.WinExists($sMessengerTitle) $udfCheckForMessage=$oAutoIT.ControlGetText("last","",$iControlMessage) $=$oAutoIt.WinClose("last") EndIf EndFunction
Now, in your event polling loop you only need to do something like: Code:
$sMessage=udfCheckForMessage() If $sMessage ; Parse and action message End If
|
Top
|
|
|
|
#155419 - 2006-01-18 05:31 PM
Re: Net Send Scripting.
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
I've been trying to get your code to work all day Richard but can't. (edited, removed obsolete code)
(Please note the "Messenger-service / Messenger Service" difference)
Here's a simple dialog I tried it with 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, $iControlMessenger $sMessengerTitle="Messenger-service" $iControlMessenger=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) ; 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()) $RichTextBox1.Text = $RichTextBox1.Text + @CRLF + CatchMSG() 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 $TextBox1.Text = "" :end EndFunction
Function CatchMSG() If $oAutoIT.WinExists($sMessengerTitle) $CatchMSG=$oAutoIT.ControlGetText("last","",$iControlMessage) $=$oAutoIt.WinClose("last") ; $log = $log + @CRLF + $oAutoIT.ControlGetText("last","",$iControlMessage) + @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
Edited by apronk (2006-01-19 08:49 AM)
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 668 anonymous users online.
|
|
|