AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Register callback...I need help or better understanding.
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
ahklerner



Joined: 26 Jun 2006
Posts: 1381
Location: USA

PostPosted: Mon Jul 02, 2007 7:25 pm    Post subject: Register callback...I need help or better understanding. Reply with quote

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
View user's profile Send private message
daniel2
Guest





PostPosted: Mon Jul 02, 2007 11:00 pm    Post subject: Reply with quote

I can't see what is wrong with this either Sad
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 Question
Back to top
engunneer



Joined: 30 Aug 2005
Posts: 8255
Location: Maywood, IL

PostPosted: Mon Jul 02, 2007 11:12 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
daniel2
Guest





PostPosted: Mon Jul 02, 2007 11:26 pm    Post subject: Reply with quote

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

PostPosted: Tue Jul 03, 2007 5:55 am    Post subject: Reply with quote

I know, but it proves all the other code is correct (no typos anyway)
_________________

(Common Answers)
Back to top
View user's profile Send private message Visit poster's website
Helpy
Guest





PostPosted: Tue Jul 03, 2007 11:18 am    Post subject: Re: Register callback...I need help or better understanding. Reply with quote

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

PostPosted: Tue Jul 03, 2007 1:06 pm    Post subject: Reply with quote

How can the system run it then...there must be a way.
Back to top
View user's profile Send private message
Helpy
Guest





PostPosted: Tue Jul 03, 2007 3:01 pm    Post subject: Reply with quote

ahklerner wrote:
How can the system run it then...
Run what?
Back to top
ahklerner



Joined: 26 Jun 2006
Posts: 1381
Location: USA

PostPosted: Tue Jul 03, 2007 8:49 pm    Post subject: Reply with quote

the machine code that is at the address given by RegisterCallback
Back to top
View user's profile Send private message
daniel2
Guest





PostPosted: Tue Jul 03, 2007 9:01 pm    Post subject: Reply with quote

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





PostPosted: Wed Jul 04, 2007 3:03 pm    Post subject: Reply with quote

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





PostPosted: Thu Jul 05, 2007 9:11 pm    Post subject: Reply with quote

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 Question
Back to top
daniel2



Joined: 23 Jul 2007
Posts: 47

PostPosted: Thu Aug 02, 2007 9:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 1019
Location: London, UK

PostPosted: Fri Aug 03, 2007 1:55 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
daniel2



Joined: 23 Jul 2007
Posts: 47

PostPosted: Fri Aug 03, 2007 5:02 am    Post subject: Reply with quote

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 Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group