Powerbuilder WebCam - webcam
I am using EZTWAIN from a powerbuilder application to acquire images from an HP scanner. Recently I tried a Kodak model (i1120) and it seems that it is not supported. Specifically the application freezes during the scanning process (perhaps the problem has to do with duplex scanning).
Can you recommend another library that you have used and works ok for you, and provides an easy-to-use wrapper for the TWAIN API that can be used from Powerbuilder?
Check out this company: http://www.data-tech.com/ we use their ImageMan ActiveX suite with PB 10.5 and it works without a problem.
I had a similar problem with duplex scanning with several libraries. The solution is to use the scanner's interface directly when using duplex scanning instead of the ActiveX component. Most of the libraries have an option that can be enabled on the fly to use the scanner interface.
I currently use the Viscomsoft Scanner Pro ActiveX library.
**object : n_webcam**
================================================================================
forward
global type nvo_webcam from nonvisualobject
end type
end forward
global type nvo_webcam from nonvisualobject autoinstantiate
end type
prototype type
function ulong capCreateCaptureWindowA ( string lpszWindowName, ulong dwStyle, long li_x, long li_y, long nWidth, long nHeight, ulong ParentWin, long nId) LIBRARY 'AVICAP32.DLL' alias for "capCreateCaptureWindowA; ansi"
Function ulong GetDC ( ulong hWnd) Library "user32.dll"
Function long ReleaseDC ( ulong hWnd, ulong hdcr) Library "USER32.DLL"
Function ulong CreateCompatibleDC ( ulong hdc) Library "gdi32.dll"
Function ulong CreateCompatibleBitmap ( ulong hdc, ulong nWidth, ulong nHeight) Library "gdi32.dll"
Function boolean DeleteDC ( ulong hDC) Library "Gdi32.dll"
Function boolean BitBlt ( ulong hdcDest, long nXDest, long nYDest, long nWidth, long nHeight, ulong hdcSrc, long nXSrc, long nYSrc, long dwRop) Library "gdi32.dll"
Function boolean StretchBlt ( ulong hdcDest, long nXOriginDest, long nYOriginDest, long nWidthDest, long nHeightDest, ulong hdcSrc, long nXOriginSrc, longnYOriginSrc, long nWidthSrc, long nHeightSrc, long dwRop) Library "gdi32.dll"
Function ulong SelectObject ( ulong hdc, ulong HGDIOBJ) Library "gdi32.dll"
Function along GetDIBits ( ulong hdc, ulong hbmp, uint uStartScan, uint cScanLines, Ref blob lpvBits, Ref BITMAPINFO lpbi, uint uUsage) Library "gdi32.dll" alias for "GetDIBits"
Function long GetDIBits ( ulong hdc, ulong hbmp, uint uStartScan , uint cScanLines, ulong lpvBits, ref bitmapinfo lpbi, uint uUsage) Library "gdi32.dll" alias for "GetDIBits"
Subroutine CopyBitmapFileHeader ( Blob Ref Destination, bitmapfileheader Source, long Length) Library "kernel32.dll" Alias For "RtlMoveMemory" Subroutine CopyBitmapInfo ( Blob Ref Destination, Source bitmapinfo, long Length) Library "kernel32.dll" Alias For "RtlMoveMemory"
Function boolean OpenClipboard ( ulong hWndNewOwner) Library "user32.dll"
Function boolean CloseClipboard () Library "user32.dll"
Function boolean EmptyClipboard () Library "user32.dll"
Function ulong GetClipboardData ( ulong uFormat) Library "user32.dll"
end prototypes
such variables
Uint LHand
Constant long GET_FRAME = 1084
Constant long COPY = 1054
Constant long WM_USER = 1024
Constant long WM_CAP_START = WM_USER
Constant long WM_CAP_STOP = WM_CAP_START + 68
Constant long WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10
Constant long WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11
Constant long WM_CAP_SAVEDIB = WM_CAP_START + 25
Constant Long WM_CAP_GRAB_FRAME = WM_CAP_START + 60
Constant LongWM_CAP_SEQUENCE = WM_CAP_START + 62
Constant long WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20
Constant long WM_CAP_FILE_SAVEAS = WM_CAP_START + 23
Constant long WM_CAP_SEQUENCE_NOFILE = WM_CAP_START + 63
Constant long WM_CAP_SET_OVERLAY = WM_CAP_START + 51
Constant long WM_CAP_SET_PREVIEW = WM_CAP_START + 50
Constant long WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START +6
Constant long WM_CAP_SET_CALLBACK_ERROR = WM_CAP_START + 2
Constant Long WM_CAP_SET_CALLBACK_STATUSA = WM_CAP_START +3
Long Constant WM_CAP_SET_CALLBACK_FRAME = WM_CAP_START +5
Long Constant WM_CAP_SET_SCALE = WM_CAP_START + 53
Long Constant WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52
end variables
forward prototypes
public subroutine of_close ()
public subroutine of_initialize_webcam ( unsignedlong a_handle, string a_title, integer a_width, integer a_height)
public function blob of_copy_clipboard_to_blob ()
public subroutine of_capture_pic ()
end prototypes
public subroutine of_close (); send (lhand, WM_CAP_DRIVER_DISCONNECT, 0, 0)
end subroutine
public subroutine of_initialize_webcam ( unsigned long a_handle, string a_title, integer a_width, integer a_height); string lpszName
lpszName = a_title
if lhand = 0 then
lhand = capCreateCaptureWindowA (lpszName, 262144 + 12582912 + 1073741824 + 268435456, 1.40, a_width, a_height, a_handle, 0)
end if
if lhand <> 0 then
send (lhand, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0)
send (lhand, WM_CAP_SET_CALLBACK_ERROR, 0, 0)
send (lhand, WM_CAP_SET_CALLBACK_STATUSA, 0, 0)
send (lhand, WM_CAP_DRIVER_CONNECT, 0, 0)
send (lhand, WM_CAP_SET_SCALE, 1, 0)
send (lhand, WM_CAP_SET_PREVIEWRATE, 66, 0)
send (lhand, WM_CAP_SET_OVERLAY, 1, 0)
send (lhand, WM_CAP_SET_PREVIEW, 1, 0)
end if
end subroutine
public function blob of_copy_clipboard_to_blob (); BitmapInfo lstr_Info
BitmapFileHeader lstr_Header
Blob lblb_header, lblb_info, lblb_bitmap, lbl_final
ULong lul_hdc, lul_hdcMem, lul_hBitmap, lul_hWnd, lul_blpos
UInt DIB_RGB_COLORS
Integer li_pixels
Boolean lb_result
long al_width, ll_height, ll_ret
constant integer BITMAPTYPE = 19778 // 4D42 = BM
constant integer CF_BITMAP = 2
constant integer CF_DIB = 8
lul_hWnd = Handle ( this )
lb_result = OpenClipboard (lul_hWnd)
// Get the device context and allocate memory
lul_hdc = GetDC (lul_hWnd)
lul_hdcMem = CreateCompatibleDC (lul_hdc)
lul_hBitmap = getclipboarddata (CF_BITMAP)
// try to store the bitmap into a blob so we can save it
lstr_Info.bmiHeader.biSize = 40
ll_height = 480 // ... 480 should be enough for everyone? ;)
DIB_RGB_COLORS = 0
// Get the bitmapinfo
If GetDIBits (lul_hdcMem, lul_hBitmap, 0, ll_height, 0, lstr_Info, DIB_RGB_COLORS)> 0 Then
li_pixels = lstr_Info.bmiHeader.biBitCount
lstr_Info.bmiColors [li_pixels] = 0
lblb_bitmap = Blob (Space (lstr_Info.bmiHeader.biSizeImage), EncodingANSI!)
ll_height = lstr_Info.bmiHeader.biheight
// get the actual bits
ll_ret = GetDIBits (lul_hdcMem, lul_hBitmap, 0, ll_height, lblb_bitmap, lstr_Info, DIB_RGB_COLORS)
// ls_msg = hexdump_blob (lblb_bitmap, false)
// create a bitmap header
lstr_Header.bfType = BITMAPTYPE
lstr_Header.bfSize = lstr_Info.bmiHeader.biSizeImage
lstr_Header.bfOffBits = 54 + (li_pixels * 4)
// copy the header structure to a blob
lblb_header = Blob (Space (7)) //
14/2 CopyBitmapFileHeader (lblb_header, lstr_Header, 14)
// copy the info structure to a blob
lblb_Info = Blob (Space (40 + li_pixels * 4) / 2))
CopyBitmapInfo (lblb_Info, lstr_Info, len (lblb_Info))
// add all together and we have a window bitmap in a blob
lbl_final = lblb_header + lblb_info + lblb_bitmap
End If
CloseClipboard ()
ReleaseDC (lul_hwnd, lul_hdc)
DeleteDC (lul_hdcMem)
return lbl_final
end function
public subroutine of_capture_pic (); Send (lhand, GET_FRAME, 0, 0)
Send (lhand, COPY, 0, 0)
end subroutine
we have nvo_webcam. create
call super :: create
TriggerEvent ( this , "constructor" )
end on
we have nvo_webcam. destroy
TriggerEvent ( this , "destructor" )
call super :: destroy
end on
**instantiate the object and initialize it:**
================================================================================
n_webcam.of_initialize_webcam (handle ( this ), "Webcam" , il_width, il_height)
**capture:**
================================================================================
n_webcam.of_capture_pic ()
**image processing:**
================================================================================
lb_blob = n_webcam..of_copy_clipboard_to_blob ()
// reinitialize for the webcam to continue live
i_nvo_webcam.of_initialize_webcam (handle ( this ), "Webcam" , il_width, il_height)
**Close:**
================================================================================
n_webcam.of_close ()
Watch Video https://youtu.be/ojcJs1ajWRc
Related
64 bit unsigned integer division in VBA
I have a function that returns unsigned 64 bit integers, which VBA does not support. I have seen workarounds using Currency but I want to do it using Type instead. This is what I came up with: Public Type LARGE_INTEGER LoPart As Long HiPart As Long End Type Private Const SCALE_UP As Double = 2^32 - 1 Public Function IntegerDivide(ByRef numerator As LARGE_INTEGER, ByRef denominator As LARGE_INTEGER) As Double IntegerDivide = Normalify(numerator) / Normalify(denominator) End Function Public Function Largify(ByVal normal As Double) As LARGE_INTEGER Largify.HiPart = normal / SCALE_UP Largify.LoPart = normal - Largify.HiPart * SCALE_UP End Function Public Function Normalify(ByRef large As LARGE_INTEGER) As Double Normalify = large.HiPart * SCALE_UP + large.LoPart End Function I have a feeling it could be buggy because of off-by-one errors or two's complement. But I don't know this stuff well enough. Is this correct? e.g. here's an example function that returns a 64 bit unsigned integer Private Declare Function QueryPerformanceCounter Lib "KERNEL32" (ByRef outTickCount As LARGE_INTEGER) As Long 'BOOL
You have the Decimal type readily available that can perform operations on integers up to 12 bytes. You can't declare variables as "Decimal" but you can declare them as "Variant" and use the "Cdec" function to convert them to decimal and then all integer operations will work correctly on these BIG integers.
how to pass struct from vb to dll?
I'm trying to pass a struct from vb to dll im facinf isues on that. //Datalink layer.cpp #include"DataLinkLayer.h" #include<stdio.h> #include <windows.h> int __stdcall DataLink_TellTale_Encode (struct telltalelib *st_telltale, LPSTR * rtnFramePassedPtr) { sprintf(*rtnFramePassedPtr,"<%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d>",NORMAL,STREAM,VEHICLEOVERALL,NA,PERCENTAGE,TELLTALEID,COMPIDNA,TELLTALELENGTH,st_telltale.Telltaleid,st_telltale.color,st_telltale.glowLevel,st_telltale.onOff); return 0; } //Datalink Layer.h #define MAXFRAMELEN 20 #define MAXPOSSOPTFIELDS 50 #define RESERVED 0 #define COMPIDNA 0 #define NA 1 #define SPEEDLENGTH 1 #define RPMLENGTH 1 #define FUELLENGTH 1 #define TELLTALELENGTH 3 struct telltalelib { int Telltaleid; int color; int glowLevel; int onOff; }; int __stdcall DataLink_TellTale_Encode (struct telltalelib *st_telltale, char* rtnFramePassedPtr); enum priority{ LOW=1 , NORMAL, HIGH, CRITICAL,FATAL }; enum frameType{ REQUEST=1, RESPONSE, ERROR, STREAM, NOTIFICATION, STATEINFORMATIONCHANGE, PERIODIC }; enum domain{MODULEPOWER=1,MODULESTATEMACHINE,VEHICLEOVERALL,ENGINE,TRANSMISSION,BRAKE,SAFETYSYSTEMS,LOCK,DRIVER,AC,DOOR,TPMS,LIGHTS,WINDOW, ANTENNA,SEATS,VEHICLEATTITUDE,WIPER,ORVM,DISPLAY,VEHICLECONSTANTS,TELEPHONY,INFOTAINMENT,FOTA }; enum Parameter{ SPEED=2 ,RPM ,FUEL, ODO ,TEMPERATURE, PRESSURE, HUMIDITY,BATTERYLEVEL, ONOFF , GLOWLEVEL, COLOR, OPENPOSITION, RAMPSTYLE, CMDSHUTDOWN, CMDREBOOT, NOTIFICATIONTEXT, CURRENT, DRIVEMODE, GEARLEVEL, MASS, VOLUME, DATAPACKET ,SLIDELEVEL ,RECLINELEVEL, DRIVERID, DRIVINGSCORE, MINLEVELSETTING, MAXLEVELSETTING, TIME, ROLL, PITCH, YAW,MODE}; enum Unit{ RAW=2, SECONDS, CM ,M ,KM, MILE, KMPERHOUR, MILESPERHOUR, X100RPM, X1000RPM, PERCENTAGE, RGB, PSI, BAR, KPA, DEGCELCIUS, DEGFARANHEIT ,FULLYOPENORFULYLCLOSED, ENUMERATEDCODES ,ENUMERATEDFIELDID, V ,MA, A, DEGREE , KG ,CM3, CC, PLAINTEXT ,DB ,EPOCHTIME ,OKNOTOK }; enum Component{TYREID=2 ,ACVENTID,DOORID, WINDOWID, LIGHTID, ANTENNAID, TELLTALEID, ACTUATORID,GENERICDATAFIELDID ,DATAFORMATID, WIPERID } ; VB Code: Private Type struct_telltalelib Telltaleid As Integer color As Integer glowLevel As Integer onOff As Integer End Type Private Declare Function DataLink_TellTale_Encode Lib "C:\MinGW\bin\DataLinkLayer.dll" (ByRef st_telltale As struct_telltalelib, ByRef rtnFramePassedPtr As String) As Integer Dim vb_telltale As struct_telltalelib Dim str_data As String * 20 Dim s2 As String Dim stringToBeTrasmitted As String Private Sub Check1_Click() vb_telltale.Telltaleid = 8 vb_telltale.color = -1 vb_telltale.glowLevel = -2 vb_telltale.onOff = 1 dummy = DataLink_TellTale_Encode(str(vb_telltale), str_data) stringToBeTrasmitted = Trim(Mid(Replace(str_data, Chr(0), " "), 1, InStr(str_data, Chr(0)))) Timer1.Enabled = True End Sub Private Sub Form_Load() UART1.PortOpen = True End Sub Private Sub Timer1_Timer() Timer1.Enabled = False UART1.Output = stringToBeTrasmitted End Sub I'm getting error message like only user defined in public object modules can be corrected to or from varient or passed to late -bound functions.
I see the following problems: The struct should be passed as vb_telltale rather than str(vb_telltale). The string should be declared as ByVal. The string buffer is likely too small and will be overrun.
The error is telling you the VB Type variable must be declared as Public in a BAS module. Also, in C an int is equivalent to a VB6 Long, not an Integer, so you'll likely have size and alignment mismatches. There may be other issues but those stand out.
Allocating physical memory for Unsigned Integer in Visual Basic .NET?
For example, For integer, we allocate some memory and get its address: Dim MyPointer As IntPtr = Marshal.AllocHGlobal(4) Marshal.WriteInt32(MyPointer, 255) For String, Dim MyStrPointer As IntPtr = Marshal.StringToHGlobalAuto("Hello World") Similary, I want to allocate memory for an Unsigned Integer (UInt32)
Unsigned integers like other .Net numeric types are structures and as such can be marshaled using Marshal.StructureToPtr and Marshal.PtrToStructure. Dim origUI32 As UInt32 = UInt32.MaxValue Dim MyPointer As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(origUI32)) Marshal.StructureToPtr(origUI32, MyPointer, True) Dim retrievedUI32 As UInt32 = DirectCast(Marshal.PtrToStructure(MyPointer, GetType(UInt32)), UInt32) Marshal.FreeHGlobal(MyPointer) Debug.Assert(retrievedUI32 = origUI32)
Calling Native C from VBA
I am unable to create a minimal working example of a native dll in combination with VBA There are three Problems: I can not resolve error 453 (can't find dll entry point) I do not know how to marshall variac VBA (ExCel) Option Explicit Public Declare Sub KERNEL32_SLEEP _ Lib "kernel32" _ Alias "Sleep" (ByVal dwMilliseconds As Long) Public Declare Sub CALLADAPTER_SIMPLE _ Lib "D:\Stackoverflow\Release\CallAdapter.dll" _ Alias "simple" () Public Declare Function CALLADAPTER_ADD _ Lib "D:\Stackoverflow\Release\CallAdapter.dll" _ Alias "add" (ByVal A As Integer, ByVal B As Integer) As Integer Public Declare Sub CALLADAPTER_PRINT _ Lib "D:\Stackoverflow\Release\CallAdapter.dll" _ Alias "print" (ByVal FormatSpecifier As String) Sub TEST_KERNEL32_SLEEP() Call KERNEL32_SLEEP(2000) 'works End Sub Sub TEST_CALLADAPTER_SIMPLE() Call CALLADAPTER_SIMPLE 'error 453 can't find dll entry point End Sub Sub TEST_CALLADAPTER_ADD() Dim A, B, C As Integer A = 30 B = 12 C = CALLADAPTER_ADD(A, B) 'error 453 can't find dll entry point MsgBox "A + B = " & C End Sub Sub TEST_CALLADAPTER_PRINT() Call CALLADAPTER_PRINT("Hello World") 'error 453 can't find dll entry point End Sub Sub TEST_CALLADAPTER_PRINTF() 'I do not know how to marshall variadic End Sub Ansi C ( Visual Studio 2010 ) // Header #ifdef CALLADAPTER_EXPORTS #define CALLADAPTER_API __declspec(dllexport) #else #define CALLADAPTER_API __declspec(dllimport) #endif CALLADAPTER_API void _stdcall simple( void ); CALLADAPTER_API int _stdcall add( int a, int b ); CALLADAPTER_API void _stdcall print( const char * msg ); CALLADAPTER_API int _stdcall printf( const char * format, ... ); // code #include "CallAdapter.h" #include <stdio.h> #include <stdarg.h> CALLADAPTER_API void _stdcall simple( void ) { printf("simple was called\n"); } CALLADAPTER_API int _stdcall add( int a, int b ) { return a + b; } CALLADAPTER_API void _stdcall print( const char * msg ) { printf( "%s", msg ); } CALLADAPTER_API int _stdcall printf( const char * format, ... ) { int ret; va_list args; va_start( args, format ); ret = vprintf( format, args ); va_end( args ); return ret; } Edit #1: I completely reworked the examples to better illustrate my problems. Edit #2: Progress with variadic. There is a very useful site on the web. I made some progress but i stll can not compule the call... VBA Option Explicit Public Declare Function CallAdapter_sprintf _ Lib "D:\Stackoverflow\Release\CallAdapter.dll" _ Alias "sprintf" (ByRef DST As String, ByRef FORMAT As String, ParamArray args()) As Integer Sub TEST_CALLADAPTER_sprintf() Dim DESTINATION, FORMAT As String Dim OTHER() As Variant Dim C As Integer FORMAT = "%s" OTHER = Array("Hello World") DESTINATION = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" C = CallAdapter_sprintf(DESTINATION, FORMAT, OTHER) MsgBox "RET " & C & " -> " & DESTINATION End Sub Ansi C CALLADAPTER_API int _stdcall sprintf( char * dest, const char * format, ... ) { int ret; va_list args; va_start( args, format ); ret = vsprintf( dest, format, args ); va_end( args ); return ret; }
varocarbas gave a good hint. I used Dependency Walker to get the correct names. This solves half of my problem, i still dont know how to marshall variadic Public Declare Sub CALLADAPTER_SIMPLE _ Lib "D:\Stackoverflow\Release\CallAdapter.dll" _ Alias "_simple#0" () Public Declare Function CALLADAPTER_ADD _ Lib "D:\Stackoverflow\Release\CallAdapter.dll" _ Alias "_add#8" (ByVal A As Integer, ByVal B As Integer) As Integer Public Declare Sub CALLADAPTER_PRINT _ Lib "D:\Stackoverflow\Release\CallAdapter.dll" _ Alias "_print#4" (ByVal FormatSpecifier As String) Only the ADD example is a good example since stdout does not seem to exist.
Checking the return code from an application executed
I want to be able to check the return code from an application that is executed. I tried implement it by the PowerBuilder function Run, but its not return the code of application which executed. Thanks.
In fact, Run() launches the target synchronously, so by the time the next line of PowerScript runs, your Run() app may not be finished, let alone have a return code available. You need to make the Windows API calls with appropriate parameters yourself to achieve this, instead of relying on the PowerScript wrapper, which only gives you the synchronous option. The following is what I have to launch a DOS command and get the return value. You may or may not need to tweak the parameters to the API calls as appropriate. The API calls are assuming a Unicode version of PowerBuilder, i.e. 10.0 or later. External Function Prototypes FUNCTION boolean CreateProcess(string AppName, string CommLine, long l1, long l2, boolean binh, long creationflags, long l3, string dir, str_startupinfo startupinfo, ref str_processinformation pi ) library 'kernel32.dll' alias for "CreateProcessW" FUNCTION long WaitForSingleObject ( ulong ul_Notification, long lmillisecs ) library "kernel32.dll" FUNCTION long GetExitCodeProcess(ulong hProcess,ref ulong lpExitCode) LIBRARY "kernel32.dll" FUNCTION boolean CloseHandle(ulong h) library 'kernel32.dll' ObjectStructure str_startupinfo ulong cb string lpreserved string lpdesktop string lptitle ulong dwx ulong dwy ulong dwxsize ulong dwysize ulong dwxcountchars ulong dwycountchars ulong dwfillattribute ulong dwflags uint wshowwindow uint cbreserved2 string lpreserved2 uint hstdinput uint hstdoutput uint hstderror ObjectStructure str_processinformation unsignedlong hprocess unsignedlong hthread long dwprocessid long dwthreadid function of_runandwait (string as_command, boolean ab_Visible) returns ulong constant long STARTF_USESHOWWINDOW = 1 constant long CREATE_NEW_CONSOLE = 16 constant long NORMAL_PRIORITY_CLASS = 32 constant long INFINITE = -1 boolean lb_Return long ll_Null, ll_CreationFlags, ll_Return ulong lul_ProcessReturn string ls_CurDir, ls_Null str_StartupInfo lstr_Start str_Processinformation lstr_PI SetNull(ll_Null) SetNull(ls_Null) SetNull(ls_CurDir) lstr_Start.cb = 72 lstr_Start.dwFlags = STARTF_USESHOWWINDOW IF ab_Visible THEN lstr_Start.wShowWindow = 1 ELSE lstr_Start.wShowWindow = 0 END IF ll_CreationFlags = CREATE_NEW_CONSOLE + NORMAL_PRIORITY_CLASS lb_Return = CreateProcess (ls_Null, as_Command, ll_Null, ll_Null, FALSE, ll_CreationFlags, ll_Null, ls_CurDir, lstr_Start, lstr_PI) ll_Return = WaitForSingleObject (lstr_PI.hProcess, INFINITE) ll_Return = GetExitCodeProcess (lstr_PI.hProcess, lul_ProcessReturn) CloseHandle(lstr_PI.hProcess) CloseHandle(lstr_PI.hThread) RETURN lul_ProcessReturn Good luck, Terry.
OleObject wsh integer li_rc CONSTANT integer MAXIMIZED = 3 CONSTANT integer MINIMIZED = 2 CONSTANT integer NORMAL = 1 CONSTANT boolean WAIT = TRUE CONSTANT boolean NOWAIT = FALSE wsh = CREATE OleObject li_rc = wsh.ConnectToNewObject( "WScript.Shell" ) li_rc = wsh.Run("Notepad" , NORMAL, WAIT) messagebox("hello", "world") The third parameter WAIT runs the executable and waits for the completion and li_rc will receive the exit code.