Page 1 of 2 12>
Topic Options
#155401 - 2006-01-16 04:00 PM Net Send Scripting.
Arend_ Moderator Online   sleepy
MM club member
*****

Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
On a side project, for the fun of it i'm writing a LanMessenger, anyone know any way how to 'catch' the messages comming in ?
Top
#155402 - 2006-01-16 04:16 PM Re: Net Send Scripting.
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Could you explain a little more about what you are trying to do?

If you are trying to intercept the text from a "net send" you might be able to use AutoIT to watch for a particular window to appear and then rip the text out of it and automatically close/hide it.

Top
#155403 - 2006-01-16 04:28 PM Re: Net Send Scripting.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
not sure about the ripping though...

if you are doing some sorta send and receive script, you should actually go for your own implementation.
something with a file based messaging or so maybe...
_________________________
!

download KiXnet

Top
#155404 - 2006-01-16 05:10 PM Re: Net Send Scripting.
Arend_ Moderator Online   sleepy
MM club member
*****

Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
well, the Net Send command sends a ASCII based message over the network and once windows cacthes it is places it in a MessageBox and opens that to the user/computer it was send to. Basically what I want is to catch that message.

AutoIT catches it ? can't kix do it as well ?

Jooel: Yeah maybe file based, but it's slower and causes more stress on the network (I know not that much but still).

Top
#155405 - 2006-01-16 05:30 PM Re: Net Send Scripting.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
actually, using a file would most likely be faster and more trustworthy.

anyways, I doubt that some proggy can catch a message from inside a messagebox.
autoIt may catch the message before windows alert service gets it, but from the messagebox, I don't think so.
_________________________
!

download KiXnet

Top
#155406 - 2006-01-16 05:43 PM Re: Net Send Scripting.
Arend_ Moderator Online   sleepy
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
#155407 - 2006-01-16 05:45 PM Re: Net Send Scripting.
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
You planning on using a GUI for this or pure script ?
Top
#155408 - 2006-01-16 05:46 PM Re: Net Send Scripting.
Arend_ Moderator Online   sleepy
MM club member
*****

Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
A Gui when the code works..
Top
#155409 - 2006-01-16 06:11 PM Re: Net Send Scripting.
Arend_ Moderator Online   sleepy
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
#155410 - 2006-01-16 07:52 PM Re: Net Send Scripting.
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Net send will leave an Application Popup event in the system log that you can pull. It will contain the body of the message.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#155411 - 2006-01-17 10:29 AM Re: Net Send Scripting.
Richard H. Administrator Offline
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_ Moderator Online   sleepy
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
#155413 - 2006-01-17 06:37 PM Re: Net Send Scripting.
Arend_ Moderator Online   sleepy
MM club member
*****

Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
The code works fine commandline wise, but getting it into a gui is a different problem, Only option I see is to write it into a second script and call for that. Anyone have any other idea's ?

Edit: Calling a second script isn't an option either, it still leaves the KiXForms Gui hanging.


Edited by apronk (2006-01-17 06:39 PM)

Top
#155414 - 2006-01-17 06:59 PM Re: Net Send Scripting.
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Are you limited to using Messenger or can you home-brew your own protocol ... wouldn't be too-too tough to use Kixforms Socket support to write a little client/server thing, using an unused open port.
Top
#155415 - 2006-01-18 03:18 AM Re: Net Send Scripting.
Stevie Offline
Starting to like KiXtart
*****

Registered: 2002-01-09
Posts: 199
You can use the au3info.exe included with autoit to capture the real title and id of the messagebox window so that you can script the capture of it.

--OR--

I could move to page 2 to see that is no longer an issue.


Edited by Stevie (2006-01-18 03:19 AM)
_________________________
Stevie

Top
#155416 - 2006-01-18 07:28 AM Re: Net Send Scripting.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol.
_________________________
!

download KiXnet

Top
#155417 - 2006-01-18 08:48 AM Re: Net Send Scripting.
Arend_ Moderator Online   sleepy
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 Offline
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_ Moderator Online   sleepy
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
#155420 - 2006-01-19 10:27 AM Re: Net Send Scripting.
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Your problem is that you are never returning to your script.

The "$Nul = Execute($Form1.DoEvents())" line will block until an event is ready to process (I'm guessing here as I'm not a big KixForms.Net user).

You need the form to return control to the script so that you can action your own code, probably by using a timer.

Top
Page 1 of 2 12>


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 496 anonymous users online.
Newest Members
Raoul, Timothy, Jojo67, MaikSimon, kvn317
17875 Registered Users

Generated in 0.076 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org