Jump to content

Communication between Program and Service


Recommended Posts

Hello all!

I have two AutoIT scripts. One, is being run as a service, the other is a program that is run on demand. I need to find a way for these two to communicate with each other - passing a few strings from the on-demand program to the service. I've done a lot of searching on the forums, and I found this example, which works well for two on-demand programs, but it does not work as well when a service is involved. There are some other ideas around the forums here, but they seemed to be "spotty" - listing bits and pieces of code that I was unable to get working together.

So, do you all have any ideas that would allow me to send some strings from a user-run on-demand AutoIT script to an AutoIT script running as a service. If it helps to know, I am looking to have this working under both Windows XP and Windows 7 (don't need Vista compatibility).

Thanks! :)

Link to comment
Share on other sites

Hello all!

I have two AutoIT scripts. One, is being run as a service, the other is a program that is run on demand. I need to find a way for these two to communicate with each other - passing a few strings from the on-demand program to the service. I've done a lot of searching on the forums, and I found this example, which works well for two on-demand programs, but it does not work as well when a service is involved. There are some other ideas around the forums here, but they seemed to be "spotty" - listing bits and pieces of code that I was unable to get working together.

So, do you all have any ideas that would allow me to send some strings from a user-run on-demand AutoIT script to an AutoIT script running as a service. If it helps to know, I am looking to have this working under both Windows XP and Windows 7 (don't need Vista compatibility).

Thanks! :)

Why does WM_COPYDATA not work for a service? Or does the service process not have a window? If the that is the problem then just create a window even though it isn't used (apart from being needed for messages) and you don't need to make it visible. Otherwise I would be interested to know what the problem is.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

The service process does not have a visible window. I have created one and done GUISetState($myGUI,$GUI_HIDE) on it, so that it would be created but not visible. The service is set to write a log file and I can see its main loop running, but it never receives any messages. The user run program is attempting to locate the service with WinGetHandle(). I have also tried getting the PID and then converting that to a window handle, but it simply causes the user program to lockup.

Edit: Since I am doing all of my primary testing under Windows 7, it seems like the user-program is unable to locate the service, even when provided with its Process ID. Maybe there is a communication barrier there? I don't seem to be able to make contact with any program under session 0 (where the service is), only with those under session 1, where the user program is. Thoughts?

Edited by HopkinsProg
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...