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 

Generic Callback Example - EnumWindows
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Mystiq



Joined: 08 Jan 2007
Posts: 19

PostPosted: Thu May 24, 2007 12:40 pm    Post subject: Reply with quote

Interesting. Smile

Im assuming this "callback dll" would allow now to use the "ReadDirectoryChangesW", which shimanov mentioned in other thread (see below), to detect specific changes in directory?

http://www.autohotkey.com/forum/topic7213.html
http://msdn2.microsoft.com/en-us/library/aa365465.aspx

Sorry for this "noobish" question. I dont have much experience with these types of stuff... Embarassed
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1338

PostPosted: Thu May 24, 2007 2:14 pm    Post subject: Reply with quote

Joy2DWorld wrote:
well, obviously, need a new assembly of the cut & minimized asm...

You're right. I realized that after posted.
To have it as the machine code would be useful in might-be cases when we're not allowed to install callback.dll.
The best solution, however, will be that Chris implements it into AHK as a built-in function.
I hope Chris take a look at the source code provided by JGR.
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Fri May 25, 2007 6:53 am    Post subject: Reply with quote

I've tried to apply the asm, but it's not working for me... likely I'm missing something in the structure for the messaging or the callback reception parms. (although shifting over the pointers does seem straightfoward).

very hard for me to debug, as will not run as is, ie. without any wrapping... and inside AHK... no help in debugging...

likely am missing something small (?)... will work some more at it.


YES... maybe Chris will add call back ... would be nice...

Maybe JGR could also strip, assemlble & post the hex...

but even so... the dll sure looks promising... especially for my own personal dream of dll serving..!! [to front end word, for example]
_________________
Joyce Jamce
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1338

PostPosted: Fri May 25, 2007 8:47 am    Post subject: Reply with quote

If you need test with ASM/machine code, you may try these.

libtcc.dll posted by Laszlo.
fbsl which has a built-in function CallAbsolute() that can execute a machine code.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sat May 26, 2007 1:16 am    Post subject: Reply with quote

Until callbacks become a built-in feature, I've linked to this topic from the DllCall page.

As for when callbacks will become built-in, I was hoping to do it in a professional, feature-rich way like DllCall. However, that takes considerably more time, which is why it will probably be many months before I get to it. The alternatives to waiting are:

1) Another developer codes the feature (perhaps taking syntax ideas from DllCall).
2) Add a "lite" version of callbacks (perhaps based on this DLL). But even this might take me considerable time to do properly because I don't understand the intricacies and interactions as well as some of you might.
Back to top
View user's profile Send private message Send e-mail
nnesori



Joined: 14 Oct 2006
Posts: 15
Location: south korea

PostPosted: Thu Jun 14, 2007 11:10 am    Post subject: Callback doesn't work on my Xp. Reply with quote

Hi, Everybody. I'm AHK user.
first, Thanks to JGR.

I have two computers. One is Windows2000pro
and the other is WindowsXpProSp2.

