Android Tablets Forum banner

HOME AUTOMATION: XBMC, a USB wireless remote and your tablet

2K views 0 replies 1 participant last post by  Carnivore 
#1 · (Edited by Moderator)
This guide will teach you how to program XBMC, Hulu and Netflix to be turned on using your remote or tablet.



My remote:
Lenovo N5902
Software needed on HTPC:
XBMC 11.0 Eden
Hulu Desktop
Netflix plugin for Windows Media Center
Winhotkey
Autohotkey

Open autohotkey, create a new script and save as XBMC.ahk :

IfWinExist XBMC
{
WinActivate

}
else
{
Run C:\\Program Files (x86)\\XBMC\\XBMC.exe
WinWait XBMC
WinActivate

}

IfWinExist, Hulu Desktop
WinClose ;

IfWinExist, Windows Media Center
WinClose ;

IfWinExist, Skyrim
WinClose

#SingleInstance force
#Persistent
SetBatchLines -1
Process Priority,,R

BlockInput mouse
CoordMode Mouse, Screen
SetMouseDelay -1

movementStep = 100
timerWait = 100

SetTimer gesture, %timerWait%
Return

gesture:
if winactive("ahk_class XBMC")
{
mousegetpos, xpos2, ypos2

dx:=xpos2-xpos1
dy:=ypos1-ypos2
if (abs(dy)>=abs(dx))
{
if (dy>0)
track=u ;track is up
else
track=d ;down
} else {
if (dx>0)
track=r ;right
else
track=l ;left
}
if (abs(dy)<movementStep and abs(dx)<movementStep)
{
track= ;not tracking at all if no significant change in x or y

if (xpos2<movementStep OR xpos2>A_ScreenWidth-movementStep)
xpos2 := A_ScreenWidth /2
if (ypos2<movementStep OR ypos2>A_ScreenHeight-movementStep)
ypos2 := A_ScreenHeight / 2

MouseMove xpos2, ypos2, 0
}
xpos1:=xpos2
ypos1:=ypos2
if (track<>SubStr(gesture, 0, 1)) ;ignore track if not changing since previous track
{
gesture := track
if islabel(gesture) ;checks if gesture is labelled
gosub, %gesture% ; eg. gosub, gdr
}
}
return

u:
SendInput {Up}
Return

d:
SendInput {Down}
Return

l:
SendInput {Left}
Return

r:
SendInput {Right}
Return

{click}:
SendInput {enter}
Return

WheelDown::
SendInput {Down}
Return

WheelUp::
SendInput {Up}
Return

LButton::
if winactive("ahk_class XBMC")
{
SendInput {Enter}
} else {
SendInput {LButton}
}
Return

RButton::
if winactive("ahk_class XBMC")
{
SendInput {Esc}
} else {
SendInput {RButton}
}
Return

Open autohotkey, create a new script and save as HULU.ahk but you will need to modify this script to redirect the ahk script to where your hulu desktop executable file is :

IfWinExist Hulu Desktop
{
WinActivate
WinMaximize ;
}
else
{
Run C:\location_where_hulu_file_is_located\hulu.exe
WinWait Hulu Desktop
WinActivate
WinMaximize ;
}

IfWinExist, XBMC
WinClose ;

IfWinExist, Windows Media Center
WinClose ;

IfWinExist, Skyrim
WinClose ;

#SingleInstance force
#Persistent
SetBatchLines -1
Process Priority,,R

BlockInput mouse
CoordMode Mouse, Screen
SetMouseDelay -1

movementStep = 100
timerWait = 100

SetTimer gesture, %timerWait%
Return

gesture:
if winactive("Hulu Desktop")
{
mousegetpos, xpos2, ypos2

dx:=xpos2-xpos1
dy:=ypos1-ypos2
if (abs(dy)>=abs(dx))
{
if (dy>0)
track=u ;track is up
else
track=d ;down
} else {
if (dx>0)
track=r ;right
else
track=l ;left
}
if (abs(dy)<movementStep and abs(dx)<movementStep)
{
track= ;not tracking at all if no significant change in x or y

if (xpos2<movementStep OR xpos2>A_ScreenWidth-movementStep)
xpos2 := A_ScreenWidth /2
if (ypos2<movementStep OR ypos2>A_ScreenHeight-movementStep)
ypos2 := A_ScreenHeight / 2

MouseMove xpos2, ypos2, 0
}
xpos1:=xpos2
ypos1:=ypos2
if (track<>SubStr(gesture, 0, 1)) ;ignore track if not changing since previous track
{
gesture := track
if islabel(gesture) ;checks if gesture is labelled
gosub, %gesture% ; eg. gosub, gdr
}
}
return

