Skeeter

Beginner - dos batch to AutoIt GUI

3 posts in this topic

First time poster and serious AutoIt noob.  I'm looking for direction in understanding the For command as my code is coming from a batch file that works but I would like to pretty it up for the end user.  

This works:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\..\..\..\Program Files (x86)\AutoIt3\SciTE\Printer.ico
#AutoIt3Wrapper_Outfile=Send_to_Xerox.exe
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_Run_Au3Stripper=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$SimpleGUI = GUICreate("Send to Xerox", 286, 75, -1, -1)
$Test = GUICtrlCreateButton("TEST", 8, 8, 125, 25)
$Production = GUICtrlCreateButton("PRODUCTION", 144, 8, 125, 25)
$Exit = GUICtrlCreateButton("EXIT", 100, 40, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Run(@ComSpec & ' /c ' & 'xcopy C:\Windows\winsxs\amd64_microsoft-windows-p..ting-lprportmonitor_31bf3856ad364e35_6.1.7601.17514_none_1229a6f0546e2346\* c:\windows\syswow64 /Q /Y', '', @SW_HIDE)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Production
            PRODUCTION()

        Case $Test
            TEST()

        Case $Exit
            Exit

    EndSwitch
WEnd


Func TEST()
    RunWait(@ComSpec & ' /c ' & 'w2test.bat', '', @SW_HIDE)
    RunWait(@ComSpec & ' /c ' & 'move *.pdf \\server\shared\folder')
    WinClose('Send to Xerox')
    EndFunc   ;==>TEST


Func PRODUCTION()
    RunWait(@ComSpec & ' /c ' & 'w2prod.bat', '', @SW_HIDE)
    RunWait(@ComSpec & ' /c ' & 'move *.pdf \\server\shared\folder')
    WinClose('Send to Xerox')
EndFunc   ;==>PRODUCTION

And this does not:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\My Scripts\Printer.ico
#AutoIt3Wrapper_Outfile=Send to IT printer.exe
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_Run_Au3Stripper=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$SimpleGUI = GUICreate("Send to Xerox", 286, 75, -1, -1)
$Test = GUICtrlCreateButton("TEST", 8, 8, 125, 25)
$Production = GUICtrlCreateButton("PRODUCTION", 144, 8, 125, 25)
$Exit = GUICtrlCreateButton("EXIT", 100, 40, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Run(@ComSpec & ' /c ' & 'xcopy C:\Windows\winsxs\amd64_microsoft-windows-p..ting-lprportmonitor_31bf3856ad364e35_6.1.7601.17514_none_1229a6f0546e2346\* c:\windows\syswow64 /Q /Y', '', @SW_HIDE)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Production
            PRODUCTION()

        Case $Test
            TEST()

        Case $Exit
            Exit

    EndSwitch
WEnd


Func TEST()
    RunWait(@ComSpec & ' /c ' & 'for %%f in (*.pdf) do LPR -SXXX.XXX.XXX.XXX -PHHSC_W2 "%%f"', '', @SW_HIDE)
    RunWait(@ComSpec & ' /c ' & 'move *.pdf \\server\share\folder')
    WinClose('Send to Xerox')
    EndFunc   ;==>TEST


Func PRODUCTION()
    RunWait(@ComSpec & ' /c ' & 'for %%f in (*.pdf) do LPR -SXXX.XXX.XXX.XXX -PHHSC_W2 "%%f"', '', @SW_HIDE)
    RunWait(@ComSpec & ' /c ' & 'move *.pdf \\server\shared\folder')
    WinClose('Send to Xerox')
EndFunc   ;==>PRODUCTION

It seems since the For command is present in AutoIt that it tries to process it instead of sending it to cmdline where it is known to work.  Is there a different way to write it so it still looks for all files in the directory it is being run in and loops to process each *.pdf accordingly then moves all *.pdf to the server share.  I'm trying to keep it all within the generated .exe file instead of calling batch files.  And yes...this must be performed using LPR, it is the only way the printshop will accept the files.  In the first script the batch files contains the same text as the bottom script.  Any help is greatly appreciated.

Share this post


Link to post
Share on other sites



try:

RunWait(@ComSpec & ' /c for %f in (*.pdf) do LPR -SXXX.XXX.XXX.XXX -PHHSC_W2 "%f"', '', @SW_HIDE)

and when it doesn't work check what is happening with:

RunWait(@ComSpec & ' /k for %f in (*.pdf) do LPR -SXXX.XXX.XXX.XXX -PHHSC_W2 "%f"', '')

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

 Jos you rock!  Works perfectly.  I've been beating my head on this one for a week and didn't want to ask for help.

 

Thanks!

Share this post


Link to post
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