Jump to content

Recommended Posts

Hi everybody!

Here is my new super tool!

It's an AutoItObject TCP Class! Very simple to use, with example and complet decumentation (Made with NaturalDocs)

There are two classes: Client, and Server.

- The data are encrypted!

- The server can handle multiple clients

- Data buffering, if you send a big amount of data, it will received as it was sent, not as many little parts of it

- OOP programing! (very simple!)

PS: You don't need to download AutoItObject, everything you need is in the zip.

Update: 03/11/2011

+: Added, -: Deleted/Deprecated, *: Modified, !: Bug corrected
=== 1.1c === (30/10/2011)
Server:
+: ClientGetBufferLen method
+: Completed doc of ClientPropertyGet and ClientPropertySet methods (Return values)
*: Now, when calling .Shutdown, the Callback_LostClient is called for each client.
!: Corrected bug: Script error when calling .DisconnectAll befor calling at least one
    time .Startup (Main socket array was not dimensioned)

UDF_TCPClass.rar

Edited by matwachich
Link to post
Share on other sites
  • 2 weeks later...
  • Replies 40
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Hi everybody! Here is my new super tool! It's an AutoItObject TCP Class! Very simple to use, with example and complet decumentation (Made with NaturalDocs) There are two classes: Client, and Serve

matwachich nice job! :graduated: Im surprised you havent got more comments. Very good use of autoitobject. And documentation is cool too. I like the html. One thing about the examples, you should add a check for window close in your loop. Since you have the tray icon hidden I dont know how to get out of it.

edit: and maybe add the examples to your zip so the user dosent have to copy and create from the help file to test it.

Edited by Beege
Link to post
Share on other sites

Hi everybody!

Here is my new super tool!

It's an AutoItObject TCP Class! Very simple to use, with example and complet decumentation (Made with NaturalDocs)

There are two classes: Client, and Server.

- The data are encrypted!

- The server can handle multiple clients

- Data buffering, if you send a big amount of data, it will received as it was sent, not as many little parts of it

- OOP programing! (very simple!)

PS: You don't need to download AutoItObject, everything you need is in the zip.

Here is the zip, enjoy!

So good work!

One question: how do you compile AutoItObject.au3 to DLL file?

(In the Function of _File_AutoItObject_dll(), how do you get $string?)

Link to post
Share on other sites

One question: how do you compile AutoItObject.au3 to DLL file?

(In the Function of _File_AutoItObject_dll(), how do you get $string?)

You dont. The Autoitobject UDF automatically extracts the dll for use at runtime.

Link to post
Share on other sites

Update 1.1b: Bug correction and new examples

Change log:

=== 1.1b === (30/09/2011)
Server:
!: Corrected bug in Number of client's extended properties
*: Documentation corrected (added 0-based for ClientPropertyGet/Set)
+: New Method: NbrClients
*: Property NbrClients is now private
Client:
!: Changed return value of Connect method (see documentation)

PS: If you want to send a file, just read it's content with binary mode (flag 16 in FileOpen) and send it! The receiver will receive binary data, and all you have to do is write it on a file with binary mode too (flag 18 in FileOpen)

For archive download, see first post

Link to post
Share on other sites

Update 1.1b: Bug correction and new examples

Change log:

=== 1.1b === (30/09/2011)
Server:
!: Corrected bug in Number of client's extended properties
*: Documentation corrected (added 0-based for ClientPropertyGet/Set)
+: New Method: NbrClients
*: Property NbrClients is now private
Client:
!: Changed return value of Connect method (see documentation)

PS: If you want to send a file, just read it's content with binary mode (flag 16 in FileOpen) and send it! The receiver will receive binary data, and all you have to do is write it on a file with binary mode too (flag 18 in FileOpen)

For archive download, see first post

i will try it a.s.a.p.

PS.

I love ur work :graduated:

DS

Link to post
Share on other sites

i get one error every time i start the app i maid on client side, think it has nothing to do with ur scripts and i think i allways had it.

Yet everything works as it should and cant see any errors in anything else then exept when i start my client (think i implemented ur code a litte wrong?)