and, I tried first example. (http://www.autohotkey.net/~JGR/callback.rar)

Callback works well on my Windows2000pro. Smile
But it's not working on my XP. Sad

I don't know why.
Can someone help me?



test AHK v1.0.46.17
Microsoft Windows XP Pro version2002 ServicePack 2, v.2622 (Korean version)

Global Variables (alphabetical)
--------------------------------------------------
0[1 of 3]: 0
EnumWindowsProcStub[6 of 7]: 422816
ErrorLevel[1 of 63]: 0
hHookModule[8 of 63]: 19922944
hwnd[8 of 63]: 0x350378
out[0 of 0]:
pid[4 of 7]: 3156
Back to top
View user's profile Send private message
foom



Joined: 19 Apr 2006
Posts: 386

PostPosted: Thu Jun 14, 2007 5:21 pm    Post subject: Reply with quote

Hi nnesori,
you should know that an AHK version with buildin callback support is on its way. For more information look here http://www.autohotkey.com/forum/post-127434.html#127434 .
JGR's EnumWindows example would look like this with the experimental AHK version.
Code:
pid:=DllCall("GetCurrentProcessId","Uint")
DetectHiddenWindows, On
hwnd:=WinExist("ahk_pid " . pid)

EnumWindowsProcStub:= RegisterCallback("EnumWindowsProc","Fast")

GoSub doit
OnExit Tidyup

AppsKey & F11::
doit:
    out:=
    DllCall("EnumWindows","UInt",EnumWindowsProcStub,"UInt",255)
    msgbox, % out
return

EnumWindowsProc(hwnd, lParam) {
    global out
    ;DetectHiddenWindows, On  ;Callbacks registered with the "Fast" option inherit global settings
    WinGetTitle, text, ahk_id %hwnd%
    WinGetClass, class, ahk_id %hwnd%
    out.="HWND: ". hwnd . "`tlParam: " . lParam . "`tTitle: " . text . "`tClass: " . class . "`n"
    return 1
}

;Tidyness
Tidyup:
DllCall("GlobalFree", "UInt", EnumWindowsProcStub)
ExitApp
Back to top
View user's profile Send private message
nnesori



Joined: 14 Oct 2006
Posts: 15
Location: south korea

PostPosted: Thu Jun 14, 2007 6:30 pm    Post subject: Callback doesn't work on my Xp. Reply with quote

Thanks for your response.

Quote:
Chris wrote:
In case anyone has time to try it out, here's a test release that contains RegisterCallback():

I tried. But It doesn't work either way. Sad
Back to top
View user's profile Send private message
foom



Joined: 19 Apr 2006
Posts: 386

PostPosted: Thu Jun 14, 2007 10:57 pm    Post subject: Reply with quote

Hmm did you test with the code i posted?
Back to top
View user's profile Send private message
nnesori



Joined: 14 Oct 2006
Posts: 15
Location: south korea

PostPosted: Fri Jun 15, 2007 7:39 am    Post subject: same result. Reply with quote

Yes, I tried your code with AutoHotkey-RegisterCallback.exe.
But, It only show me a empty messagebox on my WinXPSP2. Sad
Of course, Your posted code works well on my Win2000Pro.
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1338

PostPosted: Fri Jun 15, 2007 8:11 am    Post subject: Re: same result. Reply with quote

nnesori wrote:
Yes, I tried your code with AutoHotkey-RegisterCallback.exe.
But, It only show me a empty messagebox on my WinXPSP2. Sad
Of course, Your posted code works well on my Win2000Pro.

Try the following code. Still no output in DebugView which I used intead to display the results?
What is the output in the final MsgBox?

Code:
DetectHiddenWindows, On
MsgBox, % DllCall("EnumWindows", "Uint", RegisterCallback("Window", "Fast"), "Uint", 1) . " | " . ErrorLevel . " | " . A_LastError

Window(hWnd, lParam)
{
   WinGetTitle, sTitle, ahk_id %hWnd%
   WinGetClass, sClass, ahk_id %hWnd%
   OutputDebug, % "hWnd: ". hWnd . "`tTitle: " . sTitle . "`tClass: " . sClass
   Return 1
}
Back to top
View user's profile Send private message
nnesori



Joined: 14 Oct 2006
Posts: 15
Location: south korea

PostPosted: Fri Jun 15, 2007 10:53 am    Post subject: Reply with quote

Hi, sean.

I tried your posted code.

DebugView result:
No message.
Probably, Window(hWnd, lParam)function not executed.


msgBox result:
---------------------------
t.ahk
---------------------------
| 0xc0000005 | 0
---------------------------
확인
---------------------------
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1338

PostPosted: Fri Jun 15, 2007 11:19 am    Post subject: Reply with quote

nnesori wrote:
| 0xc0000005 | 0

This is a memory access violation.
Although I'm not sure if EnumWindows require you to be an admin, are you an admin?
How did you execute the script? Just double clicking it in the explorer?
I.e., actually I suspect this, make sure that there is no other copy of AutoHotkey.exe in your system.
Try save AutoHotkey-RegisterCallback.exe and the script as EnumWindows.ahk in C:\, then execute this:

Code:
C:\AutoHotkey-RegisterCallback.exe C:\EnumWindows.ahk
Back to top
View user's profile Send private message
nnesori



Joined: 14 Oct 2006
Posts: 15
Location: south korea

PostPosted: Fri Jun 15, 2007 1:56 pm    Post subject: Same result Reply with quote

Yes. I am admin.
I renamed original Autohotkey.exe to Autohotkey.bak.
Then, I renamed AutoHotkey-RegisterCallback.exe to Autohotkey.exe

I excute ahk scripts with dynamicReload.exe.


Also, I tested with your suggestion.

Quote:
C:\AutoHotkey-RegisterCallback.exe C:\EnumWindows.ahk


But, Same result. Sad

Thanks for the help anyway.
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1338

PostPosted: Fri Jun 15, 2007 2:49 pm    Post subject: Re: Same result Reply with quote

nnesori wrote:
Quote:
C:\AutoHotkey-RegisterCallback.exe C:\EnumWindows.ahk

Did you execute it directly from the command prompt or Run box, without using secondary some obscure application?
Are you sure that it's not the bug/intererence of the application you used?
From next time you'll report a bug or whatever, be sure you tested it with standard/common way as with other members.
Otherwise, it would make them waste their precious times for nothing, which was likely in this case.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
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