VBscript on your Smartphone!, newObjects ActiveX Pack1 |
![]() ![]() |
VBscript on your Smartphone!, newObjects ActiveX Pack1 |
|
Mar 15 2005, 14:04
Post
#1
|
||
![]() Did I say that out loud? Group: News Team Posts: 4,530 Joined: 20th August 2003 From: Kent, England Member No.: 13,469 Device(s): Kaiser, Touch |
Much as I hate to credit Jacek with anything, he has found this thing which could be pretty cool.
QUOTE Version 2.4.5.3 (March 2005): ... - Special edition for Smartphone 2003 and later has been added with Micro Script Host designed for smartphone user interface. I haven't been playing with it for very long, but being able to use VBscripts opens up all sorts of options. newObjects: http://www.newobjects.com/product.asp?Category=63 msmobiles: http://www.msmoblies.com/news.php/3675.html |
||
|
|
|||
Mar 15 2005, 14:12
Post
#2
|
|||
|
Enthusiast Group: Posters Posts: 273 Joined: 6th March 2004 From: Lancaster, PA USA Member No.: 35,302 Device(s): E200 |
QUOTE(chucky.egg @ Mar 15 2005, 14:08) Much as I hate to credit Jacek with anything, he has found this thing which could be pretty cool. I haven't been playing with it for very long, but being able to use VBscripts opens up all sorts of options. newObjects: http://www.newobjects.com/product.asp?Category=63 msmobiles: http://www.msmoblies.com/news.php/3675.html Nice find! This might be something worth playing with. NS Basic is...errr....basically a wrapper around the VBScript library on larger CE boxes. Maybe this works in kind of the same manner? Let's count the seconds before Jackhole shows up screaming about imposters or whatever the rant du jour happens to be. :-D |
||
|
|
|||
Mar 16 2005, 11:17
Post
#3
|
|||
![]() Enthusiast Group: Posters Posts: 168 Joined: 21st June 2003 From: Denmark, Esbjerg Member No.: 8,568 |
What can this be used for?
|
||
|
|
|||
|
Mar 16 2005, 12:25
Post
#4
|
||
![]() Did I say that out loud? Group: News Team Posts: 4,530 Joined: 20th August 2003 From: Kent, England Member No.: 13,469 Device(s): Kaiser, Touch |
All sorts.
I'm trying to write a script to download the weather map for my area from the BBC website. If/When I get it working I will be able to schedule the download using xBar, and potentially use the Photo Plugin to make a homescreen that has the weather map embedded in it. But there are loads of things you could do with it... one of them is to copy files to the phone's Windows folder at startup, which is something some people have been after for a while I think |
||
|
|
|||
Mar 17 2005, 17:07
Post
#5
|
|||
![]() SpinDoctorBlow Group: Posters Posts: 2,765 Joined: 25th February 2003 From: Edinburgh, UK Member No.: 3,060 |
Em ... all that sounds really wow, but it's all a bit over my head! :oops:
Is this the kind of thing thats easy to pick up? Can somebody post any sample bits of code? -------------------- "... time is an illusion ... lunchtime doubly so ..."
http://monosapiens.9f.com |
||
|
|
|||
|
Mar 17 2005, 21:23
Post
#6
|
||
![]() Did I say that out loud? Group: News Team Posts: 4,530 Joined: 20th August 2003 From: Kent, England Member No.: 13,469 Device(s): Kaiser, Touch |
I'd love to, but so far NONE of my scripts are working! :oops:
I'll have to go back to the developer because it really should be working! CODE Set sf = Host.CreateObject("newObjects.utilctls.SFMain") b = sf.FolderExists("\Storage Card\Sprite Backups") if not b then set dir = sf.CreateDirectory("\Storage Card\Sprite Backups") cpy = sf.CopyFile("\Storage Card\HTC_2005-03-08.pbf","\Storage Card\Sprite Backups") del = sf.DeleteFile("\Storage Card\HTC_2005-03-08.pbf", True) What it does: Create the SFMain object, for access to the functions Test to see if a folder exists If it does NOT exist then create it ---All OK so far, but this is where it gives up: Copy all the Sprite backup files from the root of my SD card to a sub-directory Del the Sprite files from the root directory [EDIT] BTW the file specified in that code was part of me testing this thing. If the Copyfile function works you can specify /Storage Card/*.pbf to copy all the Sprite backups. Also note that the DeleteFile function does work (although the script stalls at the CopyFile line). If you were to remove the CopyFile line then it will delete the file specified in the DeleteFile line - so be careful! [/EDIT] This post has been edited by chucky.egg: Mar 17 2005, 22:13 |
||
|
|
|||
|
Mar 17 2005, 22:32
Post
#7
|
||
|
Regular Group: Posters Posts: 135 Joined: 23rd November 2002 From: London Member No.: 17 Device(s): Vario 3 |
I've had a quick look through the documentation and didn't see anything but does this give access to the contacts etc.?
|
||
|
|
|||
Mar 17 2005, 22:55
Post
#8
|
|||
![]() Newbie Group: Posters Posts: 16 Joined: 16th March 2005 Member No.: 117,495 Device(s): QTEK 8500 |
QUOTE(chucky.egg @ Mar 17 2005, 22:27) I'd love to, but so far NONE of my scripts are working! :oops: I'll have to go back to the developer because it really should be working! CODE Set sf = Host.CreateObject("newObjects.utilctls.SFMain") b = sf.FolderExists("\Storage Card\Sprite Backups") if not b then set dir = sf.CreateDirectory("\Storage Card\Sprite Backups") cpy = sf.CopyFile("\Storage Card\HTC_2005-03-08.pbf","\Storage Card\Sprite Backups") del = sf.DeleteFile("\Storage Card\HTC_2005-03-08.pbf", True) First of: IANAL, in this context: I am not a vb programmer... but I'd try something like this: CODE // the file(s) to be copied Source = "\Storage Card\HTC_2005-03-08.pbf" // the destination directory for the file(s) Destination = "\Storage Card\Sprite Backups" // create the object for accessing the filesystem Set sf = Host.CreateObject("newObjects.utilctls.SFMain") // check if the destination directory exists and if not create it if not sf.FolderExists("Destination") then sf.CreateDirectory("Destination") // copy the file sf.CopyFile("Source","Destination") // delete the file sf.DeleteFile("Source", True) BTW: if this does not work, what are the error messages you get? |
||
|
|
|||
Mar 18 2005, 03:44
Post
#9
|
|||
|
Enthusiast Group: Posters Posts: 273 Joined: 6th March 2004 From: Lancaster, PA USA Member No.: 35,302 Device(s): E200 |
QUOTE(chucky.egg @ Mar 17 2005, 21:27) I'd love to, but so far NONE of my scripts are working! :oops: I'll have to go back to the developer because it really should be working! CODE Set sf = Host.CreateObject("newObjects.utilctls.SFMain") b = sf.FolderExists("\Storage Card\Sprite Backups") if not b then set dir = sf.CreateDirectory("\Storage Card\Sprite Backups") cpy = sf.CopyFile("\Storage Card\HTC_2005-03-08.pbf","\Storage Card\Sprite Backups") del = sf.DeleteFile("\Storage Card\HTC_2005-03-08.pbf", True) What it does: Create the SFMain object, for access to the functions Test to see if a folder exists If it does NOT exist then create it ---All OK so far, but this is where it gives up: Copy all the Sprite backup files from the root of my SD card to a sub-directory Del the Sprite files from the root directory [EDIT] BTW the file specified in that code was part of me testing this thing. If the Copyfile function works you can specify /Storage Card/*.pbf to copy all the Sprite backups. Also note that the DeleteFile function does work (although the script stalls at the CopyFile line). If you were to remove the CopyFile line then it will delete the file specified in the DeleteFile line - so be careful! [/EDIT] You've got to specify a full filename as the target of the CopyFile() call. For example: Set sf = Host.CreateObject("newObjects.utilctls.SFMain") b = sf.FolderExists("\Storage Card\backup") if not b then set dir = sf.CreateDirectory("\Storage Card\backup") cpy = sf.CopyFile("\Storage Card\test.vbs","\Storage Card\backup\test.vbs") does work whereas cpy = sf.CopyFile("\Storage Card\test.vbs","\Storage Card\backup") does not. Functions like these are most likely just thin wrappers around the API functions so you can always look them up on msdn.microsoft.com and see if the MS docs differ from or expand on the object docs. This post has been edited by markgamber: Mar 18 2005, 03:46 |
||
|
|
|||
|
Mar 18 2005, 08:39
Post
#10
|
||
![]() Did I say that out loud? Group: News Team Posts: 4,530 Joined: 20th August 2003 From: Kent, England Member No.: 13,469 Device(s): Kaiser, Touch |
OMG!
If that work's I'll marry you! Subject to a £10m dowry [EDIT] OK, that works! But... before you get to consumate this... How do I get it to work with wildcards? If I specify a destination filename it just copies each file in turn onto that file, and if I specify a *.pbf or I don't specify one at all it just fails [/EDIT] This post has been edited by chucky.egg: Mar 18 2005, 08:55 |
||
|
|
|||
Mar 18 2005, 13:38
Post
#11
|
|||
|
Enthusiast Group: Posters Posts: 273 Joined: 6th March 2004 From: Lancaster, PA USA Member No.: 35,302 Device(s): E200 |
QUOTE(chucky.egg @ Mar 18 2005, 08:43) OMG! If that work's I'll marry you! Subject to a £10m dowry [EDIT] OK, that works! But... before you get to consumate this... How do I get it to work with wildcards? If I specify a destination filename it just copies each file in turn onto that file, and if I specify a *.pbf or I don't specify one at all it just fails [/EDIT] API functions don't work with wildcards but there are objects used to manipulate directory contents. An example: Set sf = Host.CreateObject("newObjects.utilctls.SFMain") set fout = sf.CreateFile( "\Storage Card\test.txt" ) fout.WriteText "Dir listing:" + Chr(13), 1 set dir = sf.OpenDirectory( "\Storage Card\Source" ) set c = dir.contents for each i in c fout.WriteText i.name, 1 next fout.Close set sf = nothing The above code creates a text file so you can see what's going on. Then it opens the directory "\Storage Card\Source" which creates an SFStorage object (dir). The contents property of that object returns a collection of SFInfo objects ( c ), each of which (i) represents a file. As each SFInfo object is retrieved from the collection in the for each loop, it's name property is written out to the text file. All you should have to do to copy files, for example, would be something like: e = CopyFile( "\Storage Card\Source\" + i.name, "\Storage Card\Dest\" + i.name ) I'm not claiming that will work as-is, it might require some variable manipulation so the types are the same, but hopefully you get the idea. Note that OpenDirectory does NOT take a wildcard, either. You can't do set dir = sf.OpenDirectory( "\Storage\Stuff\*.txt" ) Instead, you always get a collection of all files and have to figure out which you want to deal with and which you don't via code. Oh....no offense but I'll pass on the marriage. I think my wife would probably object and you know how those Irish can be. ;-) And one last note just for future reference...the E200 does NOT appear to have vbscript.dll installed. To run anything on these (and probably other) devices, you'll need to include and register that DLL which is available by itself from the newobjects.com site. I forget the URL offhand but they have it in the docs. This post has been edited by markgamber: Mar 18 2005, 13:57 |
||
|
|
|||
|
Mar 18 2005, 14:18
Post
#12
|
||
![]() Did I say that out loud? Group: News Team Posts: 4,530 Joined: 20th August 2003 From: Kent, England Member No.: 13,469 Device(s): Kaiser, Touch |
Well thanks for the advice, even if you don't wanna get hitched!
I'm off to play and see if I can get this to do anything remotely useful! |
||
|
|
|||
Mar 18 2005, 14:21
Post
#13
|
|||
|
Enthusiast Group: Posters Posts: 273 Joined: 6th March 2004 From: Lancaster, PA USA Member No.: 35,302 Device(s): E200 |
QUOTE(chucky.egg @ Mar 18 2005, 14:22) Well thanks for the advice, even if you don't wanna get hitched! I'm off to play and see if I can get this to do anything remotely useful! Just FYI, here's some example code that does work. It gets a directory listing for \Storage Card\Source and moves all the files to \Storage Card\Backup. As it runs, it displays each file's source and destination filenames, the position of a "." in the filename and the extension of the filename. Note the complete lack of error checking and assumption that there's only one "." in each filename which indicates the extension....bad assumptions but this is only a display model. Set sf = Host.CreateObject("newObjects.utilctls.SFMain") Host.Clear Host.WriteLine "Directory Listing" set dir = sf.OpenDirectory( "\Storage Card\Source" ) set c = dir.contents for each i in c s = "\Storage Card\Source\" + i.name d = "\Storage Card\Backup\" + i.name Host.WriteLine s Host.WriteLine d Host.WriteLine InStr( s, "." ) Host.WriteLine Mid( s, InStr( s, "." ) + 1 ) sf.CopyFile s, d sf.DeleteFile s next set sf = nothing An example of looking for specific file types: for each i in c ' Use ONLY filename and work from end to start looking for extension iExt = InStrRev( i.name, "." ) ' If an extension separater was found... if iExt > 0 then ' Pull extension from filename sExt = Mid( i.name, iExt + 1 ) ' If it's a text file, display the filename if sExt = "txt" then Host.WriteLine "\Storage Card\Source\" + i.name end if end if next set sf = nothing This post has been edited by markgamber: Mar 18 2005, 14:55 |
||
|
|
|||
|
Mar 18 2005, 15:12
Post
#14
|
||
![]() Did I say that out loud? Group: News Team Posts: 4,530 Joined: 20th August 2003 From: Kent, England Member No.: 13,469 Device(s): Kaiser, Touch |
You're a useful chap to know!
I've not had time to play with this as much as I'd like, but I'll try over the weekend. Thanks for all your examples! |
||
|
|
|||
Mar 23 2005, 21:00
Post
#15
|
|||
|
Regular Group: Posters Posts: 55 Joined: 13th March 2004 Member No.: 36,184 Device(s): m3100 |
Hi..
At the risk of dumbing this down a bit ! Having investigated this for a while, I'm sure this is going to be really useful, thing is, I think I've fallen at the first hurdle.. This my aim.. On my c500 I would like to run a .vbs file (which I already have) at startup (i presume placing it in the start up folder will acheive this bit?). Problem is I'm a bit confused as to how i can get vb enabled.! I've tried the smartphone downloads from the link in the first post but these won't allow me to install on the phone, saying they are made for a different version. Maybe I am downloading the wrong things ? My wild-goose-chase has also led me to download the wm2003 sdk and the vbscript.dll (which I'm sure has something to do with it but am darned if i know how to register it!!?) I figure you guys have already gone through this (well, the correct) process so hopefully you can give me a rolling start here !! Thanks ;-] |
||
|
|
|||
|
Mar 23 2005, 21:22
Post
#16
|
||
![]() Did I say that out loud? Group: News Team Posts: 4,530 Joined: 20th August 2003 From: Kent, England Member No.: 13,469 Device(s): Kaiser, Touch |
You need to download the Smartphone-specific newObjects MicroHost bit, and the VBscript.dll
Smartphone-specific newObjects MicroHost: http://www.newobjects.com/downloads/axpack1/spn2003.zip VBScript.dll http://www.newobjects.com/downloads/axpack1/vbscript.dll Assuming you've now got those bits you unzip them and then copy the files to your phone. I've put mine in / Storage Card / MicroHost and created a shortcut to MicroHost.exe in the Start Menu Then, on the phone, run MicroHost. I can't remember the menus but it goes something like this: you want the right softkey, then "Tools", then "Register DLLs". Register all 4 of the DLLs (you might not need them all, but there's no harm in registering them anyway). AFAIK you can't just run the VBS file on it's own. You need to create a link something like this: /storage card/microhost/microhost.exe scriptfile.vbs Share your VBS, and (when I get some time) I'll post some here too. |
||
|
|
|||
Mar 23 2005, 21:36
Post
#17
|
|||
|
Regular Group: Posters Posts: 55 Joined: 13th March 2004 Member No.: 36,184 Device(s): m3100 |
Thanks chucky...
I'll try this and post my results.. ;-] |
||
|
|
|||
Mar 23 2005, 23:10
Post
#18
|
|||
|
Regular Group: Posters Posts: 55 Joined: 13th March 2004 Member No.: 36,184 Device(s): m3100 |
Excellent.. Thanks..
MicroHost and vbscript installed and my vbs file runs in microhost no problems... This is what I went with btw, to copy a couple of files to \windows (inspired by posts above!) . . . CODE File1 = "\Storage\Application Data\ToCopy\root.cpl.xml" File2 = "\Storage\Application Data\ToCopy\sounds2.cpl.xml" Copy1 = "\Windows\root.cpl.xml" Copy2 = "\Windows\sounds2.cpl.xml" Set sf = Host.CreateObject("newObjects.utilctls.SFMain") go1 = sf.CopyFile(File1,Copy1) go2 = sf.CopyFile(File2,Copy2) Now tho i feel a little more hand-holding is required ! I need to create the shortcut for the startup folder. I started with a working link to nwmicrohost.exe but i just can't get the scriptfile parameter to work so it runs the vbs. I've tried every variation of / and \ and " and ' but I just can't get it. These are the relevant paths.. "\Storage\Program Files\MicroHost\nwmicrohost.exe" "\Storage\Application Data\ToCopy\AutoCopy.vbs" Any help appreciated.. ;-] |
||
|
|
|||
|
Mar 24 2005, 09:45
Post
#19
|
||
![]() Did I say that out loud? Group: News Team Posts: 4,530 Joined: 20th August 2003 From: Kent, England Member No.: 13,469 Device(s): Kaiser, Touch |
I haven't got to that stage yet, but what I had expected to do was...
Create a shortcut to microhost.exe Edit the shortcut in Notepad or similar and add the path to the VBS If you create a shortcut and open it in Notepad what you see is: CODE 55#"\Storage Card\Program Files\MicorHost\nwmicrohost.exe" So I would guess you either need: CODE 55#"\Storage\Program Files\MicroHost\nwmicrohost.exe" "\Storage\Application Data\ToCopy\AutoCopy.vbs" Or... CODE 55#"\Storage\Program Files\MicroHost\nwmicrohost.exe \Storage\Application Data\ToCopy\AutoCopy.vbs" There are some notes on how to call scripts in the MicroHost readme This post has been edited by chucky.egg: Mar 24 2005, 09:48 |
||
|
|
|||
Mar 24 2005, 12:39
Post
#20
|
|||
|
Regular Group: Posters Posts: 55 Joined: 13th March 2004 Member No.: 36,184 Device(s): m3100 |
YES !
I'm up and running now ;-] This is my shorcut... CODE 202#"\Storage\Program Files\MicroHost\nwmicrohost.exe" "\Storage\Application Data\ToCopy\AutoCopy.vbs" The mistake i'd been making was keeping both paths inside one set of double quotes like in your second suggestion. Thought i'd tried everything! So, by putting this shortcut in startup i am now succesfully copying my files over to \windows seemlessly at start up.. I can see a lot more potential here now the vbs is working. Thanks for your help chucky, you's a star ! ;-] |
||
|
|
|||