home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Support
General Support
Beo4 IR remote receiver
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="druden" data-source="post: 32363" data-attributes="member: 17670"><p><strong>Succes!</strong></p><p></p><p>[Edit: AutoHotKey.ini (see code below) was updated on 16.01.2006]</p><p></p><p>Replaced the broken WinLIRC plugin for Media Portal with AutoHotKey - a freeware app found here: <a href="http://autohotkey.com" target="_blank">http://autohotkey.com</a> - the "final" (until the WinLIRC plugin is fixed) configuration which is sooooo nice ;-) consist of</p><ul> <li data-xf-list-type="ul"><br /> A WinLIRC standard simple serial IR receiver using Vishay TSOP7000 IR "eye" <a href="http://lnx.manoweb.com/lirc/?partType=section&partName=circuit" target="_blank">http://lnx.manoweb.com/lirc/?partType=section&partName=circuit</a><br /> WinLIRC with the Beo4.cf configuration found above to decode the IR signals<br /> AutoHotKey with the configuration found below mapping</li> </ul><p>AutoHotKey using my config sends keystrokes to the foremost application which is always Media Portal in my case...</p><p></p><p>Notes:</p><ul> <li data-xf-list-type="ul"><br /> AutoHotKey is not context sensitive (a remote buttons always sends the same keystrok, no matter if you're watching a full screen movie or browsing the TV guide<br /> Some keyboard shortcuts are not mapped because Beo4 has a limited set of buttons (F5-F9 and the "u" key was left out).</li> </ul><p>Kind regards,</p><p>Jesper</p><p></p><p>The sample autohotkey.ini modified for Beo4/WinLIRC/MP</p><p>[code]</p><p>; Here are the steps to use this script:</p><p>; 1) Configure WinLIRC to recognize your remote control and its buttons.</p><p>; WinLIRC is at http://winlirc.sourceforge.net</p><p>; 2) Edit the WinLIRC path, address, and port in the CONFIG section below.</p><p>; 3) Launch this script. It will start the WinLIRC server if needed.</p><p>; 4) Press some buttons on your remote control. A small window will</p><p>; appear showing the name of each button as you press it.</p><p>; 5) Configure your buttons to send keystrokes and mouse clicks to</p><p>; windows such as Winamp, Media Player, etc. See the examples below.</p><p></p><p>; This script requires AutoHotkey 1.0.38 or later.</p><p>; HISTORY OF CHANGES</p><p>; October 5, 2005:</p><p>; - Eliminated Winsock warning dialog "10054" upon system shutdown/logoff.</p><p>; - Added option "DelayBetweenButtonRepeats" to throttle the repeat speed.</p><p></p><p>; -------------------------------------------------</p><p>; CONFIGURATION SECTION: Set your preferences here.</p><p>; -------------------------------------------------</p><p>; Some remote controls repeat the signal rapidly while you're holding down</p><p>; a button. This makes it difficult to get the remote to send only a single</p><p>; signal. The following setting solves this by ignoring repeated signals</p><p>; until the specified time has passed. 200 is often a good setting. Set it</p><p>; to 0 to disable this feature.</p><p>DelayBetweenButtonRepeats = 200</p><p></p><p>; Specify the path to WinLIRC, such as C:\WinLIRC\winlirc.exe</p><p>WinLIRC_Path = c:\progra~1\WinLIRC\winlirc.exe</p><p></p><p>; Specify WinLIRC's address and port. The most common are 127.0.0.1 (localhost) and 8765.</p><p>WinLIRC_Address = 127.0.0.1</p><p>WinLIRC_Port = 8765</p><p></p><p>; Do not change the following two lines. Skip them and continue below.</p><p>Gosub WinLIRC_Init</p><p>return</p><p></p><p>; --------------------------------------------</p><p>; ASSIGN ACTIONS TO THE BUTTONS ON YOUR REMOTE</p><p>; --------------------------------------------</p><p>; Configure your remote control's buttons below. Use WinLIRC's names</p><p>; for the buttons, which can be seen in your WinLIRC config file</p><p>; (.cf file) -- or you can press any button on your remote and the</p><p>; script will briefly display the button's name in a small window.</p><p>; </p><p>; Below are some examples. Feel free to revise or delete them to suit</p><p>; your preferences.</p><p></p><p>;=======================================================================</p><p>;POWER 3 SEC: shut windows down</p><p>;=======================================================================</p><p>beo4-all-power-off:</p><p>Shutdown,5</p><p>return</p><p></p><p>;=======================================================================</p><p>;SAT = Launch MediaPortal (if crashed...)</p><p>;=======================================================================</p><p>beo4-sat-on:</p><p>Run,c:\progra~1\mediaportal\mediaportal.exe</p><p>return</p><p></p><p>;=======================================================================</p><p>;V.TAPE = On Screen Display (OSD) if running, otherwise launch MP!</p><p>;=======================================================================</p><p>beo4-vtape-on:</p><p>Send,y</p><p>return</p><p></p><p>;=======================================================================</p><p>;All numeric buttons naturally are sent without translation</p><p>;=======================================================================</p><p>beo4-vtape-0:</p><p>beo4-tv-0:</p><p>Send,{Numpad0}</p><p>return</p><p></p><p>beo4-vtape-1:</p><p>beo4-tv-1:</p><p>Send,{Numpad1}</p><p>return</p><p></p><p>beo4-vtape-2:</p><p>beo4-tv-2:</p><p>Send,{Numpad2}</p><p>return</p><p></p><p>beo4-vtape-3:</p><p>beo4-tv-3:</p><p>Send,{Numpad3}</p><p>return</p><p></p><p>beo4-vtape-4:</p><p>beo4-tv-4:</p><p>Send,{Numpad4}</p><p>return</p><p></p><p>beo4-vtape-5:</p><p>beo4-tv-5:</p><p>Send,{Numpad5}</p><p>return</p><p></p><p>beo4-vtape-6:</p><p>beo4-tv-6:</p><p>Send,{Numpad6}</p><p>return</p><p></p><p>beo4-vtape-7:</p><p>beo4-tv-7:</p><p>Send,{Numpad7}</p><p>return</p><p></p><p>beo4-vtape-8:</p><p>beo4-tv-8:</p><p>Send,{Numpad8}</p><p>return</p><p></p><p>beo4-vtape-9:</p><p>beo4-tv-9:</p><p>Send,{Numpad9}</p><p>return</p><p></p><p>;=======================================================================</p><p>;Arrow keys (while V.TAPE) are also passed on without translation</p><p>;=======================================================================</p><p>beo4-vtape-left:</p><p>Send,{LEFT}</p><p>return</p><p></p><p>beo4-vtape-right:</p><p>Send,{RIGHT}</p><p>return</p><p></p><p>beo4-vtape-up:</p><p>Send,{UP}</p><p>return</p><p></p><p>beo4-vtape-down:</p><p>Send,{DOWN}</p><p>return</p><p></p><p>;=======================================================================</p><p>; The Green button toggles windowed/full screen mode</p><p>;=======================================================================</p><p>beo4-vtape-green:</p><p>beo4-tv-green:</p><p>Send,x</p><p>return</p><p></p><p>;=======================================================================</p><p>; The Yellow button switches aspect ratio on videos/TV</p><p>; shows playlist/music/video in other modes</p><p>;=======================================================================</p><p>beo4-vtape-yellow:</p><p>beo4-tv-yellow:</p><p>Send,{F1}</p><p>Send,s</p><p>return</p><p></p><p>;=======================================================================</p><p>; The Red button is used for pause</p><p>;=======================================================================</p><p>beo4-vtape-red:</p><p>beo4-tv-red:</p><p>Send,{SPACE}</p><p>return</p><p></p><p>;=======================================================================</p><p>; The Blue button = Enter</p><p>;=======================================================================</p><p>beo4-vtape-blue:</p><p>beo4-tv-blue:</p><p>Send,{ENTER}</p><p>return</p><p></p><p>;=======================================================================</p><p>; RECORD = record (TV mode), rotate (in Picture mode), Menu (in DVD mode)</p><p>;=======================================================================</p><p>beo4-video-record:</p><p>Send,r</p><p>Send,m</p><p>return</p><p></p><p>;=======================================================================</p><p>; MENU = display menu/info/IMDB lookup</p><p>;=======================================================================</p><p>beo4-vtape-menu:</p><p>beo4-tv-menu:</p><p>Send,{F3}</p><p>return</p><p></p><p>;=======================================================================</p><p>; STOP = stop/exit</p><p>;=======================================================================</p><p>beo4-vtape-stop:</p><p>beo4-tv-stop:</p><p>Send,b</p><p>return</p><p></p><p>;=======================================================================</p><p>; Volume up/down are passed as =/-, could be deleted to avoid</p><p>; simultaneously controlling your B&O TV and Media Portal</p><p>;=======================================================================</p><p>beo4-video-vol-up:</p><p>Send,=</p><p>return</p><p></p><p>beo4-video-vol-down:</p><p>Send,-</p><p>return</p><p></p><p>;=======================================================================</p><p>; EXIT = generally exits or steps one menu level back</p><p>;=======================================================================</p><p>beo4-vtape-exit:</p><p>beo4-tv-exit:</p><p>Send,{ESC}</p><p>return</p><p></p><p>;=======================================================================</p><p>; Switch to DVD mode and use the arrow buttons for FFD/REW and for</p><p>; skipping a full track/movie forward or backward</p><p>;=======================================================================</p><p>beo4-tv-left:</p><p>Send,{F5}</p><p>return</p><p></p><p>beo4-tv--right:</p><p>Send,{F6}</p><p>return</p><p></p><p>beo4-tv-up:</p><p>Send,{F7}</p><p>return</p><p></p><p>beo4-tv-down:</p><p>Send,{F5}</p><p>return</p><p></p><p>; ----------------------------</p><p>; END OF CONFIGURATION SECTION</p><p>; ----------------------------</p><p>; Do not make changes below this point unless you want to change the core</p><p>; functionality of the script.</p><p></p><p>WinLIRC_Init:</p><p>OnExit, ExitSub ; For connection cleanup purposes.</p><p></p><p>; Launch WinLIRC if it isn't already running:</p><p>Process, Exist, winlirc.exe</p><p>if not ErrorLevel ; No PID for WinLIRC was found.</p><p>{</p><p> IfNotExist, %WinLIRC_Path%</p><p> {</p><p> MsgBox The file "%WinLIRC_Path%" does not exist. Please edit this script to specify its location.</p><p> ExitApp</p><p> }</p><p> Run %WinLIRC_Path%</p><p> Sleep 200 ; Give WinLIRC a little time to initialize (probably never needed, just for peace of mind).</p><p>}</p><p></p><p>; Connect to WinLIRC (or any type of server for that matter):</p><p>socket := ConnectToAddress(WinLIRC_Address, WinLIRC_Port)</p><p>if socket = -1 ; Connection failed (it already displayed the reason).</p><p> ExitApp</p><p></p><p>; Find this script's main window:</p><p>Process, Exist ; This sets ErrorLevel to this script's PID (it's done this way to support compiled scripts).</p><p>DetectHiddenWindows On</p><p>ScriptMainWindowId := WinExist("ahk_class AutoHotkey ahk_pid " . ErrorLevel)</p><p>DetectHiddenWindows Off</p><p></p><p>; When the OS notifies the script that there is incoming data waiting to be received,</p><p>; the following causes a function to be launched to read the data:</p><p>NotificationMsg = 0x5555 ; An arbitrary message number, but should be greater than 0x1000.</p><p>OnMessage(NotificationMsg, "ReceiveData")</p><p></p><p>; Set up the connection to notify this script via message whenever new data has arrived.</p><p>; This avoids the need to poll the connection and thus cuts down on resource usage.</p><p>FD_READ = 1 ; Received when data is available to be read.</p><p>FD_CLOSE = 32 ; Received when connection has been closed.</p><p>if DllCall("Ws2_32\WSAAsyncSelect", UInt, socket, UInt, ScriptMainWindowId, UInt, NotificationMsg, Int, FD_READ|FD_CLOSE)</p><p>{</p><p> MsgBox % "WSAAsyncSelect() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError")</p><p> ExitApp</p><p>}</p><p>return</p><p></p><p></p><p></p><p>ConnectToAddress(IPAddress, Port)</p><p>; This can connect to most types of TCP servers, not just WinLIRC.</p><p>; Returns -1 (INVALID_SOCKET) on failure or the socket ID upon success.</p><p>{</p><p> VarSetCapacity(wsaData, 32) ; The struct is only about 14 in size, so 32 is conservative.</p><p> result := DllCall("Ws2_32\WSAStartup", UShort, 0x0002, UInt, &wsaData) ; Request Winsock 2.0 (0x0002)</p><p> ; Since WSAStartup() will likely be the first Winsock function called by this script,</p><p> ; check ErrorLevel to see if the OS has Winsock 2.0 available:</p><p> if ErrorLevel</p><p> {</p><p> MsgBox WSAStartup() could not be called due to error %ErrorLevel%. Winsock 2.0 or higher is required.</p><p> return -1</p><p> }</p><p> if result ; Non-zero, which means it failed (most Winsock functions return 0 on success).</p><p> {</p><p> MsgBox % "WSAStartup() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError")</p><p> return -1</p><p> }</p><p></p><p> AF_INET = 2</p><p> SOCK_STREAM = 1</p><p> IPPROTO_TCP = 6</p><p> socket := DllCall("Ws2_32\socket", Int, AF_INET, Int, SOCK_STREAM, Int, IPPROTO_TCP)</p><p> if socket = -1</p><p> {</p><p> MsgBox % "socket() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError")</p><p> return -1</p><p> }</p><p></p><p> ; Prepare for connection:</p><p> SizeOfSocketAddress = 16</p><p> VarSetCapacity(SocketAddress, SizeOfSocketAddress)</p><p> InsertInteger(2, SocketAddress, 0, AF_INET) ; sin_family</p><p> InsertInteger(DllCall("Ws2_32\htons", UShort, Port), SocketAddress, 2, 2) ; sin_port</p><p> InsertInteger(DllCall("Ws2_32\inet_addr", str, IPAddress), SocketAddress, 4, 4) ; sin_addr.s_addr</p><p></p><p> ; Attempt connection:</p><p> if DllCall("Ws2_32\connect", UInt, socket, UInt, &SocketAddress, Int, SizeOfSocketAddress)</p><p> {</p><p> MsgBox % "connect() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") . ". Is WinLIRC running?"</p><p> return -1</p><p> }</p><p> return socket ; Indicate success by returning a valid socket ID rather than -1.</p><p>}</p><p></p><p></p><p></p><p>ReceiveData(wParam, lParam)</p><p>; By means of OnMessage(), this function has been set up to be called automatically whenever new data</p><p>; arrives on the connection. It reads the data from WinLIRC and takes appropriate action depending</p><p>; on the contents.</p><p>{</p><p> socket := wParam</p><p> ReceivedDataSize = 4096 ; Large in case a lot of data gets buffered due to delay in processing previous data.</p><p> Loop ; This loop solves the issue of the notification message being discarded due to thread-already-running.</p><p> {</p><p> VarSetCapacity(ReceivedData, ReceivedDataSize, 0) ; 0 for last param terminates string for use with recv().</p><p> ReceivedDataLength := DllCall("Ws2_32\recv", UInt, socket, Str, ReceivedData, Int, ReceivedDataSize, Int, 0)</p><p> if ReceivedDataLength = 0 ; The connection was gracefully closed, probably due to exiting WinLIRC.</p><p> ExitApp ; The OnExit routine will call WSACleanup() for us.</p><p> if ReceivedDataLength = -1</p><p> {</p><p> WinsockError := DllCall("Ws2_32\WSAGetLastError")</p><p> if WinsockError = 10035 ; WSAEWOULDBLOCK, which means "no more data to be read".</p><p> return 1</p><p> if WinsockError <> 10054 ; WSAECONNRESET, which happens when WinLIRC closes via system shutdown/logoff.</p><p> ; Since it's an unexpected error, report it. Also exit to avoid infinite loop.</p><p> MsgBox % "recv() indicated Winsock error " . WinsockError</p><p> ExitApp ; The OnExit routine will call WSACleanup() for us.</p><p> }</p><p> ; Otherwise, process the data received. Testing shows that it's possible to get more than one line</p><p> ; at a time (even for explicitly-sent IR signals), which the following method handles properly.</p><p> ; Data received from WinLIRC looks like the following example (see the WinLIRC docs for details):</p><p> ; 0000000000eab154 00 NameOfButton NameOfRemote</p><p> Loop, parse, ReceivedData, `n, `r</p><p> {</p><p> if A_LoopField in ,BEGIN,SIGHUP,END ; Ignore blank lines and WinLIRC's start-up messages.</p><p> continue</p><p> ButtonName = ; Init to blank in case there are less than 3 fields found below.</p><p> Loop, parse, A_LoopField, %A_Space% ; Extract the button name, which is the third field.</p><p> if A_Index = 3</p><p> ButtonName := A_LoopField</p><p> global DelayBetweenButtonRepeats ; Declare globals to make them available to this function.</p><p> static PrevButtonName, PrevButtonTime, RepeatCount ; These variables remember their values between calls.</p><p> if (ButtonName != PrevButtonName || A_TickCount - PrevButtonTime > DelayBetweenButtonRepeats)</p><p> {</p><p> if IsLabel(ButtonName) ; There is a subroutine associated with this button.</p><p> Gosub %ButtonName% ; Launch the subroutine.</p><p> else ; Since there is no associated subroutine, briefly display which button was pressed.</p><p> {</p><p> if (ButtonName == PrevButtonName)</p><p> RepeatCount += 1</p><p> else</p><p> RepeatCount = 1</p><p> SplashTextOn, 150, 20, Button from WinLIRC, %ButtonName% (%RepeatCount%)</p><p> SetTimer, SplashOff, 3000 ; This allows more signals to be processed while displaying the window.</p><p> }</p><p> PrevButtonName := ButtonName</p><p> PrevButtonTime := A_TickCount</p><p> }</p><p> }</p><p> }</p><p> return 1 ; Tell the program that no further processing of this message is needed.</p><p>}</p><p></p><p></p><p></p><p>SplashOff:</p><p>SplashTextOff</p><p>SetTimer, SplashOff, Off</p><p>return</p><p></p><p></p><p></p><p>InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)</p><p>; To preserve any existing contents in pDest, only pSize number of bytes starting at pOffset</p><p>; are altered in it. The caller must ensure that pDest has sufficient capacity.</p><p>{</p><p> mask := 0xFF ; This serves to isolate each byte, one by one.</p><p> Loop %pSize% ; Copy each byte in the integer into the structure as raw binary data.</p><p> {</p><p> DllCall("RtlFillMemory", UInt, &pDest + pOffset + A_Index - 1, UInt, 1 ; Write one byte.</p><p> , UChar, (pInteger & mask) >> 8 * (A_Index - 1))</p><p> mask := mask << 8 ; Set it up for isolation of the next byte.</p><p> }</p><p>}</p><p></p><p></p><p></p><p>ExitSub: ; This subroutine is called automatically when the script exits for any reason.</p><p>; MSDN: "Any sockets open when WSACleanup is called are reset and automatically</p><p>; deallocated as if closesocket was called."</p><p>DllCall("Ws2_32\WSACleanup")</p><p>ExitApp</p><p></p><p>[/code]</p></blockquote><p></p>
[QUOTE="druden, post: 32363, member: 17670"] [b]Succes![/b] [Edit: AutoHotKey.ini (see code below) was updated on 16.01.2006] Replaced the broken WinLIRC plugin for Media Portal with AutoHotKey - a freeware app found here: [url]http://autohotkey.com[/url] - the "final" (until the WinLIRC plugin is fixed) configuration which is sooooo nice ;-) consist of [list] A WinLIRC standard simple serial IR receiver using Vishay TSOP7000 IR "eye" [url]http://lnx.manoweb.com/lirc/?partType=section&partName=circuit[/url] WinLIRC with the Beo4.cf configuration found above to decode the IR signals AutoHotKey with the configuration found below mapping [/list] AutoHotKey using my config sends keystrokes to the foremost application which is always Media Portal in my case... Notes: [list] AutoHotKey is not context sensitive (a remote buttons always sends the same keystrok, no matter if you're watching a full screen movie or browsing the TV guide Some keyboard shortcuts are not mapped because Beo4 has a limited set of buttons (F5-F9 and the "u" key was left out). [/list] Kind regards, Jesper The sample autohotkey.ini modified for Beo4/WinLIRC/MP [code] ; Here are the steps to use this script: ; 1) Configure WinLIRC to recognize your remote control and its buttons. ; WinLIRC is at http://winlirc.sourceforge.net ; 2) Edit the WinLIRC path, address, and port in the CONFIG section below. ; 3) Launch this script. It will start the WinLIRC server if needed. ; 4) Press some buttons on your remote control. A small window will ; appear showing the name of each button as you press it. ; 5) Configure your buttons to send keystrokes and mouse clicks to ; windows such as Winamp, Media Player, etc. See the examples below. ; This script requires AutoHotkey 1.0.38 or later. ; HISTORY OF CHANGES ; October 5, 2005: ; - Eliminated Winsock warning dialog "10054" upon system shutdown/logoff. ; - Added option "DelayBetweenButtonRepeats" to throttle the repeat speed. ; ------------------------------------------------- ; CONFIGURATION SECTION: Set your preferences here. ; ------------------------------------------------- ; Some remote controls repeat the signal rapidly while you're holding down ; a button. This makes it difficult to get the remote to send only a single ; signal. The following setting solves this by ignoring repeated signals ; until the specified time has passed. 200 is often a good setting. Set it ; to 0 to disable this feature. DelayBetweenButtonRepeats = 200 ; Specify the path to WinLIRC, such as C:\WinLIRC\winlirc.exe WinLIRC_Path = c:\progra~1\WinLIRC\winlirc.exe ; Specify WinLIRC's address and port. The most common are 127.0.0.1 (localhost) and 8765. WinLIRC_Address = 127.0.0.1 WinLIRC_Port = 8765 ; Do not change the following two lines. Skip them and continue below. Gosub WinLIRC_Init return ; -------------------------------------------- ; ASSIGN ACTIONS TO THE BUTTONS ON YOUR REMOTE ; -------------------------------------------- ; Configure your remote control's buttons below. Use WinLIRC's names ; for the buttons, which can be seen in your WinLIRC config file ; (.cf file) -- or you can press any button on your remote and the ; script will briefly display the button's name in a small window. ; ; Below are some examples. Feel free to revise or delete them to suit ; your preferences. ;======================================================================= ;POWER 3 SEC: shut windows down ;======================================================================= beo4-all-power-off: Shutdown,5 return ;======================================================================= ;SAT = Launch MediaPortal (if crashed...) ;======================================================================= beo4-sat-on: Run,c:\progra~1\mediaportal\mediaportal.exe return ;======================================================================= ;V.TAPE = On Screen Display (OSD) if running, otherwise launch MP! ;======================================================================= beo4-vtape-on: Send,y return ;======================================================================= ;All numeric buttons naturally are sent without translation ;======================================================================= beo4-vtape-0: beo4-tv-0: Send,{Numpad0} return beo4-vtape-1: beo4-tv-1: Send,{Numpad1} return beo4-vtape-2: beo4-tv-2: Send,{Numpad2} return beo4-vtape-3: beo4-tv-3: Send,{Numpad3} return beo4-vtape-4: beo4-tv-4: Send,{Numpad4} return beo4-vtape-5: beo4-tv-5: Send,{Numpad5} return beo4-vtape-6: beo4-tv-6: Send,{Numpad6} return beo4-vtape-7: beo4-tv-7: Send,{Numpad7} return beo4-vtape-8: beo4-tv-8: Send,{Numpad8} return beo4-vtape-9: beo4-tv-9: Send,{Numpad9} return ;======================================================================= ;Arrow keys (while V.TAPE) are also passed on without translation ;======================================================================= beo4-vtape-left: Send,{LEFT} return beo4-vtape-right: Send,{RIGHT} return beo4-vtape-up: Send,{UP} return beo4-vtape-down: Send,{DOWN} return ;======================================================================= ; The Green button toggles windowed/full screen mode ;======================================================================= beo4-vtape-green: beo4-tv-green: Send,x return ;======================================================================= ; The Yellow button switches aspect ratio on videos/TV ; shows playlist/music/video in other modes ;======================================================================= beo4-vtape-yellow: beo4-tv-yellow: Send,{F1} Send,s return ;======================================================================= ; The Red button is used for pause ;======================================================================= beo4-vtape-red: beo4-tv-red: Send,{SPACE} return ;======================================================================= ; The Blue button = Enter ;======================================================================= beo4-vtape-blue: beo4-tv-blue: Send,{ENTER} return ;======================================================================= ; RECORD = record (TV mode), rotate (in Picture mode), Menu (in DVD mode) ;======================================================================= beo4-video-record: Send,r Send,m return ;======================================================================= ; MENU = display menu/info/IMDB lookup ;======================================================================= beo4-vtape-menu: beo4-tv-menu: Send,{F3} return ;======================================================================= ; STOP = stop/exit ;======================================================================= beo4-vtape-stop: beo4-tv-stop: Send,b return ;======================================================================= ; Volume up/down are passed as =/-, could be deleted to avoid ; simultaneously controlling your B&O TV and Media Portal ;======================================================================= beo4-video-vol-up: Send,= return beo4-video-vol-down: Send,- return ;======================================================================= ; EXIT = generally exits or steps one menu level back ;======================================================================= beo4-vtape-exit: beo4-tv-exit: Send,{ESC} return ;======================================================================= ; Switch to DVD mode and use the arrow buttons for FFD/REW and for ; skipping a full track/movie forward or backward ;======================================================================= beo4-tv-left: Send,{F5} return beo4-tv--right: Send,{F6} return beo4-tv-up: Send,{F7} return beo4-tv-down: Send,{F5} return ; ---------------------------- ; END OF CONFIGURATION SECTION ; ---------------------------- ; Do not make changes below this point unless you want to change the core ; functionality of the script. WinLIRC_Init: OnExit, ExitSub ; For connection cleanup purposes. ; Launch WinLIRC if it isn't already running: Process, Exist, winlirc.exe if not ErrorLevel ; No PID for WinLIRC was found. { IfNotExist, %WinLIRC_Path% { MsgBox The file "%WinLIRC_Path%" does not exist. Please edit this script to specify its location. ExitApp } Run %WinLIRC_Path% Sleep 200 ; Give WinLIRC a little time to initialize (probably never needed, just for peace of mind). } ; Connect to WinLIRC (or any type of server for that matter): socket := ConnectToAddress(WinLIRC_Address, WinLIRC_Port) if socket = -1 ; Connection failed (it already displayed the reason). ExitApp ; Find this script's main window: Process, Exist ; This sets ErrorLevel to this script's PID (it's done this way to support compiled scripts). DetectHiddenWindows On ScriptMainWindowId := WinExist("ahk_class AutoHotkey ahk_pid " . ErrorLevel) DetectHiddenWindows Off ; When the OS notifies the script that there is incoming data waiting to be received, ; the following causes a function to be launched to read the data: NotificationMsg = 0x5555 ; An arbitrary message number, but should be greater than 0x1000. OnMessage(NotificationMsg, "ReceiveData") ; Set up the connection to notify this script via message whenever new data has arrived. ; This avoids the need to poll the connection and thus cuts down on resource usage. FD_READ = 1 ; Received when data is available to be read. FD_CLOSE = 32 ; Received when connection has been closed. if DllCall("Ws2_32\WSAAsyncSelect", UInt, socket, UInt, ScriptMainWindowId, UInt, NotificationMsg, Int, FD_READ|FD_CLOSE) { MsgBox % "WSAAsyncSelect() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") ExitApp } return ConnectToAddress(IPAddress, Port) ; This can connect to most types of TCP servers, not just WinLIRC. ; Returns -1 (INVALID_SOCKET) on failure or the socket ID upon success. { VarSetCapacity(wsaData, 32) ; The struct is only about 14 in size, so 32 is conservative. result := DllCall("Ws2_32\WSAStartup", UShort, 0x0002, UInt, &wsaData) ; Request Winsock 2.0 (0x0002) ; Since WSAStartup() will likely be the first Winsock function called by this script, ; check ErrorLevel to see if the OS has Winsock 2.0 available: if ErrorLevel { MsgBox WSAStartup() could not be called due to error %ErrorLevel%. Winsock 2.0 or higher is required. return -1 } if result ; Non-zero, which means it failed (most Winsock functions return 0 on success). { MsgBox % "WSAStartup() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") return -1 } AF_INET = 2 SOCK_STREAM = 1 IPPROTO_TCP = 6 socket := DllCall("Ws2_32\socket", Int, AF_INET, Int, SOCK_STREAM, Int, IPPROTO_TCP) if socket = -1 { MsgBox % "socket() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") return -1 } ; Prepare for connection: SizeOfSocketAddress = 16 VarSetCapacity(SocketAddress, SizeOfSocketAddress) InsertInteger(2, SocketAddress, 0, AF_INET) ; sin_family InsertInteger(DllCall("Ws2_32\htons", UShort, Port), SocketAddress, 2, 2) ; sin_port InsertInteger(DllCall("Ws2_32\inet_addr", str, IPAddress), SocketAddress, 4, 4) ; sin_addr.s_addr ; Attempt connection: if DllCall("Ws2_32\connect", UInt, socket, UInt, &SocketAddress, Int, SizeOfSocketAddress) { MsgBox % "connect() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") . ". Is WinLIRC running?" return -1 } return socket ; Indicate success by returning a valid socket ID rather than -1. } ReceiveData(wParam, lParam) ; By means of OnMessage(), this function has been set up to be called automatically whenever new data ; arrives on the connection. It reads the data from WinLIRC and takes appropriate action depending ; on the contents. { socket := wParam ReceivedDataSize = 4096 ; Large in case a lot of data gets buffered due to delay in processing previous data. Loop ; This loop solves the issue of the notification message being discarded due to thread-already-running. { VarSetCapacity(ReceivedData, ReceivedDataSize, 0) ; 0 for last param terminates string for use with recv(). ReceivedDataLength := DllCall("Ws2_32\recv", UInt, socket, Str, ReceivedData, Int, ReceivedDataSize, Int, 0) if ReceivedDataLength = 0 ; The connection was gracefully closed, probably due to exiting WinLIRC. ExitApp ; The OnExit routine will call WSACleanup() for us. if ReceivedDataLength = -1 { WinsockError := DllCall("Ws2_32\WSAGetLastError") if WinsockError = 10035 ; WSAEWOULDBLOCK, which means "no more data to be read". return 1 if WinsockError <> 10054 ; WSAECONNRESET, which happens when WinLIRC closes via system shutdown/logoff. ; Since it's an unexpected error, report it. Also exit to avoid infinite loop. MsgBox % "recv() indicated Winsock error " . WinsockError ExitApp ; The OnExit routine will call WSACleanup() for us. } ; Otherwise, process the data received. Testing shows that it's possible to get more than one line ; at a time (even for explicitly-sent IR signals), which the following method handles properly. ; Data received from WinLIRC looks like the following example (see the WinLIRC docs for details): ; 0000000000eab154 00 NameOfButton NameOfRemote Loop, parse, ReceivedData, `n, `r { if A_LoopField in ,BEGIN,SIGHUP,END ; Ignore blank lines and WinLIRC's start-up messages. continue ButtonName = ; Init to blank in case there are less than 3 fields found below. Loop, parse, A_LoopField, %A_Space% ; Extract the button name, which is the third field. if A_Index = 3 ButtonName := A_LoopField global DelayBetweenButtonRepeats ; Declare globals to make them available to this function. static PrevButtonName, PrevButtonTime, RepeatCount ; These variables remember their values between calls. if (ButtonName != PrevButtonName || A_TickCount - PrevButtonTime > DelayBetweenButtonRepeats) { if IsLabel(ButtonName) ; There is a subroutine associated with this button. Gosub %ButtonName% ; Launch the subroutine. else ; Since there is no associated subroutine, briefly display which button was pressed. { if (ButtonName == PrevButtonName) RepeatCount += 1 else RepeatCount = 1 SplashTextOn, 150, 20, Button from WinLIRC, %ButtonName% (%RepeatCount%) SetTimer, SplashOff, 3000 ; This allows more signals to be processed while displaying the window. } PrevButtonName := ButtonName PrevButtonTime := A_TickCount } } } return 1 ; Tell the program that no further processing of this message is needed. } SplashOff: SplashTextOff SetTimer, SplashOff, Off return InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4) ; To preserve any existing contents in pDest, only pSize number of bytes starting at pOffset ; are altered in it. The caller must ensure that pDest has sufficient capacity. { mask := 0xFF ; This serves to isolate each byte, one by one. Loop %pSize% ; Copy each byte in the integer into the structure as raw binary data. { DllCall("RtlFillMemory", UInt, &pDest + pOffset + A_Index - 1, UInt, 1 ; Write one byte. , UChar, (pInteger & mask) >> 8 * (A_Index - 1)) mask := mask << 8 ; Set it up for isolation of the next byte. } } ExitSub: ; This subroutine is called automatically when the script exits for any reason. ; MSDN: "Any sockets open when WSACleanup is called are reset and automatically ; deallocated as if closesocket was called." DllCall("Ws2_32\WSACleanup") ExitApp [/code] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Support
General Support
Beo4 IR remote receiver
Contact us
RSS
Top
Bottom