AutoHotkey Community

It is currently May 25th, 2012, 10:13 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: July 2nd, 2007, 8:25 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
Can it be used script to script ?

This does not work for me. Running script 1 should give 3 message boxes. I don't even get 1.

Script1.ahk
Code:
#Persistent

CB1   := RegisterCallback("CallBack1")
CB2 := RegisterCallback("Callback2")
Run, %A_AhkPath% Script2.ahk %CB1% %CB2%
return

CallBack1(Val)
   {
   MsgBox,Callback1 %Val%
   }
   
CallBack2(Val)
   {
   MsgBox,Callback2 %Val%
   }

   
Esc::ExitApp

Script2.ahk
Code:
CB1Addr = %1%
CB2Addr = %2%

CB1 := DllCall(CB1Addr,int,1)
CB2 := DllCall(CB2Addr,int,2)

MsgBox, CB1 - %CB1%`nCB2 - %CB2%
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2007, 12:00 am 
I can't see what is wrong with this either :(
This was something I have been meaning to experiment with.. but haven't tried until now. The errorlevel from dllcall on your script2 is 0xC0000005 (access violation).. but same call works fine from script1 :?:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2007, 12:12 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8647
Location: Salem, MA
that is probably too close to each reading the other's process memory.

does it work if you #include it instead of running it?

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2007, 12:26 am 
engunneer wrote:
does it work if you #include it instead of running it?
Well yes.. but that defeats the script to script communication trying to be accomplished since it would all be from within the same processor thread..


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2007, 6:55 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8647
Location: Salem, MA
I know, but it proves all the other code is correct (no typos anyway)

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 3rd, 2007, 12:18 pm 
ahklerner wrote:
Can it be used script to script ?
No.

As engunneer says, they run in different memory areas, so you can't use this.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2007, 2:06 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
How can the system run it then...there must be a way.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2007, 4:01 pm 
ahklerner wrote:
How can the system run it then...
Run what?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2007, 9:49 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
the machine code that is at the address given by RegisterCallback


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2007, 10:01 pm 
Quote:
Upon success, RegisterCallback() returns a numeric address that may be called by DllCall() or anything else capable of calling a machine-code function.

I interpret the anything else to actually mean anything else!! There has to be a way; otherwise- I think that the documentation should be adjusted to help clearify.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 4th, 2007, 4:03 pm 
ahklerner wrote:
the machine code that is at the address given by RegisterCallback
The system is the OS: it knows what is the memory mapping of each application it runs...
Same for a DLL use with LoadLibrary: its functions run in the same memory space as the program.
The second script doesn't has this knowledge, it is a separate process.

Now, daniel2 has a point, it is a limitation...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 5th, 2007, 10:11 pm 
Helpy wrote:
Same for a DLL use with LoadLibrary: its functions run in the same memory space as the program. The second script doesn't has this knowledge, it is a separate process....
Documentation wrote:
anything else capable of calling a machine-code function
So basically-- your saying that your registercallback address can't be called by anything else except the parent script-- or a dllcall in the parent script :?:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2007, 10:44 pm 
Offline

Joined: July 23rd, 2007, 3:43 am
Posts: 47
ahklerner- Although it doesn't use register callback, majkinetor put together an excellant function to handle instant communication between scripts.

IPC - Inter Process Communication


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2007, 2:55 am 
Offline

Joined: November 2nd, 2004, 2:43 pm
Posts: 1019
Location: London, UK
i could be way of the mark here, but i believe nircmd from www.nirsoft.net allows you to read a processes memory, could you combine the two????

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2007, 6:02 am 
Offline

Joined: July 23rd, 2007, 3:43 am
Posts: 47
Superfraggle wrote:
i believe nircmd from www.nirsoft.net allows you to read a processes memory
I believe the point of this thread was to establish communication from one script to another (for passing values back and forth..). Although the experiments w/ registercallback didn't lead to anything- IPC does.

Superfraggle wrote:
could you combine the two????
I'm not sure I understand; Combine the two what?? the nircmd, IPC, registercallback, other ?

Superfraggle wrote:
i could be way of the mark here
There's always a chance :D


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], just me, snyder and 62 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group