Jump to content

A simple fast IPC based on Windows Messaging


Nine
 Share

Recommended Posts

... I suppose by placing a #RequireAdmin on one of the scripts (?)

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • 1 month later...

Added to the wiki :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 1 year later...

I was hoping to use this UDF, but the example server and client don't communicate for me. I added some ConsoleWrites to the client and found it does one of 3 things:

* it will wait in the '_WCD_IsServerAvailable' loop forever waiting for the server to be available
* it will find the server repeatedly but receive no response
* the client will crash AutoIt with "AutoIt3.exe ended.rc:-1073740771" (it continues even after adding a global COM error handler)

I'm running on Windows 10 Enterprise 21H2 and both scripts are run without admin permissions. Do you know if it's possible that this feature could be blocked?

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

@seadoggie01  I am unable to reproduce your error.  Tested on Win10 home edition 21H1 with the example I provided.  I tested all scenarios with and without #RequireAdmin, no issue.  Could you describe exactly what you are doing ?

22 minutes ago, seadoggie01 said:

Do you know if it's possible that this feature could be blocked?

I don't understand your question.

Link to comment
Share on other sites

I slightly modified the WaitForResponse function to add some ConsoleWrite statements and added a global error handler at the top of the script

Global $oErrFunc = ObjEvent("AutoIt.Error", "ErrFunc")

; [...]

Func WaitForResponse ()
  Local $sResp
  ConsoleWrite("Waiting for server" & @CRLF)
  While _WCD_IsServerAvailable ()
    ConsoleWrite("Server is available!" & @CRLF)
    $sResp = _WCD_Client_GetResponse ()
    If $sResp <> "" Then Return $sResp
    Sleep (100)
  WEnd
EndFunc

Func ErrFunc($oError)
    MsgBox($MB_OK, "We intercepted a COM Error !", _
            "Number: 0x" & Hex($oError.number, 8) & @CRLF & _
            "Description: " & $oError.windescription & _
            "At line: " & $oError.scriptline)
EndFunc   ;==>ErrFunc

Then I run the server file from the command line and started the client from SciTE.

By "Do you know if this feature could be blocked?" I mean, I'm in a heavily locked down work environment and was wondering if it's possible that this form of communication could be blocked by some program/policy/etc by IT for security concerns.

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

The COM handler is useless since the UDF is solely based on Windows Messaging System.  I do not use any COM object in my code.  Nothing is mentioned in MSDN about blocking this message, but I am not an expert about security, so in other words, I don't know.  However, I am sure that your security guys can answer this question.  One thing you could try is to put both client and server in verbose mode :

$_WCD_Verbose = True

Log is in WCD_Logfile.log.  Before starting delete this file if it already exists.

Link to comment
Share on other sites

@seadoggie01

You could try to force the message to be allowed by putting this at the beginning of both client and server script :

If Not _WinAPI_ChangeWindowMessageFilterEx(0, $WM_COPYDATA, $MSGFLT_ALLOW) Then Exit MsgBox(0, "Error", "Unable to allow message")

 

Link to comment
Share on other sites

Sorry for the delay, another project came up at work. With that added line, both scripts ran and I got the same results. I'll try testing this at home to see if I can reproduce or if it's related to my work environment. Hopefully I'll update this soon! :) Thanks for the help either way!

Edit: Finally tested at home and it works fine. It seems it's related to my work environment, darn, another great script I can't use 😐

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

  • 1 year later...

Thank you for this UDF.

One question though, does this UDF relies on tray icon and it's events? Why does it have this:

Opt("TrayOnEventMode", 1)
  Opt("TrayMenuMode", 1)
  Opt("TrayAutoPause", 0)
  TraySetIcon("shell32.dll", 300)
  TraySetOnEvent($TRAY_EVENT_PRIMARYUP, __WCD_Exit)
  TraySetState($TRAY_ICONSTATE_SHOW)
  TraySetToolTip("Left click to Exit WCD Server")

Unless this is required somehow, this should be handled by the script, not UDF...Simple exiting script should never be done by UDF, because script might require it's own cleaning up on exit.

Link to comment
Share on other sites

I understand your arguments and they are quite valid.  I wanted to offer an easy way to exit the server, and a check if there are still messages waiting in queue. But this can be made optional if need be.  Meanwhile, If you want to clean up your server script, you can use OnAutoItExitRegister (as you probably know)

Link to comment
Share on other sites

Another suggestion if I may. To allow use this UDF in multiple applications on the same machine, perhaps the server name could be supplied as an argument to the _WCD_CreateServer().

This will also allow create a more secure link between two instances of the same script (i.e. using Multi-task udf) by generating random server name, or run two servers for a true 2-way communication.

Link to comment
Share on other sites

Doable, in fact it is quite simple to implement.  But it would create a large breach in the security of the UDF. 

Let's say one decides to create multiple servers in a single script.  Then all servers would share the same queue, the same handler, the same thread.  Not brilliant, but it would make it possible to do.

As the title says, I want to make it simple, so anyone with little knowledge of IPC can use it.

Link to comment
Share on other sites

Not sure what security breach you are referring to...if nothing else, it would make it more secure since outside applications won't be able send messages to static WCDServer server.

Having multiple servers in the same instance of the script doesn't make sense to begin with...I was referring to running the same script as separate processes on the same machine.

To make this possible in current UDF all it needs is make $WCD_SERVER_WINDOW_NAME as non-constant variable (so it can be set by the script) and use it in _singleton (?)

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...