Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: ScriptIt INI Files
Is there anything that can be done?
If you download and install WinBatch and use the following script, you can automagically convert your ScriptIt ini files to real WinBatch programs. Then various problems can be studied in detail and fixed.
;*************************************************************************** ;** Winbatch script to convert SCRIPTIT INI files to Winbatch WBT files ;** ;** Syntax: (from Start Run line): ;** ;** For Compiled script: WinBatchIt.EXE "C:\PATH TO\YourIniFile.INI" ;** ;*************************************************************************** wintitle("","WinBatchIt") if IsKeyDown(@SHIFT) then exit intcontrol(12,5,0,0,0) intcontrol(43,1,0,0,0) intcontrol(49,3,0,0,0) mkfilelist="" comspec=environment("COMSPEC") if isdefined(param1)==@FALSE then param1="/?" if isdefined(param2)==@FALSE then param2="" param1=strupper(param1) param2=strupper(param2) cr="%@CRLF%" cr2="%@CRLF%%@CRLF%" line='%cr%____________________________________________________________________________________' firstline=`Run WinBatchIt.EXE from the Start Run Command Line.%cr2%` secondline=`If WinBatchIt.EXE is not on your path, you will need to provide the full path to WinBatchIt.EXE.%cr%` thirdline=`The same reasoning applies to the path to the ScriptIt INI file on the command line.%cr2%` fourthline=`The syntax to run WinBatchIt.EXE is as follows:%cr2%` fifthline=`%cr2% WinBatchIt.exe ScriptItFile.INI%cr2%%cr%` msg=strcat(firstline, secondline, thirdline, fourthline, line, fifthline) if param1!="/?" then goto NEXT message("WinbatchIt Usage:",msg) exit :NEXT if fileexist(param1)==@FALSE then message("WinBatchIt Error","Can not find %param1%") then exit curdir=DirGet() root=FileRoot(param1) ;get file root of current SCRIPTIT file WBTfile=strcat(root,".WBT") BATfile=strcat(root, ".BAT") VBSfile=strcat(root, ".VBS") wbthandle=FileOpen(strcat(curdir, WBTfile), "WRITE") ;open new WBT file in current diretory FileWrite(wbthandle, "intcontrol(12,5,0,0,0)") slash=strindex(param1,"\",1,@FWDSCAN) if slash==0 then param1=strcat(".\","%param1%") tempdir=environment("TEMP") randnum=random(99999999) filecopy(param1,"%tempdir%\%randnum%",@FALSE) ;copy orig INI file to \Windows\Temp dir named random number param1="%tempdir%\%randnum%" ;new file name of the ini file adliblist=iniitemizepvt("ADLIB",param1) ;itemize adlib section adlibcount=itemcount(adliblist,@TAB) ;get num of items section="SCRIPT" gosub PROCESSSECTION FileDelete(param1) ;FINALLY, delete the temporary file from \WINDOWS\TEMP FileClose(wbthandle) ;CLOSE OUT THE NEW WBT FILE exit :PROCESSSECTION :SCRIPTSECTION windowlist=iniitemizepvt(section,param1) ;itemize the SCRIPT section windowcount=itemcount(windowlist,@TAB) ;get num of items in INI file SCRIPT section windowtitle="" windowtext="" keylist="" :WINDOWLOOP :ADLIBLOOP if windowcount==0 then gosub ADLIB then goto ADLIBLOOP for j=1 to windowcount gosub ADLIB :GOTOENTRYPOINT windowkey=itemextract(j,windowlist,@TAB) ;grab each line of SCRIPT section up to windowcount rem=itemextract(1,windowkey," ") ;grab first item separated by spaces? doesn't seem right??????? rem=strupper(rem) if rem=="REM" then goto NEXTWINDOW ;if there's a remark in INI file, carry on to next window keylist=inireadpvt(section,windowkey,"",param1) ;for ea line of SCRIPT section, get keys after "=" FileWrite(wbthandle, "%@crlf%;'%windowkey%=%keylist%'%@crlf%") keylist=strreplace(keylist,"%%%%","@@") ;replace old %%%% with new @@ (use two to end up with one) :ENVSUBLOOP oenvvar=itemextract(2,keylist,"%%") ;grab out environment variable in this loop, if there is one envvar=strupper(oenvvar) envvalue=environment(envvar) if envvalue!="" then keylist=strreplace(keylist,"%%%oenvvar%%%",envvalue) ;replace old entry with extra %% from INI file with the substituted envir variable index=strindex(keylist,"%%",1,@FWDSCAN) ;now see if the keylist contains any environ variables if index != 0 then goto ENVSUBLOOP ;if it does, go up to loop and process string keylist=strreplace(keylist,"@@","%%%%") ;now we turn the @ back into %% for processing with Execute function temp=strupper(windowkey) ;temporary uppercase each line of SCRIPT section index=strindex(temp,"SCRIPTIT",1,@FWDSCAN) ;look for "SCRIPTIT" if index==0 then wintitle("","WinBatchIt %windowkey%") ;this title if "SCRIPTIT" not in the INI file if index!=0 then wintitle("",windowkey) ;this title if "SCRIPTIT" is found in INI file boxtext("Processing Line: %windowkey%") temp=strupper(windowkey) ;this is redundant of above temp=strtrim(temp) ;remove leading and trailing spaces if temp=="RUN" then gosub PROCESSRUNLINES ;now we're reading to start processing the run statement then goto NEXTWINDOW temp=strupper(windowkey) ;this is redundant of above first7=strsub(temp,1,7) if first7=="MKFILE " then gosub PROCESSMKFILELINES ;MKFILE is their processor to write files to a file for later reading then goto NEXTWINDOW windowtitle=itemextract(1,windowkey,"+") ;grab out parent window windowtext=itemextract(2,windowkey,"+") ;grab out child text :CHECKAGAIN if windowtext=="" then goto DOWINDOWTITLE ;if no child window exists, then do parent processing only FileWrite(wbthandle, "windowtext='%windowtext%'") ;never end up using this at this point :DOWINDOWTITLE ;this is the parent window processing loop FileWrite(wbthandle, "windowtitle='%windowtitle%'") FileWrite(wbthandle, "count=0") FileWrite(wbthandle, "For i=1 to 3 ;go thru this loop a total of 3x, waiting for parent/child windows") FileWrite(wbthandle, "if !winexist('%windowtitle%')") FileWrite(wbthandle, " TimeDelay(1)") FileWrite(wbthandle, "else") FileWrite(wbthandle, " state=winstate('%windowtitle%')") FileWrite(wbthandle, " if state!=-1") ;if window is not hidden Filewrite(wbthandle, " a=winitemchild('%windowtitle%')") ;if windowtext exists, itemize window text FileWrite(wbthandle, " index=strindexnc(a,'%windowtext%',1,@FWDSCAN)") ;look for matching window text in current window FileWrite(wbthandle, " if index==0") ; then this is not the window we want to send keystrokes to FileWrite(wbthandle, " TimeDelay(1)") FileWrite(wbthandle, " else") FileWrite(wbthandle, " break") FileWrite(wbthandle, " endif") FileWrite(wbthandle, " else") FileWrite(wbthandle, " TimeDelay(1)") FileWrite(wbthandle, " endif") FileWrite(wbthandle, "endif") FileWrite(wbthandle, "count=count+1") FileWrite(wbthandle, "BoxOpen('Testing for child window text...', 'Test %i% of 3')") FileWrite(wbthandle, "next") FileWrite(wbthandle, "BoxShut()") gosub PROCESSKEYLIST :NEXTWINDOW gosub ADLIB inideletepvt("SCRIPT",windowkey,param1) ;delete the line we just processed out of **COPY OF** INI file next return :ADLIB if adliblist=="(NONE)" then return ;if nothing in the [ADLIB] section, then go back to CHECKAGAIN section SaveScriptWindowTitle=windowtitle SaveScriptWindowText=windowtext SaveKeyList=keylist for k=1 to adlibcount yield yield adlibwin=itemextract(k,adliblist,@TAB) FileWrite(wbthandle, "%@crlf%;'%adlibwin%=%keylist%'%@crlf%") rem=itemextract(1,adlibwin," ") rem=strupper(rem) if rem=="REM" then goto NEXTADLIBWINDOW windowtitle=itemextract(1,adlibwin,"+") windowtext=itemextract(2,adlibwin,"+") if windowtext=="" then goto DOADLIBWINDOWTITLE ;if no specified window text, then process parent as-is :CHECKFORADLIBWIN FileWrite(wbthandle, "count=0") FileWrite(wbthandle, "For i=1 to 3 ;go thru this loop a total of 3x, waiting for parent/child windows") FileWrite(wbthandle, "if !winexist('%windowtitle%')") ;then goto NEXTADLIBWINDOW FileWrite(wbthandle, " TimeDelay(1)") FileWrite(wbthandle, "else") FileWrite(wbthandle, " state=winstate('%windowtitle%')") FileWrite(wbthandle, " if state!=-1") ;if window is not hidden Filewrite(wbthandle, " a=winitemchild('%windowtitle%')") ;if windowtext exists, itemize window text FileWrite(wbthandle, " index=strindexnc(a,'%windowtext%',1,@FWDSCAN)") ;look for matching window text in current window FileWrite(wbthandle, " if index==0") ; then this is not the window we want to send keystrokes to FileWrite(wbthandle, " TimeDelay(1)") FileWrite(wbthandle, " else") FileWrite(wbthandle, " break") FileWrite(wbthandle, " endif") FileWrite(wbthandle, " else") FileWrite(wbthandle, " TimeDelay(1)") FileWrite(wbthandle, " endif") FileWrite(wbthandle, "endif") FileWrite(wbthandle, "count=count+1") FileWrite(wbthandle, "BoxOpen('Testing for ADLIB Window...', 'Test %i% of 3')") FileWrite(wbthandle, "next") FileWrite(wbthandle, "BoxShut()") FileWrite(wbthandle, "if count==3 then goto NEXTADLIBWINDOW ; if we loop thru 3X and window isn't there, go to next adlib window") :DOADLIBWINDOWTITLE FileWrite(wbthandle, "windowtitle='%windowtitle%'") FileWrite(wbthandle, "WinWaitExist(windowtitle,-1)") FileWrite(wbthandle, "windowtitle=WinIDGet(windowtitle)") if windowtext != "" FileWrite(wbthandle,"windowtext='%windowtext%'") endif keylist=inireadpvt("ADLIB",adlibwin,"",param1) keycount=itemcount(keylist,"#") if param2=="/DEBUG" then message("Found ADLIB",adlibwin) gosub PROCESSKEYLIST :NEXTADLIBWINDOW yield yield next windowtitle=SaveScriptWindowTitle windowtext=SaveScriptWindowText keylist=SaveKeyList return :PROCESSKEYLIST keycount=itemcount(keylist,"#") ;now count how many sendkey statements in sendkey part if keycount==0 then keycount=1 ;this means there's only one sendkey statement to process then keylist=strcat(keylist,"#") ;put "#" at end of sendkey list, to know it's the only one for l=1 to keycount FileWrite(wbthandle, "TimeDelay(1)") yield yield key=itemextract(l,keylist,"#") ;extract out each sendkey sequence temp=strupper(key) ;temporarily uppercase the sendkey string :DOEXIT if temp=="~EXIT" then exit ;now look for all the special SCRIPTIT parameters if temp=="~LOOP" then goto WINDOWLOOP ;not mentioned in docs if temp=="" then TimeDelay(5) ;if empty string, then go to next sendkey sequence then goto NEXTKEY if temp=="~WAIT" then TimeDelay(5) then goto NEXTKEY if temp!="~WINWAITCLOSE" then goto SKIPWINWAITCLOSE ;skip on down to specified label if parameter isn't found FileWrite(wbthandle, "winwaitclose(windowtitle)") goto NEXTKEY :SKIPWINWAITCLOSE if temp!="~WINCLOSE" then goto SKIPWINCLOSE ;keep going until you see winclose FileWrite(wbthandle, "winclose(windowtitle)") goto NEXTKEY :SKIPWINCLOSE if temp!="~WINWAITACTIVE" then goto SKIPWINWAITACTIVE ;skip on down to specified label if this isn't found :CHECKACTIVELOOP FileWrite(wbthandle, "activewin=wingetactive()") FileWrite(wbthandle, "activewin=winidget(activewin)") if activewin!=windowtitle then delay(1) then goto CHECKACTIVELOOP ;keep looping around until the active window is the one we want to send keys to goto NEXTKEY :SKIPWINWAITACTIVE if temp=="~WINHIDE" then FileWrite(wbthandle, "winhide(windowtitle)") ;handle more special SCRIPTIT parameters then goto NEXTKEY if temp=="~WINSHOW" then FileWrite(wbthandle, "winshow(windowtitle)") then goto NEXTKEY if temp=="~WINMIN" then FileWrite(wbthandle, "winiconize(windowtitle)") then goto NEXTKEY if temp=="~WINICON" then FileWrite(wbthandle, "winiconize(windowtitle)") then goto NEXTKEY if temp=="~WINMAX" then FileWrite(wbthandle, "winzoom(windowtitle)") then goto NEXTKEY if temp=="~WINZOOM" then FileWrite(wbthandle, "winzoom(windowtitle)") then goto NEXTKEY index=strindex(key,"@",1,@FWDSCAN) if index!=1 then goto SKIPWBCOMMANDS ;if the "@" isn't found, then no WB commands to handle wbcmd=itemextract(2,key,"@") FileWrite(wbthandle, "execute key=%wbcmd%") if (key==0) || (key==1) then goto NEXTKEY :SKIPWBCOMMANDS index=strindex(key,"`",1,@FWDSCAN) if index!=1 then goto SKIPRUNCOMMANDS ;if the "'" isn't there, then no DOS commands to handle command=itemextract(2,key,"`") ;otherwise, extract the DOS command and write it to a BAT file handle=fileopen("%tempdir%\~TMP~.BAT","WRITE") ;here's where we create and write the DOS BAT file filewrite(handle,`%command% >>%%TEMP%%\~TMP~`) fileclose(handle) if fileexist("%tempdir%\~TMP~.BAT") then filerename("%tempdir%\~TMP~.BAT", "%tempdir%\%BATfile%") FileWrite(wbthandle, "comspec=environment('COMSPEC')") FileWrite(wbthandle, "tempdir=environment('TEMP')") FileWrite(wbthandle, "runhidewait(comspec,'/c %tempdir%\%BATfile%')") if fileexist("%tempdir%\~TMP~")==@FALSE then key="" ;skip DOS run commands if this file doesn't exist then goto SKIPRUNCOMMANDS if filesize("%tempdir%\~TMP~")==0 then key="" then goto SKIPRUNCOMMANDS if fileexist("%tempdir%\~TMP~")==@TRUE then tmphandle=fileopen("%tempdir%\~TMP~","READ") key="" key=fileread(tmphandle) ;otherwise, if it exists, open and read it while key!="*EOF*" FileWrite(wbthandle, "if winexist(windowtitle)") FileWrite(wbthandle, " intcontrol(36,windowtitle,5,0,0)") FileWrite(wbthandle, " Sendkeysto(windowtitle,'%key%')") FileWrite(wbthandle, "endif") FileWrite(wbthandle, "if winexist(windowtitle)") FileWrite(wbthandle, " intcontrol(36,windowtitle,5,0,0)") FileWrite(wbthandle, " Sendkeysto(windowtitle,"~")") FileWrite(wbthandle, "endif") key=fileread(tmphandle) ;this is structured sort of strangely - i.e., two fileread(tmphandle) before close endwhile fileclose(tmphandle) if fileexist("%tempdir%\~TMP~") then filedelete("%tempdir%\~TMP~") goto NEXTKEY :SKIPRUNCOMMANDS index=strindex(key,"*",1,@FWDSCAN) ;if sendkey contains a "*", then this is ONLY documented as a multiplication char, but it's supposed to be able to do some shell stuff if index!=1 then goto SKIPWSHCOMMANDS wshcmd=itemextract(2,key,"*") handle=fileopen("%tempdir%\~WSH~.VBS","WRITE") filewrite(handle, `set wshshell=wscript.createobject("Wscript.Shell")`) filewrite(handle, `set wshnetwork=wscript.createobject("Wscript.Network")`) filewrite(handle, `key=%wshcmd%`) filewrite(handle, `wscript.echo key`) fileclose(handle) FileRename("%tempdir%\~WSH~.VBS", VBSFile) runhidewait(comspec, "/c cscript.exe //nologo %tempdir%\%VBSFile%>%tempdir%\~TMP~") if fileexist("%tempdir%\~TMP~")==@FALSE then key="" then goto SKIPWSHCOMMANDS if filesize("%tempdir%\~TMP~")==0 then key="" then goto SKIPWSHCOMMANDS if fileexist("%tempdir%\~TMP~")==@TRUE then tmphandle=fileopen("%tempdir%\~TMP~","READ") key="" key=fileread(tmphandle) while key!="*EOF*" FileWrite(wbthandle, "if winexist(windowtitle)") FileWrite(wbthandle, " intcontrol(36,windowtitle,5,0,0)") FileWrite(wbthandle, " Sendkeysto(windowtitle,'%key%')") FileWrite(wbthandle, "endif") FileWrite(wbthandle, "if winexist(windowtitle)") FileWrite(wbthandle, " intcontrol(36,windowtitle,5,0,0)") FileWrite(wbthandle, " Sendkeysto(windowtitle,'~')") FileWrite(wbthandle, "endif") key=fileread(tmphandle) ;this is redundant? endwhile fileclose(tmphandle) if fileexist("%tempdir%\~TMP~") then filedelete("%tempdir%\~TMP~") goto NEXTKEY :SKIPWSHCOMMANDS FileWrite(wbthandle, "if winexist(windowtitle)") FileWrite(wbthandle, " intcontrol(36,windowtitle,5,0,0)") FileWrite(wbthandle, " Sendkeysto(windowtitle,'%key%')") FileWrite(wbthandle, "endif") yield yield :NEXTKEY next return :PROCESSRUNLINES keycount=itemcount(keylist,"#") ;get number of sendkeys statements if keycount==0 then keycount=1 ;only one if no "#" signs then keylist=strcat(keylist,"#") ;and concatenate on a "#" at end of one item lists for p=1 to keycount FileWrite(wbthandle, "TimeDelay(1)") key=itemextract(p,keylist,"#") ;grab the first sendkey string commandline=key found=strindex(commandline,"@",1,@FWDSCAN) ;do WB processing with Execute if find "@" if found==1 then goto RUNWINBATCH found=strindex(commandline,"`",1,@FWDSCAN) ;do DOS batch processing if find "`" if found==1 then goto RUNCMD found=strindex(commandline,"~",1,@FWDSCAN) ;do SCRIPTIT processing if find "~" if found==1 then goto RUNSCRIPTIT found=strindex(key,"*",1,@FWDSCAN) ;do some sort of SHELL processing if find "*" if found==1 then goto RUNWSH goto RUNCMD ;otherwise, run the regular sendkeys stuff :RUNWINBATCH commandline=itemremove(1,commandline,"@") FileWrite(wbthandle, "execute %%commandline%%") goto SKIPCMD :RUNCMD parameters="" usecomspec="YES" comspec=environment("COMSPEC") found=strindex(commandline,"`",1,@FWDSCAN) if found==0 then usecomspec="NO" then goto RUNIT commandline=itemremove(1,commandline,"`") :RUNIT temp=strupper(windowkey) if strindex(temp,"RUN",1,@FWDSCAN)==@TRUE then runmode="run" if strindex(temp,"RUNWAIT",1,@FWDSCAN)==@TRUE then runmode="runwait" if usecomspec=="YES" then FileWrite(wbthandle, "%runmode%(`%comspec%`,`/c %commandline%`)") if usecomspec!="YES" command=commandline if fileexist(commandline)==@FALSE command=itemextract(1,"%commandline%"," ") parameters=itemremove(1,"%commandline%"," ") endif FileWrite(wbthandle, "command='%commandline%'") if parameters != "" then FileWrite(wbthandle, "parameters='%parameters%'") FileWrite(wbthandle, "%runmode%('%command%','%parameters%')") endif goto SKIPCMD :RUNSCRIPTIT temp=strupper(commandline) found=strindex(temp,"~EXIT",1,@FWDSCAN) if found!=0 then goto DOEXIT goto SKIPCMD :RUNWSH wshcmd=itemextract(2,key,"*") handle=fileopen("%tempdir%\~WSH~.VBS","WRITE") filewrite(handle, `set wshshell=wscript.createobject("Wscript.Shell")`) filewrite(handle, `set wshnetwork=wscript.createobject("Wscript.Network")`) filewrite(handle, `%wshcmd%`) fileclose(handle) if fileexist("%tempdir%\~WSH~.VBS") then FileRename("%tempdir%\~WSH~.VBS", VBSFile) FileWrite(wbthandle, "runhidewait('%comspec%', '/c cscript.exe //nologo %tempdir%\%VBSFile%')") goto SKIPCMD :SKIPCMD yield yield yield next return :PROCESSMKFILELINES filename=itemremove(1,windowkey," ") filename=strtrim(filename) filename=strreplace(filename,"%%%%","@@") :FILEENVSUBLOOP oenvvar=itemextract(2,filename,"%%") envvar=strupper(oenvvar) envvalue=environment("%envvar%") if envvalue!="" then filename=strreplace(filename,"%%%oenvvar%%%",envvalue) index=strindex(filename,"%%",1,@FWDSCAN) if index != 0 then goto FILEENVSUBLOOP filename=strreplace(filename,"@@","%%%%") index=strindex(mkfilelist, filename, 1, @FWDSCAN) if index==0 handle=FileOpen("%filename%", "WRITE") mkfilelist=strcat("%mkfilelist%", " ", "%filename%") else handle = FileOpen("%filename%", "APPEND") endif filewrite(handle, keylist) fileclose(handle) return
Article ID: W13761
Filename: Winbatch Script to Convert ScriptIt INI Files.txt
File Created: 2000:06:01:12:11:24
Last Updated: 2000:06:01:12:11:24