VBS2VB6 Conv ScriptListener from VB script to VB 6 Classic

Upload Area - Upload Files Here, link to them from the appropriate Forum

Moderators: Tom, Kukurykus

DonJuane

VBS2VB6 Conv ScriptListener from VB script to VB 6 Classic

Post by DonJuane »

VBS2VB6

Visual Basic Script to VB6 Library
Code Conversion Utility

Quickly convert output from the Photoshop Script Listener tool into code that is both easier to read and can be easily imported directly into Visual Basic 6 projects, those that interact with Adobe Photoshop CS and higher.

This program is primarily a programmer’s tool. If you are a coder of Classic Visual Basic (VB6), you know how time consuming it is to record scripts with the Photoshop Script Listener and then hand-code them to operate in VB6. This eliminates a lot of the work required to do that. It also re-structures the code to be much more readable, well, as readable as possible from the very cryptic output of the Listener facility. There is no miracle with this code, the Photoshop Class calls are still very cryptic but still there is something gained with a slight improvement of clarity of the purpose of each function illustrated in the Listener file.

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

DonJuane

VBS2VB6 Conv ScriptListener from VB script to VB 6 Classic

Post by DonJuane »

Examples:

Subroutine from input file ScriptListenerVB.log file:

Code: Select allREM =======================================================
DIM objApp
SET objApp = CreateObject("Photoshop.Application")
REM Use dialog mode 3 for show no dialogs
DIM dialogMode
dialogMode = 3
DIM id683
id683 = objApp.CharIDToTypeID( "Mk  " )
    DIM desc59
    SET desc59 = CreateObject( "Photoshop.ActionDescriptor" )
    DIM id684
    id684 = objApp.CharIDToTypeID( "Nw  " )
        DIM desc60
        SET desc60 = CreateObject( "Photoshop.ActionDescriptor" )
        DIM id685
        id685 = objApp.CharIDToTypeID( "Md  " )
        DIM id686
        id686 = objApp.CharIDToTypeID( "RGBM" )
        Call desc60.PutClass( id685, id686 )
        DIM id687
        id687 = objApp.CharIDToTypeID( "Wdth" )
        DIM id688
        id688 = objApp.CharIDToTypeID( "#Rlt" )
        Call desc60.PutUnitDouble( id687, id688, 300.000000 )
        DIM id689
        id689 = objApp.CharIDToTypeID( "Hght" )
        DIM id690
        id690 = objApp.CharIDToTypeID( "#Rlt" )
        Call desc60.PutUnitDouble( id689, id690, 3000.000000 )
        DIM id691
        id691 = objApp.CharIDToTypeID( "Rslt" )
        DIM id692
        id692 = objApp.CharIDToTypeID( "#Rsl" )
        Call desc60.PutUnitDouble( id691, id692, 72.000000 )
        DIM id693
        id693 = objApp.StringIDToTypeID( "pixelScaleFactor" )
        Call desc60.PutDouble( id693, 1.000000 )
        DIM id694
        id694 = objApp.CharIDToTypeID( "Fl  " )
        DIM id695
        id695 = objApp.CharIDToTypeID( "Fl  " )
        DIM id696
        id696 = objApp.CharIDToTypeID( "Trns" )
        Call desc60.PutEnumerated( id694, id695, id696 )
        DIM id697
        id697 = objApp.CharIDToTypeID( "Dpth" )
        Call desc60.PutInteger( id697, 8 )
        DIM id698
        id698 = objApp.StringIDToTypeID( "profile" )
        Call desc60.PutString( id698, "sRGB IEC61966-2.1" )
    DIM id699
    id699 = objApp.CharIDToTypeID( "Dcmn" )
    Call desc59.PutObject( id684, id699, desc60 )
Call objApp.ExecuteAction( id683, desc59, dialogMode )


This is the ScritpListenerVB code after it has been run through this
program:

Output file, i.e. ScriptingVB6.log:

Code: Select allOption Explicit
Const p__profile                  = 267
Const p__pixelScaleFactor         = 412

Dim appRef As Photoshop.Application
Dim dialogMode as long

"'''''''''''''' Move these to your first called routine, i.e. FormLoad()

dialogMode = 3

Set appRef = New Photoshop.Application


