 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
ginandtonic Guest
|
Posted: Sat Jan 09, 2010 4:57 pm Post subject: Why is OnMessage() ignoring my message? |
|
|
I used SendMessage to send two integers to a script
| Code: |
prev_sdHWND := sdHWND
prev_sdtHWND := sdtHWND
SetTitleMatchMode 2
detectHiddenWindows on
run SynDownload.ahk
WinWait, SynDownload.ahk
while (prev_sdHWND = sdHWND)
ControlGet, sdHWND, Hwnd,,, SynDownload.ahk
run SynDownloadTimer.ahk
WinWait, SynDownloadTimer.ahk
while (prev_sdtHWND = sdtHWND)
ControlGet, sdtHWND, Hwnd,,, SynDownloadTimer.ahk
SendMessage, 0x305D, %timeout%, %sdHWND%,, ahk_id %sdtHWND%
msgbox %errorlevel%
|
And in SynDownloadTimer.ahk:
| Code: |
OnMessage(0x305D, "InitializeTimer")
return
InitializeTimer(wParam, lParam)
{
global timeout := wParam
global sdHWND := lParam
SetTimer, InitTimer, -50
return 537
}
|
The problem is I quite often get an errorLevel of 0 instead of 537. What does this mean and how can I fix it?
Any other comments/suggestions on code snippets always welcome. |
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 448
|
Posted: Sun Jan 10, 2010 11:48 am Post subject: |
|
|
I can't explain . | ginandtonic wrote: | | The problem is I quite often get an errorLevel of 0 instead of 537. | What's often (ratio SendMessage/return 0)? |
|
| Back to top |
|
 |
svi
Joined: 09 Oct 2006 Posts: 236 Location: Finland
|
Posted: Sun Jan 10, 2010 7:19 pm Post subject: |
|
|
When you leave the control parameter blank in | Code: | | ControlGet, sdtHWND, Hwnd,,, SynDownloadTimer.ahk | the message is sent to... | The Manual wrote: | | the target window's topmost control | , which seems to be Edit1.
Using it I always got errorlevel 0. _________________ Pekka Vartto |
|
| Back to top |
|
 |
ginandtonic Guest
|
Posted: Sun Jan 10, 2010 11:55 pm Post subject: |
|
|
| THANK YOU THANK YOU THANK YOU. I switched ControlGet, HWND to WinGet, ID and it's working great now. |
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 448
|
Posted: Mon Jan 11, 2010 12:53 am Post subject: |
|
|
@svi: Yeah right, I didn't check that.
@ginandtonic: | ginandtonic wrote: | | What does this mean and how can I fix it? | You got me there with your trick question. It means the script itself was not receiving the message at all. With as a result returning the zero value.
BUT, why did it sometimes received the message then (with one and the same script)?  |
|
| Back to top |
|
 |
ginandtonic Guest
|
Posted: Mon Jan 11, 2010 1:06 am Post subject: |
|
|
Peter, I also wondered why it WAS working some of the time. I didn't write any controls to the receiving scripts.
svi seems to be saying that an Edit1 control is automatically created when a script is run? The message was getting through about 1 time out of 3. Is it possible that the sending script retrieved the window handle before it could create a control? |
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 448
|
Posted: Mon Jan 11, 2010 2:10 am Post subject: |
|
|
| ginandtonic wrote: | | svi seems to be saying that an Edit1 control is automatically created when a script is run? | There is, on the hidden AHK main window. | ginandtonic wrote: | | Is it possible that the sending script retrieved the window handle before it could create a control? | Well, I did some small tests, and this looks interesting:
It seems that ControlGet returns a handle of the GUI itself, when that GUI doesn't contain any control! In that case your script will work, like you say, if maybe the control is not yet created.
I had in the past some similar thoughts about control ID and window ID commands (or the ID concept itself), there doesn't seems to be a strict separation between them. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|