Jump to content

PostMessage and COM channel switching


Recommended Posts

Hello!

I thought it might be nice info, for future scripters, to post my AHK channel switching methods Im using for a DVBViewer based app.

CHSwitchCom := {0: ["PostMessage, 0xB2C2, 0x0815, 0x08C,, ahk_class TfrmMain", "iDVBViewer.SendCommand(38)"]   ; Sends DVBViewer Channelswitch 0
     ,          1: ["PostMessage, 0xB2C2, 0x0815, 0x08D,, ahk_class TfrmMain", "iDVBViewer.SendCommand(11)"]   ; Sends DVBViewer Channelswitch 1
     ,          2: ["PostMessage, 0xB2C2, 0x0815, 0x08E,, ahk_class TfrmMain", "iDVBViewer.SendCommand(12)"]   ; Sends DVBViewer Channelswitch 2
     ,          3: ["PostMessage, 0xB2C2, 0x0815, 0x08F,, ahk_class TfrmMain", "iDVBViewer.SendCommand(13)"]   ; Sends DVBViewer Channelswitch 3
     ,          4: ["PostMessage, 0xB2C2, 0x0815, 0x090,, ahk_class TfrmMain", "iDVBViewer.SendCommand(14)"]   ; Sends DVBViewer Channelswitch 4
     ,          5: ["PostMessage, 0xB2C2, 0x0815, 0x091,, ahk_class TfrmMain", "iDVBViewer.SendCommand(15)"]   ; Sends DVBViewer Channelswitch 5
     ,          6: ["PostMessage, 0xB2C2, 0x0815, 0x092,, ahk_class TfrmMain", "iDVBViewer.SendCommand(16)"]   ; Sends DVBViewer Channelswitch 6
     ,          7: ["PostMessage, 0xB2C2, 0x0815, 0x093,, ahk_class TfrmMain", "iDVBViewer.SendCommand(17)"]   ; Sends DVBViewer Channelswitch 7
     ,          8: ["PostMessage, 0xB2C2, 0x0815, 0x094,, ahk_class TfrmMain", "iDVBViewer.SendCommand(18)"]   ; Sends DVBViewer Channelswitch 8
     ,          9: ["PostMessage, 0xB2C2, 0x0815, 0x095,, ahk_class TfrmMain", "iDVBViewer.SendCommand(19)"] } ; Sends DVBViewer Channelswitch 9
;MsgBox % CHSwitchCom[Key 7, 1]
iDVBViewer := ComObject("DVBViewerServer.DVBViewer")
MenuHandler:
CHSwichCode := HasVal(FavArray, A_ThisMenuItem)
If (CHSwichCode >= 10) {
  SwitchArray := StrSplit(CHSwichCode)
  Loop % SwitchArray.MaxIndex()
   {
     CHSwichCodeSplit := SwitchArray[a_index]
     ahkExec(CHSwitchCom[Key . CHSwichCodeSplit, 2]) ; set 1 to execute Postmessage channelswitch or 2 for COM channelswitch
   }
}
Else
  ahkExec(CHSwitchCom[Key . CHSwichCode, 2])  ; set 1 to execute Postmessage channelswitch or 2 for COM channelswitch
return
;--------------------------------------------------------------------------
HasVal(haystack, needle) {
	if !(IsObject(haystack)) || (haystack.Length() = 0)
		return 0
	for index, value in haystack
		if (value = needle)
			return index
	return 0
}
;--------------------------------------------------------------------------
ahkExec(Script){ ; AHK_H is required to execute commands dynamically
static ahkExec
if !ahkExec
ahkExec:=DynaCall(A_IsDll&&A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"ahkExec"):DllCall("GetProcAddress","PTR",A_ModuleHandle,"AStr","ahkExec","PTR"),"i==s")
Errorlevel := ahkExec[Script]
}

It can be a bit tricky to get the COM channel switching to work. See here for solution: http://www.DVBViewer.tv/forum/topic/59795-com-favourites-sendcommand-issue/

Hope it helps someone:bye:

Edited by majstang
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...