Home

Cardbox Talk

 

CardboxForumsCardbox Talk > "Start a VBScript when Cardbox launches"

Start a VBScript when Cardbox launches

Starting a script that runs continuously in the background whilst Cardbox runs, (and shuts down when Cardbox closed)

Current user: [none]
Register / Log In · Help

Posted By Post

cristoayre

6-Feb-2015 12:52

I have cobbled together some code that runs in a DO LOOP, and reads a folder. At present, it simply shows the files present in the folder**. But of course, VBScript doesn't pick up key presses to break out of the loop, so I added a line that stops the thing running when a grapic named "stop.JPG" appears in folder. (Must admit, when I renamed the file in folder, the program complained first time, but on next iteration, it stopped as expected)

Now, to start this script, I ran it in IE, which is not the preferred way to do it. I know Cardbox has "Launch", but not sure how to start - of even if - this would run the VBS in background. (I tried a macro, but that didn't start the DO loop, and only ran once) As stated, I would LIKE to start and stop with Cardbox. I don't really want to have to start IE, then hunt for the script every time I want to start it up. Any ideas?

Option Explicit
Dim objShell,objFSO,objStartFolder,objFolder,colFiles,objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\Users\Chris Brown\Desktop\PhotoBooth\hot"

Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
Set objShell = CreateObject("WScript.Shell")
CheckFolder()
wscript.Echo "Stopped VBS"

Sub CheckFolder()
Do
For Each objFile in colFiles
wscript.Echo objFile.Name
If objFile.Name="stop.JPG" Then Exit Do
Next
WScript.Sleep 15000'15 seconds pause between loops
Loop
End Sub

** The script will eventually copy the picture out of "hot" and into "print", and append an entry to a text file.

bert

6-Feb-2015 13:35

-First: is you click on a .vbs and IE starts, there something wrong with you file association in Windows. Repair that! In my opinion it should be associated with C:\Windows\System32\WScript.exe
-You add in a macro a launch command for starting a vbs file. While the vbs script is running then, the Cardbox macro continues – and end when it’s ready.
-In the vbs you can add commands for doing the things you want and then terminate itself when ready.
-In Cardbox it is possible to add a “startup” macro. See Help how to do this.
Doing this:
-When Carbox is started – the wished startup macro starts.
-That macro launches a vbs file. That waits for the jpg, do its thing(s) on its own and quit
-The Carbox macro end it self when it is finished
-If you want to start the “startup macro” again, make a easy button for it an the process can start from the beginning again.
Success,
Regards
Bert

cristoayre

6-Feb-2015 19:20

No, it was the way I was doing it 'cos I knew IE had a built in VB engine, so I was typing the filename into the browser window to run it locally. I'll take a look at "Help" re starup macro.

I've just spent the afternoon writing a script, and I found that with CMD, I can CD to the folder, and enter the filename. So I thought it might also be possible to write a .bat file to initiate cardbox.exe and then the vb script. (That made me wonder if I could type "exit" into macro to end the script/CMD) But will check out start macro first.

(My complex new script - which I'm quite proud of - takes the image from "hot folder", puts a copy in Archive, resizes it down to fit an 5" x 7" portrait frame on A4 sheet and puts it in "Print" folder, puts another copy in "Thumbs" folder and reduces to 640px x360px and writes the filename to a text file before removing photo from "hot" folder. Was looking at PNG convert to 256 colours for thumbs ... but converting thumbs ended up than JPG, so I'll leave that aspect out) So I'm getting there!

bert

6-Feb-2015 20:59

I cannot exactly understand why you use Cardbox for these things.
Converting/resizing images etc: use free Irfanview. Proofed and excellent quality. Install it en then read - stuff for you!!! - the help about command lines.
You can do a lot of things using the command line without opening the graphic interface.
Such a command line you can add into a bat/cmd/vbs file as well as a Cardbox macro.
It is not really clear to me why Cardbox would be the right solution for the things you mention. It's not a image editor, no file manager, it's a database.
Success,
Bert

Quick Reply

Please log in or register before trying to post a reply.

 
© 2010 Cardbox Software Limited   Home