Do u have any idea where i should start to look?

in ur client.au3, line 6 is

Global $__TCPClass_oMyErr = ObjEvent("AutoIt.Error", "_TCPClass_ErrFunc")

when i do this.

ConsoleWrite("test")

#include "Client.au3"

ConsoleWrite("test1")

i can see it must be the client.au3

>Running:(3.3.6.1):C:\Program\AutoIt3\autoit3.exe "H:\Jobb\scripts\Dev\ChargeDeamon\utveckling\Ny\CH-Agent\CH-Agent.au3" -d  
testA COM Error has occured!
err.description is:
err.windescription:
err.number is:  00000002
err.lastdllerror is:  0
err.scriptline is:  6
err.source is:
err.helpfile is:
err.helpcontext is:
test1@@(266) :(42:37)Updateing client settnigs...
@@ (500) :(42:37) _Getbiosinfo()
@@(266) :(42:37)Updateing webserver...
Edited by lgvlgv
Link to post
Share on other sites

Update 1.1b: Bug correction and new examples Change log:

=== 1.1b === (30/09/2011) Server: !: Corrected bug in Number of client's extended properties *: Documentation corrected (added 0-based for ClientPropertyGet/Set) +: New Method: NbrClients *: Property NbrClients is now private Client: !: Changed return value of Connect method (see documentation)
PS: If you want to send a file, just read it's content with binary mode (flag 16 in FileOpen) and send it! The receiver will receive binary data, and all you have to do is write it on a file with binary mode too (flag 18 in FileOpen) For archive download, see first post

What im i doing wrong?

server sends:
Case $ButtonViewDesktop
Local $sock1 = _GUICtrlListView_GetItemTextArray(GUICtrlGetHandle($ListViewClients)) ;gets the socket
SendPacketToServer($sock1[7], "~~GetScreenShot")

client do:
Case $data[0] = "~~GetScreenShot"
SetClientStatus(1, "Sending Screenshot")
_ScreenCapture_SetJPGQuality(100)
_ScreenCapture_Capture(@DesktopDir & "\tempscreen1.jpg")
sleep(1000)
local $screenfile = FileOpen(@DesktopDir & "\tempscreen1.jpg", 16)
$oClient.Send("~~SendingScreenshot|" & $screenfile)
sERVER RECIVES:
Case $data[0] = "~~SendingScreenshot"
;_ArrayDisplay($data)
local $screenshotfile = FileOpen(@DesktopDir & "\SCREEN.JPG", 18)
Filewrite($screenshotfile, $data[1])
FileClose($screenshotfile)
Link to post
Share on other sites

Try like this

Filewrite($screenshotfile, Binary($data[1]))

Or, try to not mix between String data and binary data here: $oClient.Send("~~SendingScreenshot|" & $screenfile)

What i do is, to send a small command to the server to tell him that the next received data will be a screen shot, and just after that, i send ONLY the screen shot binary data, and it works for me.

About the com error, i really don't know, don't have it.

Link to post
Share on other sites

Try like this

Filewrite($screenshotfile, Binary($data[1]))

Or, try to not mix between String data and binary data here: $oClient.Send("~~SendingScreenshot|" & $screenfile)

What i do is, to send a small command to the server to tell him that the next received data will be a screen shot, and just after that, i send ONLY the screen shot binary data, and it works for me.

About the com error, i really don't know, don't have it.

Ive got it working :graduated: thx alot.

had 2 stupid errors in the script one was that i only read 4096 of the file no matter how big it was ;) (cut and past from another guys script)

One last question!

there are another threed here on the forums about running "ur own" scripts as a service do u know if its possible to merge ur example with there exampels?

i nuderstand this is not ur table, but beeing a guru and all u probbebly allready have the answer. sorrry for my bad swenglish (im swedish ;) )

any of the example would do :)

Edited by lgvlgv
Link to post
Share on other sites

