Basically you connect via TCP to your Roku device on port 8080, so you
need to know its network address and there are just a handful of
commands to control functions. I'm copying the full script below so
that perhaps someone can tell me if it's even possible to do in Hecl
or if I should consider taking a Python course. :-)
BTW, I personally don't care about the GUI component since I
deliberately went old school for real phone keys. I'd be okay with
something like "1 = Down", "2 - Home", "3 = Up", etc. since there are
only 9 basic functions to handle and using the numeric keys would make
it more portable for other phones, like Windows Smartphones. It's
just how to do the network connection that I didn't see in the
documentation but if it's possible, that would really be great.
Thanks,
Terry (who only has basic Perl and VBScripting skills)
-- start script = RokuRemote(v3).au3--
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
AutoItSetOption ( "TrayAutoPause",0) ;0=no pause, 1=Pause
Opt("GUICloseOnESC", 0) ;1=ESC closes, 0=ESC won't close
$frmRemote = GUICreate("Roku Remote", 243, 360, 419, 171)
$btnSelect = GUICtrlCreateButton("Select", 96, 80, 50, 41, 0)
$btnDown = GUICtrlCreateButton("Down", 96, 128, 50, 25, 0)
$btnUp = GUICtrlCreateButton("Up", 96, 48, 50, 25, 0)
$btnRight = GUICtrlCreateButton("Right", 160, 88, 50, 25, 0)
$btnLeft = GUICtrlCreateButton("Left", 32, 88, 50, 25, 0)
$btnPause = GUICtrlCreateButton("Play/Pause", 86, 176, 70, 25, 0)
$btnForward = GUICtrlCreateButton("Forward", 160, 176, 50, 25, 0)
$btnRewind = GUICtrlCreateButton("Rewind", 32, 176, 50, 25, 0)
$btnHome = GUICtrlCreateButton("Home", 80, 8, 83, 25, 0)
; ROKU IP setting section
GUICtrlCreateLabel("_________________________________________", 5,
210, 233, 0)
GUICtrlCreateLabel("Settings", 5, 225, 233, 0)
$lblDevice = GUICtrlCreateLabel("Roku's IP Address: ", 18, 248, 100,
21)
$txtDevice = GUICtrlCreateInput("192.168.1.", 113, 245, 110, 21)
$btnSave_IP = GuiCtrlCreateButton("Save IP to file", 10, 265, 100, 20)
GUICtrlCreateLabel("_________________________________________", 5,
285, 233, 0)
GUICtrlCreateLabel("Roku Hidden Tools", 5, 300, 233, 0)
$btnBitrate = GUICtrlCreateButton("Bit Rate", 10, 320, 60, 25, 0)
$btnRestart = GUICtrlCreateButton("Reboot", 173, 320, 60, 25, 0)
GUISetState(@SW_SHOW)
$file = FileOpen("RokuRemote.ini", 0)
; Check if file opened for reading OK
If $file = -1 Then
MsgBox(0, "Notice", "No previously saved IP exist.")
Else
$IPline = FileReadLine($file)
;MsgBox (0, "Saved IP:", $IPline) ;for testing to see IP saved to
file
GUICtrlSetData ( $txtDevice, $IPline)
FileClose($file)
EndIf
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $btnSelect
rokuCommand("press select")
Case $msg = $btnDown
rokuCommand("press down")
Case $msg = $btnUp
rokuCommand("press up")
Case $msg = $btnRight
rokuCommand("press right")
Case $msg = $btnLeft
rokuCommand("press left")
Case $msg = $btnPause
rokuCommand("press pause")
Case $msg = $btnForward
rokuCommand("press fwd")
Case $msg = $btnRewind
rokuCommand("press back")
Case $msg = $btnHome
rokuCommand("press home")
Case $msg = $btnBitrate
rokuCommand("press home")
rokuCommand("press home")
rokuCommand("press home")
rokuCommand("press home")
rokuCommand("press home")
rokuCommand("press back")
rokuCommand("press back")
rokuCommand("press back")
rokuCommand("press fwd")
rokuCommand("press fwd")
Case $msg = $btnRestart
rokuCommand("press home")
rokuCommand("press home")
rokuCommand("press home")
rokuCommand("press home")
rokuCommand("press home")
rokuCommand("press up")
rokuCommand("press back")
rokuCommand("press back")
rokuCommand("press fwd")
rokuCommand("press fwd")
Case $msg = $btnSave_IP
$file = FileOpen("RokuRemote.ini", 2)
; Check if file opened for reading OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to create settings file.")
Exit
EndIf
Dim $SaveIp = GUICtrlRead($txtDevice)
FileWrite($file, $SaveIp)
FileClose($file)
EndSelect
WEnd
Func rokuCommand($command)
Dim $rokuIp = GUICtrlRead($txtDevice)
Dim $rokuPort = "8080"
TCPStartUp()
$rokuSocket = TCPConnect( $rokuIp, $rokuPort )
if @error Then
MsgBox(4112, "Error", "TCPConnect failed: " & @error)
EndIf
TCPSend($rokuSocket, $command & @CRLF)
TCPCloseSocket($rokuSocket)
TCPShutdown()
Sleep(50)
EndFunc
--end script--
On Wed, Apr 7, 2010 at 11:00 PM, terryowen <terr...@gmail.com> wrote:
> I am a fairly new Nokia N79 phone user and while I don't miss a
> touchscreen very often, one thing I really do miss is my Roku remote
> replacement that I had on my G1. Since my phone has wifi I keep
> thinking there should be some way to knock together a script that
> would send the fairly simple commands but Symbian isn't exactly loaded
> with lots of scripting options other than Python, that I can tell. I
> wasn't able to locate the Python version of the Roku remote that I've
> seen references to but I did download an Autohotkey version that works
> pretty well from my laptop. (Note: I would credit it but the author
> didn't include a name in the code.)
> Basically you connect via TCP to your Roku device on port 8080, so you
> need to know its network address and there are just a handful of
> commands to control functions. I'm copying the full script below so
> that perhaps someone can tell me if it's even possible to do in Hecl
> or if I should consider taking a Python course. :-)
Sort of odd that they use 8080, but it's not an http connection...
> BTW, I personally don't care about the GUI component since I
> deliberately went old school for real phone keys. I'd be okay with
> something like "1 = Down", "2 - Home", "3 = Up", etc. since there are
> only 9 basic functions to handle and using the numeric keys would make
> it more portable for other phones, like Windows Smartphones. It's
> just how to do the network connection that I didn't see in the
> documentation but if it's possible, that would really be great.
With Hecl, what you'll want to do is fiddle around some to get a feel
for it. The components you'll need are:
1) Canvas
2) Sockets
I just checked in the code for the latter, so it's kind of
experimental, but shouldn't be that hard.
There's a canvas example in midp20/script.hcl and sockets would work like this:
proc rokuCmd {cmd} {
set s [socket [getIPaddressfromGui] 8080]
$s writeln $cmd
$s close
}
Do let us know if you have any problems, we'll try and deal with them
as they come up.
--
David N. Welton