Jump to content

Shell Execute variable not working


Recommended Posts

Hi,

I am new to Autoit. Here is the code I am stuck on:

$dCur = _nowdate();set date & time--remove unnecessary symbols

$string = $dCur

$string2 = StringReplace($string,'/','')

$tcur = _nowtime()

$string3 = $tcur

$string4 = StringReplace($string3,':','')

$string5 = StringReplace($string4,' ','')

;read each field from form 1 & concatenate

$Irfan = (guictrlread ($SYMINP) & "") & (guictrlread ($Combo1) & "") & $adjust2 & "_" & $string2 & "_" & $string5;end date & time

$var3 = iniread ("C:\MDS.ini", "section1", "key", "not found")

;send command to irfanview batch scan

run("c:\program files\irfanview\i_view32.exe /batchscan=(" & $irfan & ",1,1,2,0," & $var3 & ",tif,1)")

;autoscan on epson box & close

WinWaitActive("EPSON Scan", "", 0)

controlclick ("EPSON Scan", "","Button18", "primary", 1, 61, 27)

sleep(15000)

ShellExecute ($var3 & "\" & $Irfan & ".tif", "", "", "open", @SW_MAXIMIZE)

if FileExists ($var3) & $Irfan then

controlclick ("EPSON Scan", "","Button27", "primary", 1, 39, 12)

controlclick ("MAYVILLE DOCUMENT SCAN", "","Button1", "primary", 1, 36, 13)

EndIf

The $Irfan variable in the shell execute command, for whatever reason gives me the windows cannot find the file message.

Yet if I manually type the filename in, instead of using the $Irfan variable, the scanned file opens?

Any help is appreciated!

Link to comment
Share on other sites

Hi,

I am new to Autoit. Here is the code I am stuck on:

$dCur = _nowdate();set date & time--remove unnecessary symbols

$string = $dCur

$string2 = StringReplace($string,'/','')

$tcur = _nowtime()

$string3 = $tcur

$string4 = StringReplace($string3,':','')

$string5 = StringReplace($string4,' ','')

;read each field from form 1 & concatenate

$Irfan = (guictrlread ($SYMINP) & "") & (guictrlread ($Combo1) & "") & $adjust2 & "_" & $string2 & "_" & $string5;end date & time

$var3 = iniread ("C:\MDS.ini", "section1", "key", "not found")

;send command to irfanview batch scan

run("c:\program files\irfanview\i_view32.exe /batchscan=(" & $irfan & ",1,1,2,0," & $var3 & ",tif,1)")

;autoscan on epson box & close

WinWaitActive("EPSON Scan", "", 0)

controlclick ("EPSON Scan", "","Button18", "primary", 1, 61, 27)

sleep(15000)

ShellExecute ($var3 & "\" & $Irfan & ".tif", "", "", "open", @SW_MAXIMIZE)

if FileExists ($var3) & $Irfan then

controlclick ("EPSON Scan", "","Button27", "primary", 1, 39, 12)

controlclick ("MAYVILLE DOCUMENT SCAN", "","Button1", "primary", 1, 36, 13)

EndIf

The $Irfan variable in the shell execute command, for whatever reason gives me the windows cannot find the file message.

Yet if I manually type the filename in, instead of using the $Irfan variable, the scanned file opens?

Any help is appreciated!

You need to correct your ShellExecute call. The parameters have been given as "" and you are calling a program called $var3 & "\" & $Irfan & ".tif". which is why the file can't be found. Check the help.

You might need the full path to the tiff file and that isn't given in the ini file.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hi,

Thank you for replying.

I am calling the directory & name of the TIF (irfanview)file in the beginning of the shellexecute ($var3 & "\" & $irfan & ".tif"). Am I misunderstanding this? I did look at the help file, which got me to this point, for the last day.

As far as the parameters--according to help file ("") is no parameters?.

I have also tried taking the ($var3 & "\" & $irfan & ".tif") & putting it in a variable. example: $var4 = $var3 & "\" & $Irfan & ".tif". Then using

shellexecute ($vAR4, "", "", "OPEN", @SW_MAXMIMIZE) & I get the same result--TIF image will not open.

If I remove the $irfan from the shell execute & just type the file name in quotes, the image opens up in irfanview example:

shellexecute ($var3 & "\" & "45678FIR4443_682011_25003PM01.tif", "", "", "open", @sw_maximize) $var3 is the path (C:\temp) to the directory containing the image file ($irfan).

I have also created a one line script using: shellexecute ("C:\temp\45678FIR4443_682011_25003PM01.tif", "", "", "open", @sw_maximize) and the TIF image opens in irfanview.

To me, the $irfan variable is the issue, however, this is my first script, so there is a good chance i'm not understanding something correctly.

Can you please help?

Link to comment
Share on other sites

Hi,

Thank you for replying.

...

Can you please help?

Perhaps I have misunderstood what you are trying to do. I thought you wanted to run a program with ShellExecute, and that program should be passed $var3 & "\" & $Irfan & ".tif " as a parameter for the file it should work on or open. If that is not the case then are you saying that you expect the tiff to be opened by the program associated with tiff images on your PC.

If so then the first thing I would do place ConsoleWrite( ">>" &$var3 & "\" & $Irfan & ".tif & "<<" & @CRLF) before the ShellExecute line and see what gets printed out.

If what's printed out looks coirrect to you then are there any spaces in the bit between >> and << ? If there are then that is why you have a problem because sheel execute is looking for whatever occurs up to th efirst space, so you just need to enclose it all in quotes -

"'" & $var3 & "\" & $Irfan & ".tif'"

If not then come back.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Perhaps I have misunderstood what you are trying to do. I thought you wanted to run a program with ShellExecute, and that program should be passed $var3 & "\" & $Irfan & ".tif " as a parameter for the file it should work on or open. If that is not the case then are you saying that you expect the tiff to be opened by the program associated with tiff images on your PC.

If so then the first thing I would do place ConsoleWrite( ">>" &$var3 & "\" & $Irfan & ".tif & "<<" & @CRLF) before the ShellExecute line and see what gets printed out.

If what's printed out looks coirrect to you then are there any spaces in the bit between >> and << ? If there are then that is why you have a problem because sheel execute is looking for whatever occurs up to th efirst space, so you just need to enclose it all in quotes -

"'" & $var3 & "\" & $Irfan & ".tif'"

If not then come back.

Link to comment
Share on other sites

Martin,

Thanks for the consolewrite tip. That is very handy. There are no spaces & the path and filename look perfect to me. Would you like me to include the code of the whole program, or is the problem area I have posted sufficient?

Thanks for all the help!

Edited by Homey
Link to comment
Share on other sites

In post #3 you say that if you type the following it works

$var3 & "\" & "45678FIR4443_682011_25003PM01.tif" (i)

In post #1 you say

$Irfan = (guictrlread ($SYMINP) & "") & (guictrlread ($Combo1) & "") & $adjust2 & "_" & $string2 & "_" & $string5;end date & time (ii)

and

ShellExecute ($var3 & "\" & $Irfan & ".tif", "", "", "open", @SW_MAXIMIZE) (iii)

So (i) works ok and (iiii) doesn't . Therefore the two are different.

In (iii) you have used $Irfan and yiou have already said that there is something wrong with it. So if you have

ConsoleWrite($var3 & "\" & "45678FIR4443_682011_25003PM01.tif" & @CRLF)

ConsoleWrite($var3 & "\" & $Irfan & ".tif" & @CRLF)

then I would expect that you would see a difference.

Try to get to the problem in steps.

FileChangeDir($var3)

If FileExists($Irfan & ".tif") then 
   MsgBox(262144,"Yes", "It is there")
else
   MsgBox(262144,"No","It' really isn't there.")
endif
[code]

and then maybe
[code]
FileChangeDir($var3)
$Search = FileFindFirst("*.tif")

While 1
   $File = FileFindNext($Search)
   if error then exitloop
   if StringInStr($File,"45678FIR4443") then ConsoleWrite($File & @CRLF);show any files which contain some part o fthe name you think should exist.
wend

FileClose($Search)

Finding errors you can't understand is simply a slog and there is often no short cut.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...