Can HB press a button on a webpage

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
James D
Senior Member
Posts: 133
Joined: Wed Jun 06, 2007 3:30 pm
Location: Baja California

Can HB press a button on a webpage

Post by James D »

I need some help. I am currently using VLC Media Player for my music, movies and streaming videos. Inside the VLC media Player is a web interface. You can open up a web page and control the media player. The question I have is there a way to have Housebot press the control button that i see on the web (intranet) using a vbscript. Attached is a portion of the html file from the web. Any idea will be appreciated.

VLC media player
<button id="btn_toggle_text" onclick="toggle_btn_text();" title="Help" >
<img src="images/help.png" alt="Help" />
Help
</button>
</div>
<div class="controls">
<button id="btn_open" onclick="toggle_show('input');" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Open" >
<img src="images/eject.png" alt="Open" />
<span class="btn_text">Open</span>
</button>
&nbsp;
<button id="btn_stop" onclick="pl_stop();" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Stop" >
<img src="images/stop.png" alt="Stop" />
<span class="btn_text">Stop</span>
</button>
<!--<button id="btn_play" onclick="alert('FIXME');" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Play" >
<img src="images/play.png" alt="Play" />
<span class="btn_text">Play</span>
</button>-->
<button id="btn_pause" onclick="pl_pause();" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Pause" >
<img src="images/pause.png" alt="Pause" id="btn_pause_img" />
<span class="btn_text">Pause</span>
</button>
&nbsp;
<button id="btn_previous" onclick="pl_previous();" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Previous" >
<img src="images/prev.png" alt="Previous" />
<span class="btn_text">Previous</span>
</button>
<button id="btn_next" onclick="pl_next();" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Next" >
<img src="images/next.png" alt="Next" />
<span class="btn_text">Next</span>
</button>
&nbsp;
<button id="btn_sout" onclick="toggle_show('sout');" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Stream Output" >
<img src="images/sout.png" alt="Stream Output" />
<span class="btn_text">Stream Output</span>
</button>
<button id="btn_playlist" onclick="toggle_show('playlist');" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Playlist" >
<img src="images/playlist.png" alt="Playlist" />
<span class="btn_text">Playlist</span>
</button>
<button id="btn_info" onclick="toggle_show('info');" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Info" >
<img src="images/info.png" alt="Info" />
<span class="btn_text">Info</span>
</button>
&nbsp;
<button id="btn_fullscreen" onclick="fullscreen();" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Fullscreen" >
<img src="images/fullscreen.png" alt="Fullscreen" />
<span class="btn_text">Fullscreen</span>
</button>
&nbsp;
<button id="btn_snapshot" onclick="snapshot();" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Take video snapshot" >
<img src="images/snapshot.png" alt="Take video snapshot" />
<span class="btn_text">Take video snapshot</span>
</button>
&nbsp;
<button id="btn_volume_down" onclick="volume_down();" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Decrease Volume" >
<img src="images/volume_down.png" alt="Decrease Volume" />
<span class="btn_text">Decrease Volume</span>
</button>
<button id="btn_volume_up" onclick="volume_up();" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Increase Volume" >
<img src="images/volume_up.png" alt="Increase Volume" />
<span class="btn_text">Increase Volume</span>
</button>
</div>
<div id="status">
<span id="state">(?)</span>
-
Time : <span id="time">(?)</span>/<span id="length">(?)</span>
-
Volume : <span id="volume">(?)</span>
<br/>
<!-- progress bar -->
<img src="images/slider_left.png" alt="slider left" /><span id="progressbar" style="background-image: url( 'images/slider_bar.png' ); width: 408px; height:16px; position:absolute;" onclick="slider_seek( event, this );" onmousemove="slider_move( event, this );"><img src="images/slider_point.png" alt="slider point" style="position:relative; left:0px;" id="main_slider_point" onmousedown="slider_down( event, this );" onmouseup="slider_up( event, this.parentNode );" onmouseout="slider_up( event, this.parentNode );"/></span><img src="images/slider_right.png" alt="slider right" style="position:relative;left:408px;" />
<br/>
<span id="nowplaying">(?)</span>
</div>
</div>

<div id="info" class="dialog" style="display: none;" >
<div class="title">
Stream and media info
<img class="close" src="images/white_cross_small.png" alt="Close" onclick="hide('info');"/>
</div>
<div id="infotree">
</div>
</div>
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Re: Can HB press a button on a webpage

Post by Osler »

Take a look at AutoIt. I think it should be able to do what you want from within an AutoIt script. This can then be compiled into an executable that HouseBot can run.

http://www.autoitscript.com/autoit3/index.shtml

Osler
lostdreamer
Member
Posts: 54
Joined: Sat Apr 18, 2009 8:53 pm

Re: Can HB press a button on a webpage

Post by lostdreamer »

Actually,

Thanks to a 'feature' in just about every common browser it's also doable in VBscript.

First you have VBscript open up an instance of Internet Explorer and let it navigate to the page of VLC (where the button is)
When the page is loaded you let VBscript navigate that same window to the address "javascript:pl_stop();" to trigger that specific javascript.

I just tested the following script to still work in MSIE 8:

Code: Select all

' Create MSIE object
Set oIE = wscript.CreateObject("InternetExplorer.Application","IE_")
' Navigate to VLC page (Replace URL in here)
oIE.Navigate "http://localhost/test.html"
' set to 1 if you want to see what's happening in MSIE
oIE.Visible = 0
' Wait till we're done
Do While oIE.Busy
   wscript.sleep(10)
Loop
' Now call the javascript action (check the onclick action of the VLC buttons)
oIE.Navigate "javascript:pl_stop();"
' Wait a bit so the script can finnish, then close the window
wscript.sleep(500)
oIE.Quit
It's not very fast this way, having to start MSIE everytime
But I used this in early scripts where I didnt close the window, and when running the script, I would first let the script check if there was a MSIE window open with the right URL allready, if so it would use that.
I remember that one having < 0.1 seconds delay.

Regards,
LostDreamer
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Re: Can HB press a button on a webpage

Post by Richard Naninck »

Like Osler suggested, AutoIT can set mouse coordinates and perform mouseclicks. I use it to autologon to my camera webclient. I open the camera page in IE using HouseBot, than set the mousepointer in the username window and left click it, set my name, move the cursor to the password, set the password and then move to and click the login button. All timed of course but fully automated from within HouseBot using vbScript.
Post Reply