interesting.
i have problems with Receive_WM_COPYDATA .
seems like the script often could not find hidden scipts. sometimes it find it sometimes not. i dont understand. it drives me crazy
Code: Select all
Receive_WM_COPYDATA(wParam, lParam)
{
StringAddress := NumGet(lParam + 2*A_PtrSize) ; Retrieves the CopyDataStruct's lpData member.
CopyOfData := StrGet(StringAddress) ; Copy the string out of the structure.
; Show it with ToolTip vs. MsgBox so we can return in a timely fashion:
;msgbox, %A_ScriptName%`nReceived:`n%CopyOfData%
;RegRead, wordlistActive, HKEY_CURRENT_USER, SOFTWARE\sl5net, CopyOfData
global wordlistOLD
global wordlist
; wordlistNEWarchivePath := CopyOfData
; wordlistActivePath := CopyOfData
; wordlistNEW := CopyOfData
wordlist := CopyOfData
tooltip,Receive_WM_COPYDATA: `n`n''%wordlist%' = wordlist `n ( %A_ScriptName%(inc)~%A_LineNumber% ) `n
;msgbox,Receive_WM_COPYDATA: `n`n'%wordlist%' = wordlist `n ( %A_ScriptName%(inc)~%A_LineNumber% ) `n
ToolTip4sec(wordlistOLD . "<??>" . wordlist . "´n´n" . A_LineNumber . " " . A_ScriptName . " " . Last_A_This)
Sleep,1000
if( 1 && wordlistOLD <> wordlist){
feedbackMsgBox("wordlistOLD <> wordlist",wordlistOLD . " <> " . wordlist . "`n" . A_ScriptName . "(inc)~" . A_LineNumber)
;setGlobalWordlist(wordlistActive)
;InitializeListBox()
;BlockInput, Send ; Send: The user's keyboard and mouse input is ignored while a Send or SendRaw is in progress
InitializeHotKeys()
DisableKeyboardHotKeys()
SetBatchLines, -1 ;Change the Running performance speed (Priority changed to High in GetIncludedActiveWindow)
;feedbackMsgBox("ReadInTheWordList()",wordlist . "`n" . activeTitle . " = activeTitle `n " . A_ScriptName . "(inc)~" . A_LineNumber)
ReadInTheWordList()
;prefs_Length := setLength(ParseWordsCount, maxLinesOfCode4length1)
wordlistOLD:=wordlist
}
MainLoop()
}
Code: Select all
temp =
(
TargetScriptTitle = TypingAid ahk_class AutoHotkey
TargetScriptTitle = TypingAid.ahk ahk_class AutoHotkey
;TargetScriptTitle = TypingAid.ahk
stringToSend := (InStr(wordlistNEW,"\")) ? wordlistNEW : wordlistDir . "\" . wordlistNEW
result := Send_WM_COPYDATA`(stringToSend, TargetScriptTitle`)
Send_WM_COPYDATA(ByRef StringToSend, ByRef TargetScriptTitle){ ; ByRef saves a little memory in this case.
; This function sends the specified string to the specified window and returns the reply.
; The reply is 1 if the target window processed the message, or 0 if it ignored it.
VarSetCapacity(CopyDataStruct, 3*A_PtrSize, 0) ; Set up the structure's memory area. \
; First set the structure's cbData member to the size of the string, including its zero terminator:
SizeInBytes := (StrLen(StringToSend) + 1) * (A_IsUnicode ? 2 : 1)
NumPut(SizeInBytes, CopyDataStruct, A_PtrSize) ; OS requires that this be done.
NumPut(&StringToSend, CopyDataStruct, 2*A_PtrSize) ; Set lpData to point to the string itself.
Prev_DetectHiddenWindows := A_DetectHiddenWindows
Prev_TitleMatchMode := A_TitleMatchMode
DetectHiddenWindows On
SetTitleMatchMode 2
IfWinNotExist,`% TargetScriptTitle
{
tooltip,`% TargetScriptTitle . "=TargetScriptTitle :( NOT found "
sleep,4000
return
}
TimeOutTime = 2400 ; Optional. Milliseconds to wait for response from receiver.ahk. Default is 5000
; Must use SendMessage not PostMessage.
; see Receive_WM_COPYDATA
; SendMessage, 0x4a, 0, &CopyDataStruct,, `%TargetScriptTitle`%,,,, `%TimeOutTime`% ; 0x4a is WM_COPYDATA.
;SendMessage, 0x4a, 0, &CopyDataStruct,, TypingAid,,,, `%TimeOutTime`% ; 0x4a is WM_COPYDATA.
;SendMessage, 0x4a, 0, &CopyDataStruct,, TypingAid,,,, `%TimeOutTime`% ; 0x4a is WM_COPYDATA.
;PostMessage, 0x4a, 0, &CopyDataStruct,, `%TargetScriptTitle`%,,,, ; 0x4a is WM_COPYDATA.
SendMessage, 0x4a, 0, &CopyDataStruct,, TypingAid ahk_class AutoHotkey,,,, `%TimeOutTime`% ; 0x4a is WM_COPYDATA.
;PostMessage, 0x4a, 0, &CopyDataStruct,, TypingAid,,,, ; 0x4a is WM_COPYDATA.
;msg:="#" . StringToSend . "# ``n" . A_ScriptName . "~" . A_LineNumber
;tooltip,`% "SendMessage: " . msg
;sleep,2000
;feedbackMsgBox("SendMessage",msg)
DetectHiddenWindows `%Prev_DetectHiddenWindows`% ; Restore original setting for the caller.
SetTitleMatchMode `%Prev_TitleMatchMode`% ; Same.
return ErrorLevel ; Return SendMessage's reply back to our caller.
}
; RegWrite, REG_SZ, HKEY_CURRENT_USER, SOFTWARE\sl5net, wordlistDir, `%wordlistDir`%
; RegWrite, REG_SZ, HKEY_CURRENT_USER, SOFTWARE\sl5net, wordlistActive, `%wordlistActive`%
; RegWrite, REG_SZ, HKEY_CURRENT_USER, SOFTWARE\sl5net, wordlistNEW, `%wordlistNEW`%
; RegWrite, REG_SZ, HKEY_CURRENT_USER, SOFTWARE\sl5net, wordlistNEWarchivePath, `%wordlistNEWarchivePath`%
)
;feedbackMsgBox("SendMessage",temp . "`n#" . wordlistNEW . "#`n`n" . A_ScriptName . "~" . A_LineNumber)
ahkSource .= temp
it seems for me that the script sometimes cant find each other.