#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author:      Matwachich
Script Function:
#ce ----------------------------------------------------------------------------
#include <Services.au3>
Global $srvName = "custom_service", $srvDesc = "My Custom Au3 Service"
If Not _Service_Exists($srvName) Then
; This creates your service in windows service manager, it hase to be done
; only one time.
_Service_Create($srvName, $srvDesc, _
     $SERVICE_WIN32_OWN_PROCESS + $SERVICE_INTERACTIVE_PROCESS, _
     $SERVICE_AUTO_START, _
     $SERVICE_ERROR_IGNORE, _
     '"' & @ScriptFullPath & '"')
EndIf
; This starts your service, calling the _Svc_Main function
_Service_init($srvName)
; ##############################################################
Func _Svc_Main()
; Now, all your code goes here!
EndFunc

Link to post
Share on other sites

#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author:      Matwachich
Script Function:
#ce ----------------------------------------------------------------------------
#include <Services.au3>
Global $srvName = "custom_service", $srvDesc = "My Custom Au3 Service"
If Not _Service_Exists($srvName) Then
; This creates your service in windows service manager, it hase to be done
; only one time.
_Service_Create($srvName, $srvDesc, _
     $SERVICE_WIN32_OWN_PROCESS + $SERVICE_INTERACTIVE_PROCESS, _
     $SERVICE_AUTO_START, _
     $SERVICE_ERROR_IGNORE, _
     '"' & @ScriptFullPath & '"')
EndIf
; This starts your service, calling the _Svc_Main function
_Service_init($srvName)
; ##############################################################
Func _Svc_Main()
; Now, all your code goes here!
EndFunc

ahh, its under _Svc_main i should put it :graduated: tryed to put it everywere else ;)

i will try it as soon as i get home :)

//Thx alot

Link to post
Share on other sites
  • 3 weeks later...

question...

o_server.au3 add code

#region ### START Koda GUI section ###

$GUI_Main = GUICreate("Mini-Server", 1408, 228)

$tab = GUICtrlCreateTab(6, 6, 1297, 217)

$bsen = GUICtrlCreateButton('bsend',1300,6,100,25)

GUISetState(@SW_SHOW)

#endregion ### END Koda GUI section ###

---------->

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $bsen

Local $Sockets = $oSrv.SocketIDList()

If $oSrv.Broadcast($Sockets, 'bsend') Then

MsgBox(0,'','all')

EndIf

EndSwitch

; ---

$oSrv.Process()

__Process($nMsg)

WEnd

is not send...msg..help me....

Edited by davidkim

