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 

OnMessage 0x4a is ignored when a ToolTip is displayed

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Kai



Joined: 08 Aug 2009
Posts: 17

PostPosted: Mon Oct 19, 2009 11:35 pm    Post subject: OnMessage 0x4a is ignored when a ToolTip is displayed Reply with quote

Hi.

I have 2 scripts that communicate with each one with onmessage/sendmessage functions. They pass data with 0x4a message (WM_COPYDATA). When on the first script a tooltip is displayed, first script ignore messages from second script.

Isn't this a bug?

[Moderator's note: Moved topic from Bug Reports to Ask for Help.]
Back to top
View user's profile Send private message
Guest






PostPosted: Tue Oct 20, 2009 3:54 am    Post subject: Reply with quote

Most likely not, but we can't know unless you post code.
Back to top
Z_Gecko
Guest





PostPosted: Tue Oct 20, 2009 9:35 am    Post subject: Reply with quote

i run across the same problem(without solving it), check this post: http://www.autohotkey.com/forum/topic31673.html

so here is a demo for this problem:
Sender
Code:
;Sender-Script
RecPID := 1596 ;change this according to the MsgBox in the Receiver-Script
Message := 1111
return
^L::
Message += 1
result := Send_WM_COPYDATA(Message, RecPID)
MsgBox, %result%     
return

Send_WM_COPYDATA(ByRef Message, ByRef RecPID)
{
    VarSetCapacity(CopyDataStruct, 12, 0)
    NumPut(StrLen(Message) + 1, CopyDataStruct, 4)
    NumPut(&Message, CopyDataStruct, 8)
    Prev_DetectHiddenWindows := A_DetectHiddenWindows
    Prev_TitleMatchMode := A_TitleMatchMode
    DetectHiddenWindows On
    SetTitleMatchMode 2
    SendMessage, 0x4a, 0, &CopyDataStruct,, ahk_PID%RecPID%
    DetectHiddenWindows %Prev_DetectHiddenWindows%
    SetTitleMatchMode %Prev_TitleMatchMode%
    return ErrorLevel  ;
}


Receiver
Code:
;Receiver-Script
PID := DllCall("GetCurrentProcessId")
OnMessage(0x4a, "Receive_WM_COPYDATA")
MsgBox, RecPID := %PID%
Tooltip, Waiting
return

Receive_WM_COPYDATA(wParam, lParam)
{
   global BCCCopyOfData
    lpDataAddress := lParam + 8
    lpData := 0
    Loop 4
    {
        lpData := lpData | (*lpDataAddress << 8 * (A_Index - 1))
        lpDataAddress += 1
    }
    DataLength := DllCall("lstrlen", UInt, lpData)
    if DataLength <= 0
        ToolTip %A_ScriptName%`nA blank string was received or there was an error.
    else
    {
        VarSetCapacity(CopyOfData, DataLength)
        DllCall("lstrcpy", "str", CopyOfData, "uint", lpData)
        BCCCopyOfData := CopyOfData
        SetTimer, DoTooltip, -1000
    }
    return true
}

DoTooltip:
   ToolTip %A_ScriptName%`nReceived the following string:`n%BCCCopyOfData%
; sleep, 1000
; Tooltip
return
Back to top
Kai



Joined: 08 Aug 2009
Posts: 17

PostPosted: Tue Oct 20, 2009 10:09 am    Post subject: Reply with quote

Thanks Z_Gecko, and sorry for double-posting.

I did some tests and I think this problem appear when "ahk_PID" is specified in SendMessage. When I specify "ahk_class", and not "ahk_PID", the problem doesn't appear.

In my script (is too long and complex to be posted), a tooltip is refreshed every second, and the problem still remain.
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 7295
Location: Australia

PostPosted: Tue Oct 20, 2009 11:16 am    Post subject: Reply with quote

That makes sense. If you use only ahk_pid, you are specifying "any window in that process." I think that usually means the top-most window in that process; i.e. the tooltip. I suppose the tooltip handles the message (or simply passes it to DefWindowProc) without allowing AutoHotkey a chance to intercept it. There shouldn't be any problem if you specify both ahk_class AutoHotkey and ahk_pid.
Back to top
View user's profile Send private message Visit poster's website
Kai



Joined: 08 Aug 2009
Posts: 17

PostPosted: Tue Oct 20, 2009 12:50 pm    Post subject: Reply with quote

Lexikos wrote:
That makes sense. If you use only ahk_pid, you are specifying "any window in that process." I think that usually means the top-most window in that process; i.e. the tooltip. I suppose the tooltip handles the message (or simply passes it to DefWindowProc) without allowing AutoHotkey a chance to intercept it. There shouldn't be any problem if you specify both ahk_class AutoHotkey and ahk_pid.


I thought that too but, how to specify both ahk_class and ahk_pid? ;D I tried but never worked...
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 4652
Location: AHK Forum

PostPosted: Tue Oct 20, 2009 3:19 pm    Post subject: Reply with quote

Thanks Lexikos, I had that problem as well, looks like it works as it should Smile
Code:
SendMessage, 0x4a, 0, &CopyDataStruct,, ahk_PID %RecPID% ahk_class AutoHotkey

Test
Code:

;Receiver-Script
Receiver=
(
OnMessage(0x4a, "Receive_WM_COPYDATA")
Tooltip, Waiting
return

Receive_WM_COPYDATA(wParam, lParam)
{
   global BCCCopyOfData
    lpDataAddress := lParam + 8
    lpData := 0
    Loop 4
    {
        lpData := lpData | (*lpDataAddress << 8 * (A_Index - 1))
        lpDataAddress += 1
    }
    DataLength := DllCall("lstrlen", UInt, lpData)
    if DataLength <= 0
        ToolTip `%A_ScriptName`%``nA blank string was received or there was an error.
    else
    {
        VarSetCapacity(CopyOfData, DataLength)
        DllCall("lstrcpy", "str", CopyOfData, "uint", lpData)
        BCCCopyOfData := CopyOfData
        SetTimer, DoTooltip, -1000
    }
    return true
}

DoTooltip:
   ToolTip `%A_ScriptName`%``nReceived the following string:``n`%BCCCopyOfData`%
return
)



PID:=RunTempScript(Receiver,"Receiver")


;Sender-Script
Sender=
(
RecPID = %PID%
Message := 1111
Gosub, ^L
return
^L::
Message += 1
result := Send_WM_COPYDATA(Message, RecPID)
MsgBox, `%result`%     
return

Send_WM_COPYDATA(ByRef Message, ByRef RecPID)
{
    VarSetCapacity(CopyDataStruct, 12, 0)
    NumPut(StrLen(Message) + 1, CopyDataStruct, 4)
    NumPut(&Message, CopyDataStruct, 8)
    Prev_DetectHiddenWindows := A_DetectHiddenWindows
    Prev_TitleMatchMode := A_TitleMatchMode
    DetectHiddenWindows On
    SetTitleMatchMode 2
    SendMessage, 0x4a, 0, &CopyDataStruct,, ahk_PID `%RecPID`% ahk_class AutoHotkey
    DetectHiddenWindows `%Prev_DetectHiddenWindows`%
    SetTitleMatchMode `%Prev_TitleMatchMode`%
    return ErrorLevel  ;
}
Return
)

RunTempScript(Sender,"Sender")

ExitApp


RunTempScript(TempScript, name="")
{
   global #__AHK_EXE_
   If Name =
      #__PIPE_NAME_ := A_TickCount
   Else
      #__PIPE_NAME_ := name
   #__PIPE_GA_ := CreateNamedPipe(#__PIPE_NAME_, 2)
   #__PIPE_    := CreateNamedPipe(#__PIPE_NAME_, 2)
   if (#__PIPE_=-1 or #__PIPE_GA_=-1) {
      MsgBox CreateNamedPipe failed.
      Return
   }
   Run, %A_AhkPath% "\\.\pipe\%#__PIPE_NAME_%",,UseErrorLevel HIDE, PID
   If ErrorLevel
      MsgBox, 262144, ERROR,% "Could not open file:`n" #__AHK_EXE_ """\\.\pipe\" #__PIPE_NAME_ """"
   DllCall("ConnectNamedPipe","uint",#__PIPE_GA_,"uint",0)
   DllCall("CloseHandle","uint",#__PIPE_GA_)
   DllCall("ConnectNamedPipe","uint",#__PIPE_,"uint",0)
   script := chr(239) . chr(187) . chr(191) . TempScript
   if !DllCall("WriteFile","uint",#__PIPE_,"str",script,"uint",StrLen(script)+1,"uint*",0,"uint",0)
      MsgBox WriteFile failed: %ErrorLevel%/%A_LastError%
   DllCall("CloseHandle","uint",#__PIPE_)
   Return PID
}

CreateNamedPipe(Name, OpenMode=3, PipeMode=0, MaxInstances=255) {
   return DllCall("CreateNamedPipe","str","\\.\pipe\" Name,"uint",OpenMode
      ,"uint",PipeMode,"uint",MaxInstances,"uint",0,"uint",0,"uint",0,"uint",0)
}

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun Wink
Back to top
View user's profile Send private message
Kai



Joined: 08 Aug 2009
Posts: 17

PostPosted: Tue Oct 20, 2009 3:53 pm    Post subject: Reply with quote

HotKeyIt wrote:
Code:
SendMessage, 0x4a, 0, &CopyDataStruct,, ahk_PID %RecPID% ahk_class AutoHotkey


I tried but it doesn't work to me...
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 4652
Location: AHK Forum

PostPosted: Tue Oct 20, 2009 4:26 pm    Post subject: Reply with quote

Have you tried my example test?
_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun Wink
Back to top
View user's profile Send private message
Kai



Joined: 08 Aug 2009
Posts: 17

PostPosted: Tue Oct 20, 2009 4:58 pm    Post subject: Reply with quote

No, I haven't.
I tried this
Code:
SendMessage, 0x4a, 1, &CopyDataStruct,, ahk_PID %param1% ahk_class AutoHotKey

but the script doesn't receive anything without tooltip too.

I'll find a solution, thanks anyway Smile
Back to top
View user's profile Send private message
MasterFocus



Joined: 08 Apr 2009
Posts: 3035
Location: Rio de Janeiro - RJ - Brasil

PostPosted: Tue Oct 20, 2009 7:34 pm    Post subject: Reply with quote

Kai wrote:
Code:
SendMessage, 0x4a, 1, &CopyDataStruct,, ahk_PID %param1% ahk_class AutoHotKey

Does this make any difference?
_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"

Antonio França
My stuff: Google Profile
Back to top
View user's profile Send private message Visit poster's website
Lexikos



Joined: 17 Oct 2006
Posts: 7295
Location: Australia

PostPosted: Tue Oct 20, 2009 10:18 pm    Post subject: Reply with quote

Window classes are case-sensitive. "ahk_class AutoHotKey" != "ahk_class AutoHotkey"
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Tue Oct 20, 2009 11:41 pm    Post subject: Reply with quote

Lexikos wrote:
Window classes are case-sensitive. "ahk_class AutoHotKey" != "ahk_class AutoHotkey"

...hahaha... Laughing ...like I've been saying...lowercase k people!
Back to top
Kai



Joined: 08 Aug 2009
Posts: 17

PostPosted: Wed Oct 21, 2009 12:49 pm    Post subject: Reply with quote

LOL, unbelievable! XD

Thanks guys Razz
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
Page 1 of 1

 
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