Grabbing net cam images using vbscript only
-
- Senior Member
- Posts: 141
- Joined: Tue Jul 07, 2009 12:55 pm
- Location: NC
Re: Grabbing net cam images using vbscript only
Hi Terry,
The task basically says when timer = 00:00 then run script.
However it is not working when i manually run the script and look at the file on the disk manually.
I have not yet put it into a swremote.
Raptor
The task basically says when timer = 00:00 then run script.
However it is not working when i manually run the script and look at the file on the disk manually.
I have not yet put it into a swremote.
Raptor
Re: Grabbing net cam images using vbscript only
I am not sure that you are connecting to the server. The orignal script has no error checking, it assumes you connected and all is well.
Try using the CreateObject(msxml2.xmlhttp) in the new script I posted in place of WinHTTP and see what happens.
Osler
Try using the CreateObject(msxml2.xmlhttp) in the new script I posted in place of WinHTTP and see what happens.
Osler
-
- Senior Member
- Posts: 141
- Joined: Tue Jul 07, 2009 12:55 pm
- Location: NC
Re: Grabbing net cam images using vbscript only
By server does it mean the Camera?
-
- Senior Member
- Posts: 141
- Joined: Tue Jul 07, 2009 12:55 pm
- Location: NC
Re: Grabbing net cam images using vbscript only
Hi,
no dice, i get the following error: Any ideas?
Terry, here are the tasks i have used: thanks for your help here guys....
no dice, i get the following error: Any ideas?
Terry, here are the tasks i have used: thanks for your help here guys....
-
- Senior Member
- Posts: 141
- Joined: Tue Jul 07, 2009 12:55 pm
- Location: NC
Re: Grabbing net cam images using vbscript only
ok, weird,
just messing with the code, breking it then putting it back it now works,
I think it is network traffic related....
EDIT: Spoke too soon stopped again.
just messing with the code, breking it then putting it back it now works,
I think it is network traffic related....
Code: Select all
Option Explicit
Dim URL
Dim File
Dim xmlHTTP
Dim ADOStream
Dim Date1
Date1 = Day(Date)&"-"&Month(Date)&"-"&Year(Date)&"-"&hour(now)&"h"&minute(now)&"m"&second(now)
URL = "http://192.168.2.160/image.jpg"
File = "D:\shares\Photos\Security Cam\Security-"&Date1&".jpg"
Set xmlHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
Call xmlHTTP.open ("GET", URL, False)
xmlHTTP.send()
Sleep(500)
If xmlHTTP.status = 200 Then
Set ADOStream = CreateObject("ADODB.Stream")
With ADOStream
.Type = 1
.Open()
.Write(xmlHTTP.responseBody)
.SaveToFile File, 2
.Close()
End With
Set ADOStream = Nothing
Else
MsgBox "There was an error."
End If
Set xmlHTTP = Nothing
Re: Grabbing net cam images using vbscript only
Do you have a firewall on the server?
From the server, run the following script by simply double clicking it. Don't use HouseBot...just run the script:
Click through the message boxes as the script runs and report back what happens.
Osler
From the server, run the following script by simply double clicking it. Don't use HouseBot...just run the script:
Code: Select all
Option Explicit
On Error Resume Next
MsgBox "Script is starting."
Dim URL
Dim File
Dim xmlHTTP
Dim ADOStream
Dim Date1
Dim WshShell
Date1 = Day(Date)&"-"&Month(Date)&"-"&Year(Date)&"-"&hour(now)&"h"&minute(now)&"m"&second(now)
URL = "http://192.168.2.160/image.jpg"
File = "D:\shares\Photos\Security Cam\Security-"&Date1&".jpg"
Set WshShell = WScript.CreateObject("WScript.Shell")
Set xmlHTTP = CreateObject("MSXML2.XMLHTTP")
If Err.Number <> 0 Then
MsgBox "There was a problem creating the objects. Error code: " & Err.Number
End If
MsgBox "Objects created."
Call xmlHTTP.open ("GET", URL, False)
xmlHTTP.send()
If Err.Number <> 0 Then
MsgBox "There was a problem sending the HTTP request. Error code: " & Err.Number
End If
WScript.Sleep 500
If xmlHTTP.status = 200 Then
MsgBox "Camera server reached successfully."
Set ADOStream = CreateObject("ADODB.Stream")
MsgBox "ADOStream object created."
With ADOStream
.Type = 1
.Open()
.Write(xmlHTTP.responseBody)
.SaveToFile File, 2
.Close()
End With
MsgBox "Image saved."
Set ADOStream = Nothing
Else
MsgBox "Camera server returned " & xmlHTTP.status & ". Unable to connect."
End If
Set xmlHTTP = Nothing
SetWshShell = Nothing
Osler
Re: Grabbing net cam images using vbscript only
Is the 5 Second Timer Device set to Repeat? If not then that would explain why it only runs once...raptor_demon wrote:Hi,
Terry, here are the tasks i have used:
Also, you may want to change the first line in the task from
If ('5 second timer.Remaining Time' is Equal '00:00')
to
If ('5 second timer.Running' is Equal 'No')
The remaining time property was a recent addition to the sleep device and while your logic is correct, perhaps HB is missing the 00 transition... Scott can answer that one. I know the "old schoolers" check for a running=no because when the timer hits zero and restarts, the running property momentarily transitions through Yes-No-Yes. It's a shot in the dark, but that's really the only difference between what you're doing and my scripts.
Terry
-
- Senior Member
- Posts: 141
- Joined: Tue Jul 07, 2009 12:55 pm
- Location: NC
Re: Grabbing net cam images using vbscript only
Hi Terry,
The sleep timer is set to repeat and I am getting images created every 5 seconds they are just identical.
Olser's new code seems to work sometimes iw ill do some more playing tonight....
Raptor
The sleep timer is set to repeat and I am getting images created every 5 seconds they are just identical.
Olser's new code seems to work sometimes iw ill do some more playing tonight....
Raptor
-
- Member
- Posts: 54
- Joined: Sat Apr 18, 2009 8:53 pm
Re: Grabbing net cam images using vbscript only
Simple problem, simple solutions:
The problem with the images not refreshing is easy..... Cache settings in MSIE.
MSXML2.XMLHTTP uses MSIE to get the URL, with all of MSIE's cache settings.
2 simple options for using the VBS posted by ossler in the beginning of this topic:
1) Open MSIE, go to Extra -> Options -> Temp files and History and set it to "Every time I open a website"
2) Edit the vbs
Becomes:
Sending the time with the POST data will make sure the result isn't from the cache.
Good luck,
LostDreamer
The problem with the images not refreshing is easy..... Cache settings in MSIE.
MSXML2.XMLHTTP uses MSIE to get the URL, with all of MSIE's cache settings.
2 simple options for using the VBS posted by ossler in the beginning of this topic:
1) Open MSIE, go to Extra -> Options -> Temp files and History and set it to "Every time I open a website"
2) Edit the vbs
Code: Select all
Call xmlHTTP.Open("GET", URL, False)
xmlHTTP.send()
Code: Select all
Call xmlHTTP.Open("POST", URL, False)
xmlHTTP.send "time="+ Now()
Good luck,
LostDreamer
-
- Senior Member
- Posts: 141
- Joined: Tue Jul 07, 2009 12:55 pm
- Location: NC
Re: Grabbing net cam images using vbscript only
Hi Osler,Osler wrote:Do you have a firewall on the server?
From the server, run the following script by simply double clicking it. Don't use HouseBot...just run the script:
Click through the message boxes as the script runs and report back what happens.Code: Select all
Option Explicit On Error Resume Next MsgBox "Script is starting." Dim URL Dim File Dim xmlHTTP Dim ADOStream Dim Date1 Dim WshShell Date1 = Day(Date)&"-"&Month(Date)&"-"&Year(Date)&"-"&hour(now)&"h"&minute(now)&"m"&second(now) URL = "http://192.168.2.160/image.jpg" File = "D:\shares\Photos\Security Cam\Security-"&Date1&".jpg" Set WshShell = WScript.CreateObject("WScript.Shell") Set xmlHTTP = CreateObject("MSXML2.XMLHTTP") If Err.Number <> 0 Then MsgBox "There was a problem creating the objects. Error code: " & Err.Number End If MsgBox "Objects created." Call xmlHTTP.open ("GET", URL, False) xmlHTTP.send() If Err.Number <> 0 Then MsgBox "There was a problem sending the HTTP request. Error code: " & Err.Number End If WScript.Sleep 500 If xmlHTTP.status = 200 Then MsgBox "Camera server reached successfully." Set ADOStream = CreateObject("ADODB.Stream") MsgBox "ADOStream object created." With ADOStream .Type = 1 .Open() .Write(xmlHTTP.responseBody) .SaveToFile File, 2 .Close() End With MsgBox "Image saved." Set ADOStream = Nothing Else MsgBox "Camera server returned " & xmlHTTP.status & ". Unable to connect." End If Set xmlHTTP = Nothing SetWshShell = Nothing
Osler
This script ran without issue when running manually on the desktop however when running the same script in housebot i get an error 500followed by a object created. then a error 13 followed by a camera reached.
LostDreamer,
unfortualty your code produced images that were empty
Raptor
Re: Grabbing net cam images using vbscript only
You can't use WSHShell from within HouseBot. Delete all references to it in the script and change "WScript.Sleep" to simply "Sleep". I had to use the shell to get a sleep function outside of HouseBot....but HB has one built in.
Osler
Osler
-
- Senior Member
- Posts: 141
- Joined: Tue Jul 07, 2009 12:55 pm
- Location: NC
Re: Grabbing net cam images using vbscript only
Thanks Osler,Osler wrote:You can't use WSHShell from within HouseBot. Delete all references to it in the script and change "WScript.Sleep" to simply "Sleep". I had to use the shell to get a sleep function outside of HouseBot....but HB has one built in.
Osler
this works great for the Netcam. For some reason tho it does not work well with my album art grab from the squeezebox server.
What did you change in the code?
Thanks
Raptor
Re: Grabbing net cam images using vbscript only
I didn't change anything...just made it so the script could run outside of HouseBot.
Post the URL for a album art grab from the squeezebox so I can take a look at it. How are you geting the albumarturi from the squeezebox?
Osler
Post the URL for a album art grab from the squeezebox so I can take a look at it. How are you geting the albumarturi from the squeezebox?
Osler
-
- Senior Member
- Posts: 141
- Joined: Tue Jul 07, 2009 12:55 pm
- Location: NC
Re: Grabbing net cam images using vbscript only
Hi here is the url:
http://192.168.2.150:9500/music/current ... macaddress of player}
your script works perfectly if i use the url in MSIE and refresh it everytime but if i do not refreshi it the image never changes.....
I have set my MSIE settings to update the page everytime i visit as suggested by lost dreamer.
Any ideas?
Raptor
http://192.168.2.150:9500/music/current ... macaddress of player}
your script works perfectly if i use the url in MSIE and refresh it everytime but if i do not refreshi it the image never changes.....
I have set my MSIE settings to update the page everytime i visit as suggested by lost dreamer.
Any ideas?
Raptor