Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Exec Litestep Bangs From AHK [dll]


  • Please log in to reply
29 replies to this topic
budRich
  • Members
  • 146 posts
  • Last active: Aug 03 2015 08:33 PM
  • Joined: 09 Aug 2011

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



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

I have modified to StringCopyA, try again ;)



budRich
  • Members
  • 146 posts
  • Last active: Aug 03 2015 08:33 PM
  • Joined: 09 Aug 2011

Worse, only works with A32.



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

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$")


budRich
  • Members
  • 146 posts
  • Last active: Aug 03 2015 08:33 PM
  • Joined: 09 Aug 2011

I get an Out of memory warning from VarSetCapacity in StringCopyA, in all versions.



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

Please try above again.



budRich
  • Members
  • 146 posts
  • Last active: Aug 03 2015 08:33 PM
  • Joined: 09 Aug 2011

Now it works in A32 & U32, but not U64. I'm not sure but i think my Litestep is 32bit, if that helps...



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

Give it another try.



budRich
  • Members
  • 146 posts
  • Last active: Aug 03 2015 08:33 PM
  • Joined: 09 Aug 2011

Same result, No U64.



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

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$")


budRich
  • Members
  • 146 posts
  • Last active: Aug 03 2015 08:33 PM
  • Joined: 09 Aug 2011

Same result, only works with U32 & A32.



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

What is the ErrorLevel and A_LastError after SendMessage?



budRich
  • Members
  • 146 posts
  • Last active: Aug 03 2015 08:33 PM
  • Joined: 09 Aug 2011

U32:

ErrorLevel: 1
A_LastError: 0

 

U64:

ErrorLevel: 0
A_LastError: 0

 

A32:

ErrorLevel: 1
A_LastError: 0



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

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.



budRich
  • Members
  • 146 posts
  • Last active: Aug 03 2015 08:33 PM
  • Joined: 09 Aug 2011

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.