I interest am many quite in AutoitScript.From that is [http://cafe.naver.com/autoitscript[/color]] Korea of cafe(blog) to be operating, [size="2"][color="#ff00ff"]English cannot well[/size].Many help it requests.To read, it stands it thanks.

Link to post
Share on other sites

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $bsen

Local $Sockets = $oSrv.SocketIDList()

If $oSrv.Broadcast($Sockets, 'bsend') Then ; is not send...

MsgBox(0,'','all')

EndIf

;/// is var enable....

_ArrayDisplay($__TCPServer_Sockets)

For $i = 0 To $oSrv.max_clients - 1

If $__TCPServer_Sockets[$i][0] <> -1 Then TCPSend($__TCPServer_Sockets[$i][0], 'bsend')

;// is send not.......

Next

help me...

EndSwitch

; ---

$oSrv.Process()

__Process($nMsg)

WEnd

I interest am many quite in AutoitScript.From that is [http://cafe.naver.com/autoitscript[/color]] Korea of cafe(blog) to be operating, [size="2"][color="#ff00ff"]English cannot well[/size].Many help it requests.To read, it stands it thanks.

Link to post
Share on other sites

Your problem is that you have not well read the documentation of the broadcast method. It takes only one parameter: The data to be sent.

Why do you pass it the socketID list???!!!

#region ### START Koda GUI section ###
$GUI_Main = GUICreate("Mini-Server", 1408, 228)
$tab = GUICtrlCreateTab(6, 6, 1297, 217)
$bsen = GUICtrlCreateButton('bsend', 1300, 6, 100, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $bsen
   If $oSrv.Broadcast('bsend') Then
    MsgBox(0, '', 'all')
   EndIf
EndSwitch
; ---
$oSrv.Process()
__Process($nMsg)
WEnd
Link to post
Share on other sites
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By SEuBo
      Hi there,
      while I created an example script to generate and execute a function during runtime, I stumbled across a neat way to share data between running autoit scripts.
      This is done using the amazing magic of  AutoItObject_Internal . (You'll need at least Version 3.0.0 of AutoItObject_Internal)
      Using this UDF, you can create a shared data storage, basically an empty "AutoitObject_Internal-"Object which you can then use to write / read data Inline. no set/get methods, just
      #include "AutoItSharedData.au3" $oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID") $oShare.some_data = 'foo' and you're done. any other script accessing this data will have to do:
      #include "AutoItSharedData.au3" $oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID") ConsoleWrite($oShare.some_data & @LF)  
      Basically it's Larsj's Implementing IRunningObjectTable Interface, but you dont have a Dictionary, but an IDIspatch Object instead.
      There are already a bunch of IPC options available - and this is another one.
      AutoItSharedData.au3
       
      Example Script 1
       
      Example Script 2
      Output: 
      To test: run Example Script 1, Then run example Script 2.. or the other way around.
      Example Script 3
      Example_sharedata3.au3
      Example_sharedata3_Controlsend.au3
      Example_sharedata3_Tooltip.au3
      To test: run Example_sharedata3.au3.
      Output: 
       
       Example SharedData4:
      Output: 
      /Edit: Please note that there's a limitation with the Running object table :
      The Script accessing a variable first, will be the "server" for this variable. This means, access to that variable from other scripts should only be possible, as long the "server" script is running! Use appropriate Object Error handlers in case you don't want the surviving "clients" to crash.
      Feedback and/or improvements appreciated
       
      changelog
      version 2.0
      Removed need for AutoItObject, as AutoItObject_Internal now comes with ROT support Added UDF Header Fixed typo on "#include AutoItObjectInternal.au3" -> "#include AutoItObject_Internal.au3" Added ObjGet() after registering the object fails (in case 2 programs tried to register the same ID simultaneously) Updated Examples & zip archive. Cheers,
       
      AutoItSharedData.zip
    • By HurleyShanabarger
      Hello,
       
      I am trying to convert code from C# to AutoIt. This is the code:
      byte[] lv_aKey = { 23, 82, 107, 6, 35, 78, 88, 7 }; byte[] lv_aPwd = ToByteArray(password); //--> here I don't know which AutoIt function to use DES des = new DESCryptoServiceProvider(); des.Padding = PaddingMode.None; des.Mode = CipherMode.ECB; ICryptoTransform dec = des.CreateDecryptor(lv_aKey, null); dec.TransformBlock(lv_aPwd, 0, lv_aPwd.Length, response, 0); //<-- here I don't know which AutoIt function to use return System.Text.ASCIIEncoding.ASCII.GetString(response); I am having problems with the crypt functions - can someone point me in the right direction?
    • By tarretarretarre
      Version 2.x.x and 3.x.x has been moved to branch 3.x
      About Autoit-Socket-IO
      Autoit-Socket-IO is a event driven TCP/IP wrapper heavily inspired from Socket.IO with focus on user friendliness and long term sustainability.
      I constantly want to make this UDF faster and better, so if you have any suggestions or questions (beginner and advanced) Do not hesitate to ask them, I will gladly help!
      Key features
      Simple API 99% data-type serialization thanks to Autoit-Serialize Can easily be extended with your own functionality thanks to Autoit-Events "Educational" examples Data encryption thanks to _<Crypt.au3> Limitations
      Speed. This UDF will sacrifice some speed for convenience Getting started
      Download the script from AutoIt or pull it from the official github repo git@github.com:tarreislam/Autoit-Socket-IO.git and checkout the tag 4.0.0-beta Check out the documentaion Take a look in the examples/ folder Changelog
      To see changes from 3.x.x and 2.x.x please checkout the 3.x branch
      Version 4.0.0-beta (This update break scripts.)
      Code base fully rewritten with Autoit-Events and decoupled to improve code quality and reduce bloat. The new UDF is very different from 3.x.x so please checkout the UPGRADE guide to fully understand all changes Added new documentation documentaion Success stories
      Since December 2017-now I have used version 1.5.0 in an production environment for 150+ clients with great success, the only downtime is planned windows updates and power outages.
       
      Newest version (2020-09-15!)

       
      Older versions (Not supported anymore)
      Autoit-Socket-IO-1.0.0.zip Autoit-Socket-IO-1.1.0.zip Autoit-Socket-IO-1.3.0.zip Autoit-Socket-IO-1.4.0.zip Autoit-Socket-IO-1.5.0.zip
      Autoit-Socket-IO-2.0.0.zip
    • By tarretarretarre
      Version 2.x.x and 3.x.x has been moved to branch 3.x
      About Autoit-Socket-IO
      Autoit-Socket-IO is a event driven TCP/IP wrapper heavily inspired from Socket.IO with focus on user friendliness and long term sustainability.
      I constantly want to make this UDF faster and better, so if you have any suggestions or questions (beginner and advanced) Do not hesitate to ask them, I will gladly help!
      Key features
      Simple API 99% data-type serialization thanks to Autoit-Serialize Can easily be extended with your own functionality thanks to Autoit-Events "Educational" examples Data encryption thanks to _<Crypt.au3> Limitations
      Speed. This UDF will sacrifice some speed for convenience Read more in the official thread
    • By TheXman
      Purpose (from Microsoft's website)
      The HTTP Server API enables applications to communicate over HTTP without using Microsoft Internet Information Server (IIS). Applications can register to receive HTTP requests for particular URLs, receive HTTP requests, and send HTTP responses. The HTTP Server API includes SSL support so that applications can exchange data over secure HTTP connections without IIS.
      Description
      There have been several times in the past that I wanted to either retrieve information from one of my PCs or execute commands on one of my PCs, whether it was from across the world or sitting on my couch.  Since AutoIt is one of my favorite tools for automating just about anything on my PC, I looked for ways to make to make it happen.  Setting up a full blown IIS server seemed like overkill so I looked for lighter weight solutions.  I though about creating my own AutoIt UDP or TCP server but that just wasn't robust enough,  Then I found Microsoft's HTTP Server API and it looked very promising.  After doing a little research into the APIs, I found that it was flexible & robust enough to handle just about any of the tasks that I required now and in the future.  So a while back I decided to wrap the API functionality that I needed into an AutoIt UDF file to allow me to easily create the functionality I needed at the time.  It has come in very handy over the years.  Of course it wasn't all wrapped up with a nice little bow like it is now.  That only happened when I decided to share it with anyone else who could use it or learn from it.
      The example file that I included is a very granular example of the steps required to get a lightweight HTTP Server up and listening for GET requests.  The UDF is a wrapper for the Microsoft APIs.  That means to do anything over and above what I show in the example, one would probably have to have at least a general knowledge of APIs or the ability to figure out which APIs/functions to use, what structures and data is needed to be passed to them, and in what order.  However, the UDF gives a very solid foundation on which to build upon.  Of course, if anyone has questions about the UDF or how to implement any particular functionality, I would probably help to the extent that I could or point you in the right direction so that you can figure out how to implement your own solution.
      The APIs included in the UDF are the ones that I needed in the past to do what I needed to do.  If any additional APIs need to be added to the UDF file, please make those suggestions in the related forum topic.
      Being that this is basically an AutoIt wrapper for the Microsoft API functions, there's no need to create AutoIt-specific documentation.  All of the UDF functions, structures, constants, and enumerations are named after their Microsoft API counterparts.  Therefore, you can refer to Microsoft's extensive documentation of their HTTP Server API.  As stated earlier, if there is one or more APIs that you find yourself needing for your particular solution, please suggest it in the related Example Scripts forum topic.
      Related Links
      Microsoft HTTP Server API - Start Page
      Microsoft HTTP Server API - API v2 Reference
      Microsoft HTTP Server API - Programming Model
×
×
  • Create New...