u:
SendInput {Up}
Return

d:
SendInput {Down}
Return

l:
SendInput {Left}
Return

r:
SendInput {Right}
Return

{click}:
SendInput {enter}
Return

LButton::
if winactive("Hulu Desktop")
{
SendInput {Enter}
} else {
SendInput {LButton}
}
Return

RButton::
if winactive("Hulu Desktop")
{
SendInput {Esc}
} else {
SendInput {RButton}
}
Return

Open autohotkey, create a new script and save as NETFLIX.ahk but you will need to modify this script to redirect the ahk script to your NETFLIX.bat script:

IfWinExist Windows Media Center
{
WinActivate
WinMaximize ;
}
else
{
Run C:\location_where_netflix.bat_is_located\netflix.bat
WinWait Windows Media Center
WinActivate
WinMaximize ;
}

IfWinExist, XBMC
WinClose ;

IfWinExist, Hulu Desktop
WinClose ;

IfWinExist, Skyrim
WinClose ;

#SingleInstance force
#Persistent
SetBatchLines -1
Process Priority,,R

BlockInput mouse
CoordMode Mouse, Screen
SetMouseDelay -1

movementStep = 100
timerWait = 100

SetTimer gesture, %timerWait%
Return

gesture:
if winactive("Windows Media Center")
{
mousegetpos, xpos2, ypos2

dx:=xpos2-xpos1
dy:=ypos1-ypos2
if (abs(dy)>=abs(dx))
{
if (dy>0)
track=u ;track is up
else
track=d ;down
} else {
if (dx>0)
track=r ;right
else
track=l ;left
}
if (abs(dy)<movementStep and abs(dx)<movementStep)
{
track= ;not tracking at all if no significant change in x or y

if (xpos2<movementStep OR xpos2>A_ScreenWidth-movementStep)
xpos2 := A_ScreenWidth /2
if (ypos2<movementStep OR ypos2>A_ScreenHeight-movementStep)
ypos2 := A_ScreenHeight / 2

MouseMove xpos2, ypos2, 0
}
xpos1:=xpos2
ypos1:=ypos2
if (track<>SubStr(gesture, 0, 1)) ;ignore track if not changing since previous track
{
gesture := track
if islabel(gesture) ;checks if gesture is labelled
gosub, %gesture% ; eg. gosub, gdr
}
}
return

u:
SendInput {Up}
Return

d:
SendInput {Down}
Return

l:
SendInput {Left}
Return

r:
SendInput {Right}
Return

{click}:
SendInput {enter}
Return

LButton::
if winactive("Windows Media Center")
{
SendInput {Enter}
} else {
SendInput {LButton}
}
Return

RButton::
if winactive("Windows Media Center")
{
SendInput {Esc}
} else {
SendInput {RButton}
}
Return

Create a batch file called Netflix.bat and type this in

Start "C:\Program Files\Internet Explorer\iexplore.exe" windowsmediacenterapp:{e6f46126-f8a9-4a97-9159-b70b07890112}\{982ea9d3-915c-4713-a3c8-99a4688b7c59}?EntryPointParameters=')

Open winhotkey
new rule
unselect 'Windows'
select Home
under action, launch application
locate XBMC.ahk

new rule
unselect 'Windows'
select End
under action, launch application
locate HULU.ahk

new rule
unselect 'Windows'
select PgUp
under action, launch application
locate NETFLIX.ahk

On your tablet
download the XBMC remote for android and XBMC for android (alpha).
Set it up (look online for guides, I know there are plenty)

To make Psuedotv auto turn on when XBMC starts
create autoexec.py and paste this in
import time;time.sleep(5);xbmc.executebuiltin("XBMC.RunScript(special://home/addons/script.pseudotv/default.py,-startup)")
place into C:\Users\your_name\AppData\Roaming\XBMC\userdata

To make mouse disappear
download nomousey
http://www.autohotkey.com/community/viewtopic.php?t=2197

What this does in a nutshell
Whenever you press Home on your Lenovo n9502, it will launch XBMC and kill HULU/NETFLIX. The mouse is reprogrammed to be the up/down/left/right arrow keys while XBMC is running.
When you press End, it will kill XBMC/NETFLIX and launch Hulu. The mouse is reprogrammed to be the up/down/left/right arrow keys while Hulu is running.
When you press PgUp, it will kill HULU/XBMC and launch Netflix. The mouse is reprogrammed to be the up/down/left/right arrow keys while Netflix is running.
The scroll bar is reprogrammed to be up/down
 
See less See more
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top