REM ====== [ optionaly name this subroutine ] ====
 
DIM desc59 AS Photoshop.ActionDescriptor
DIM desc60 AS Photoshop.ActionDescriptor
Set desc59 = New Photoshop.ActionDescriptor
Set desc60 = New Photoshop.ActionDescriptor
 
Call desc60.PutClass( phClassMode, phClassRGBColorMode)
Call desc60.PutUnitDouble( phKeyWidth, phUnitDistance, 300.000000)
Call desc60.PutUnitDouble( phKeyHeight, phUnitDistance, 3000.000000)
Call desc60.PutUnitDouble( phKeyResolution, phUnitDensity, 72.000000)
Call desc60.PutDouble( p__pixelScaleFactor, 1.000000)
Call desc60.PutEnumerated( phEventFill, phEventFill, phEnumTransparent)
Call desc60.PutInteger( phKeyDepth, 8)
Call desc60.PutString( p__profile, "sRGB IEC61966-2.1")
Call desc59.PutObject( phKeyNew, phClassDocument, desc60)
Call appRef.ExecuteAction( phEventMake, desc59, dialogMode)

Mike Hale

VBS2VB6 Conv ScriptListener from VB script to VB 6 Classic

Post by Mike Hale »

I have seen several versions for javascript, it's nice to see one for vb.

StringIDs change from session to session. "pixelScaleFactor" for example will not always be 412.
DonJuane

VBS2VB6 Conv ScriptListener from VB script to VB 6 Classic

Post by DonJuane »

In response:
- thanks!
- it's always "something"
- looks like I have more work to do
DonJuane

VBS2VB6 Conv ScriptListener from VB script to VB 6 Classic

Post by DonJuane »

Mike Hale wrote:I have seen several versions for javascript, it's nice to see one for vb.

StringIDs change from session to session. "pixelScaleFactor" for example will not always be 412.

I wonder what is the condition that makes these change? I have rebooted 3 times and run it and they always come out to be the same number. Maybe from installation to installation????
Mike Hale

VBS2VB6 Conv ScriptListener from VB script to VB 6 Classic

Post by Mike Hale »

I am not sure why the value changes. It may be the order in which the stringID are encountered so that if you restart Photoshop and run your script the values will stay the same but if you did some other work that uses stringIDs before hand the values would be different.

But I am sure that they can, and do, change.
DonJuane

VBS2VB6 Conv ScriptListener from VB script to VB 6 Classic

Post by DonJuane »

OK, I am going to remove this until I can rewrite the tool to handle this condition. Thank you.
DonJuane

VBS2VB6 Conv ScriptListener from VB script to VB 6 Classic

Post by DonJuane »

I have removed the requirements for Photoshop needed to run this converter, therefore I was able to compile the code to run without any need for the Visual Basic 6 development environment.

The bad news is once compiled and bundled with all the installation files, it is now 3.14 MB and will therefore not load here on this 250K max upload facility.

I have listed it with Brothersoft but it will take up to 15 days to review and index.

Here is a copy if you wish to download and get started. I made changes to where the StringID to CharID calculations are now done dynamically, which adds some trash to the code but I still think it is easier to read and modify. (Your opinion may differ )

I tested the code by recording a procedure to watermark a photo, then converted it to a new data stream with VBS2VB6. I took the output with no modification and added it directly to a new VB6 project, added the Photoshop Object and Type Library references, and finally constructed a form with 1 push-button on it. The imported code ran perfectly.

Download it:
http://www.brothersoft.com/vbs2vb6-294181.html
xbytor

VBS2VB6 Conv ScriptListener from VB script to VB 6 Classic

Post by xbytor »

Mike Hale wrote:It may be the order in which the stringID are encountered so that if you restart Photoshop and run your script the values will stay the same but if you did some other work that uses stringIDs before hand the values would be different.

This is correct. String ids are dynamically allocated so will differ from session to session depend on your actions.

However, stringIDToTypeID('null') == charIDToTypeID('null'). 'null' is magic

-X
DonJuane

VBS2VB6 Conv ScriptListener from VB script to VB 6 Classic

Post by DonJuane »

I accidentally left a control file out of the package. The package has been updated to v 1.02 with this fix added.

http://www.brothersoft.com/vbs2vb6-294181.html