Progress! Now it works with A32 and U32, but not with U64.

Exec Litestep Bangs From AHK [dll]
I have modified to StringCopyA, try again
![Exec Litestep Bangs From AHK [dll]: post #17](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
Worse, only works with A32.
![Exec Litestep Bangs From AHK [dll]: post #18](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
And this?
StringCopyA(ByRef dst, offset, ByRef src) { While NumGet(&src,A_Index-1,"Char") NumPut(NumGet(&src,A_Index-1,"Char"), &dst, offset + (A_Index-1),"Char") } Bang(command) { static bang,args,MAX_BANGCOMMAND := 64,MAX_BANGARGS := 256,init := VarSetCapacity(bang,MAX_BANGCOMMAND) VarSetCapacity(args,MAX_BANGARGS) StrPut((pos := InStr(command, " ")) ? SubStr(command, 1, pos - 1) : command,&bang,"CP0") ,StrPut(pos?SubStr(command, pos + 1):"",&args,"CP0") ;MAX_BANGCOMMAND = 64 ;MAX_BANGARGS = 256 ;struct _LMBANGCOMMANDA ;{ ; UINT cbSize; ; HWND hWnd; ; CHAR szCommand[MAX_BANGCOMMAND]; ; CHAR szArgs[MAX_BANGARGS]; ;} ,VarSetCapacity(lmbc,sz := A_PtrSize*2+MAX_BANGCOMMAND+MAX_BANGARGS, 0) ,NumPut(sz, lmbc, 0, "UInt") ,NumPut(0, lmbc, A_PtrSize, "UInt") ,StringCopyA(lmbc, A_PtrSize*2, bang) ,StringCopyA(lmbc, A_PtrSize*2+MAX_BANGCOMMAND, args) ;COPYDATASTRUCT VarSetCapacity(cds, A_PtrSize*2 + 4, 0) ;LM_BANGCOMMAND = 9420 ,NumPut(9420, cds, 0, "UInt") ,NumPut(sz, cds, A_PtrSize, "UInt") ,NumPut(&lmbc, cds, A_PtrSize + 4) ,dhw := A_DetectHiddenWindows DetectHiddenWindows On ;WM_COPYDATA = 0x4A SendMessage, 0x4A, 0, &cds,, LiteStep ahk_class TApplication ret := ErrorLevel DetectHiddenWindows %dhw% return ret } Bang("!alert Moo $USERNAME$")
![Exec Litestep Bangs From AHK [dll]: post #19](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
I get an Out of memory warning from VarSetCapacity in StringCopyA, in all versions.
![Exec Litestep Bangs From AHK [dll]: post #20](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
Please try above again.
![Exec Litestep Bangs From AHK [dll]: post #21](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
Now it works in A32 & U32, but not U64. I'm not sure but i think my Litestep is 32bit, if that helps...
![Exec Litestep Bangs From AHK [dll]: post #22](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
Give it another try.
![Exec Litestep Bangs From AHK [dll]: post #23](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
Same result, No U64.
![Exec Litestep Bangs From AHK [dll]: post #24](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
Now it works in A32 & U32, but not U64. I'm not sure but i think my Litestep is 32bit, if that helps...
I think in that case it will need an 32-bit structure:
StringCopyA(ByRef dst, offset, ByRef src) { While NumGet(&src,A_Index-1,"Char") NumPut(NumGet(&src,A_Index-1,"Char"), &dst, offset + (A_Index-1),"Char") } Bang(command) { static bang,args,MAX_BANGCOMMAND := 64,MAX_BANGARGS := 256,init := VarSetCapacity(bang,MAX_BANGCOMMAND) VarSetCapacity(args,MAX_BANGARGS) StrPut((pos := InStr(command, " ")) ? SubStr(command, 1, pos - 1) : command,&bang,"CP0") ,StrPut(pos?SubStr(command, pos + 1):"",&args,"CP0") ;MAX_BANGCOMMAND = 64 ;MAX_BANGARGS = 256 ;struct _LMBANGCOMMANDA ;{ ; UINT cbSize; ; HWND hWnd; ; CHAR szCommand[MAX_BANGCOMMAND]; ; CHAR szArgs[MAX_BANGARGS]; ;} ,VarSetCapacity(lmbc,sz := 4*2+MAX_BANGCOMMAND+MAX_BANGARGS, 0) ,NumPut(sz, lmbc, 0, "UInt") ,NumPut(0, lmbc, 4, "UInt") ,StringCopyA(lmbc, 4*2, bang) ,StringCopyA(lmbc, 4*2+MAX_BANGCOMMAND, args) ;COPYDATASTRUCT VarSetCapacity(cds, A_PtrSize*2 + 4, 0) ;LM_BANGCOMMAND = 9420 ,NumPut(9420, cds, 0, "UInt") ,NumPut(sz, cds, A_PtrSize, "UInt") ,NumPut(&lmbc, cds, A_PtrSize + 4) ,dhw := A_DetectHiddenWindows DetectHiddenWindows On ;WM_COPYDATA = 0x4A SendMessage, 0x4A, 0, &cds,, LiteStep ahk_class TApplication ret := ErrorLevel DetectHiddenWindows %dhw% return ret } Bang("!alert Moo $USERNAME$")
![Exec Litestep Bangs From AHK [dll]: post #25](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
Same result, only works with U32 & A32.
![Exec Litestep Bangs From AHK [dll]: post #26](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
What is the ErrorLevel and A_LastError after SendMessage?
![Exec Litestep Bangs From AHK [dll]: post #27](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
U32:
ErrorLevel: 1
A_LastError: 0
U64:
ErrorLevel: 0
A_LastError: 0
A32:
ErrorLevel: 1
A_LastError: 0
![Exec Litestep Bangs From AHK [dll]: post #28](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
I assume this is not possible due to 64-bit to 32-bit pointer conversion. You have to run the SendMessage part from 32-bit process or compile a 64-bit version of the other app if possible.
![Exec Litestep Bangs From AHK [dll]: post #29](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
Ok, but thank you very much for taking the time. Is it OK if I post the latest version of the functions on ahkscript.org? I'll give credit to you and the original author of-course.
![Exec Litestep Bangs From AHK [dll]: post #30](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)