| View previous topic :: View next topic |
| Author |
Message |
ahklerner
Joined: 26 Jun 2006 Posts: 1381 Location: USA
|
Posted: Mon Jul 02, 2007 7:25 pm Post subject: Register callback...I need help or better understanding. |
|
|
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
|
|
|
| Back to top |
|
 |
daniel2 Guest
|
Posted: Mon Jul 02, 2007 11:00 pm Post subject: |
|
|
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  |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 8255 Location: Maywood, IL
|
Posted: Mon Jul 02, 2007 11:12 pm Post subject: |
|
|
that is probably too close to each reading the other's process memory.
does it work if you #include it instead of running it? _________________
(Common Answers) |
|
| Back to top |
|
 |
daniel2 Guest
|
Posted: Mon Jul 02, 2007 11:26 pm Post subject: |
|
|
| 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.. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 8255 Location: Maywood, IL
|
Posted: Tue Jul 03, 2007 5:55 am Post subject: |
|
|
I know, but it proves all the other code is correct (no typos anyway) _________________
(Common Answers) |
|
| Back to top |
|
 |
Helpy Guest
|
Posted: Tue Jul 03, 2007 11:18 am Post subject: Re: Register callback...I need help or better understanding. |
|
|
| 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. |
|
| Back to top |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1381 Location: USA
|
Posted: Tue Jul 03, 2007 1:06 pm Post subject: |
|
|
| How can the system run it then...there must be a way. |
|
| Back to top |
|
 |
Helpy Guest
|
Posted: Tue Jul 03, 2007 3:01 pm Post subject: |
|
|
| ahklerner wrote: | | How can the system run it then... | Run what? |
|
| Back to top |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1381 Location: USA
|
Posted: Tue Jul 03, 2007 8:49 pm Post subject: |
|
|
| the machine code that is at the address given by RegisterCallback |
|
| Back to top |
|
 |
daniel2 Guest
|
Posted: Tue Jul 03, 2007 9:01 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Helpy Guest
|
Posted: Wed Jul 04, 2007 3:03 pm Post subject: |
|
|
| 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... |
|
| Back to top |
|
 |
daniel2 Guest
|
Posted: Thu Jul 05, 2007 9:11 pm Post subject: |
|
|
| 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  |
|
| Back to top |
|
 |
daniel2
Joined: 23 Jul 2007 Posts: 47
|
Posted: Thu Aug 02, 2007 9:44 pm Post subject: |
|
|
ahklerner- Although it doesn't use register callback, majkinetor put together an excellant function to handle instant communication between scripts.
IPC - Inter Process Communication |
|
| Back to top |
|
 |
Superfraggle
Joined: 02 Nov 2004 Posts: 1019 Location: London, UK
|
Posted: Fri Aug 03, 2007 1:55 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
daniel2
Joined: 23 Jul 2007 Posts: 47
|
Posted: Fri Aug 03, 2007 5:02 am Post subject: |
|
|
| 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  |
|
| Back to top |
|
 |
|