Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[module, ahk & dotNet] IPC 2.6 


  • Please log in to reply
59 replies to this topic
zoulou
  • Guests
  • Last active:
  • Joined: --
Thanks majkinetor for this example. But I was very interested when you said :

He can also use CreateWindowEx to create hidden control and subclass it, in which case it will not receive large number of messages. Then it can receive IPC messages.

So I'd like to have an example of a script with no (at least visible) window which receive an IPC message from an other script with no (at least visible) window. Thanks by advance

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
Just don't use Gui, Show then :!:
Posted Image

zoulou
  • Guests
  • Last active:
  • Joined: --
OK. Sorry I'm a noob. So there is no problem using IPC_OnMessage and IPC_Send without any window.
Thanks for all your marvelous work (IPC, MMenu, etc)

infogulch
  • Moderators
  • 717 posts
  • Last active: Jul 31 2014 08:27 PM
  • Joined: 27 Mar 2008
Cool!

Now that 1.0.48 is out, you could use IsFunc() and allow specifying a function instead of only a label. Or maybe both. I guess I personally just have issues with global variables. :p

Btw, I noticed that the static id var isn't used in the receiving function.

Thanks, majkinetor!

:)

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
Thanks.

About your suggestion, yes, sure, most recent modules use functions regeardless of IsFunc, plus, there are other improvementes which makes them better candidates for APIs.

Ill do it if I return to AHK programming.
Posted Image

hughman
  • Members
  • 192 posts
  • Last active: Feb 14 2016 06:59 AM
  • Joined: 11 Feb 2007
Is it possible to communicate between local process and remote?

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
version 2.0

- Removed all globals
- Label switched to function
- API changed a bit to support sending binary data.
Posted Image

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
majkinetor, currently the Hwnd parameter of the Handler function is always your "security ID" 951753, despite being documented as "Handle of the window passing data". I think it woud be best to either remove this parameter or discard the "security ID" feature (i.e. pass an actual hwnd and let the script rely on port numbers or some other mechnism for "security").

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
*** version 2.01 ***

- Bugfixes.
- Security ID removed.
- Docs updated.


Ty Lex.

PS: The point of sec ID was for script to make less likely that other app will send COPYDATA (i.e. for module to know its own messages). I removed it nevertheless.
Posted Image

Fry
  • Members
  • 885 posts
  • Last active: Jan 17 2011 09:57 PM
  • Joined: 01 Nov 2007
Can you post an example for say, shutting down a script from another?

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
That would probably be a bad example since it can be done more easily by simply closing the 'ahk_class AutoHotkey' window. (It has been covered many times before on the forums.) There isn't much to the IPC module; the example included in the download should be sufficient.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
I am constantly using IPC for situations in which I have some kind of console that sets up execution of some independent scripts that notify console about execution details.

For instance, my latest project was involving Task Scheduler in AHK that instantiates dozen of scripts as scheduled tasks. Tasks send execution details to log control kept by the scheduler script.
Posted Image

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
*** version 2.5 ***

+ Added DotNet library in IPC.cs (classes IPC, IPCEventArgs). The API is the same as with IPC.ahk (minus obvious AHK vs C# differences)
+ IPC_Test.exe sample for DotNet <-> AHK communication.
Posted Image

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
It seems that DotNet part doesnt work correctly on 64bit systems.

Ill see more about it, but If somebody can test on 32 and 64bit on their own, it could help.

Ty.
Posted Image

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
majkinetor, the first and last fields of COPYDATASTRUCT are pointer-sized, i.e. 64-bit in 64-bit applications:
typedef struct tagCOPYDATASTRUCT {
    [color=red]ULONG_PTR[/color] dwData;
    DWORD cbData;
    [color=red]PVOID[/color] lpData;
} COPYDATASTRUCT, *PCOPYDATASTRUCT;
[StructLayout(LayoutKind.Sequential)]
	struct COPYDATASTRUCT
	{
		public [color=red]int[/color] dwData;
		public int cbData;
		public [color=red]int[/color] lpData;
	}
I suppose IntPtr is the appropriate managed type to use for these two fields.

Edit: After correcting that, the rest is mostly straight-forward as long as you don't do this:
ea.Port = CD.dwData.ToInt32();
What we want to be -100 is treated as 0xFFFFFF9C. Since that's outside the range of an int, OverflowException is thrown and the WndProc silently fails. Very annoying and IMO rediculous, but the following works:
ea.Port = (int)CD.dwData.ToInt64();
(Also edit: "i.e. 64-bit on 64-bit Windows" was inaccurate.)