Jump to content
newniman

Run - challenge

Recommended Posts

newniman

Hi, first post here - so this is probably an :> question.

This works:

Global $processid0 = Run("C:\CHDKPTP\chdkptp.exe -i", "", @SW_MAXIMIZE)

I need to make this more general to get user input and use variables - to that end I tried the following, but the program hangs:

    $the_path_passed_in = "C:\CHDKPTP\"

    $path1 = '"'
    $path2 = $the_path_passed_in
    $path3 = "chdkptp.exe"
    $path4 = "-i"
    $path5 = '"'
    $path6 = ","
    $path7 = '"'
    $path8 = '"'
    $path9 = ","
    $path10 = "@SW_MAXIMIZE"

    $final_path = $path1 & $path2 & $path3 & " " & $path4 & $path5 & $path6 & " " & $path7 & $path8 & $path9 & " " & $path10

   Global $processid0 = Run($final_path)

In an attempt to understand what's going wrong, when I display $final_path in an edit box (using GUICtrlSetData($chdk_path, $final_path), the edit box displays:

"C:\CHDKPTP\chdkptp.exe -i", "", @SW_MAXIMIZE

Any comment appreciated.

(i've attached the complete script for fuller context if necessary)

 

WIP-GUI .au3

Share this post


Link to post
Share on other sites
water

Welcome to AutoIt and the forum!
Try:

$sPath = "C:\CHDKPTP\"
$sProgram = "chdkptp.exe"
$sParameters = "-i"
$sWorkingDir = ""
$sFlag = "@SW_MAXIMIZE"
Global $iProcessID = Run($sPath & $sProgram & " " & $sParameters, $sWorkingDir, $sFlag)

 

Edited by water
  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
newniman

Thanks very much for your comment water.

Unfortunately that does not work.

In case it might help with a further suggestion i've attached a .PNG file of what I type in the Windows7 Run dialog. 

 

Run.PNG

Share this post


Link to post
Share on other sites
water

My bad. Should be:

$sPath = "C:\CHDKPTP\"
$sProgram = "chdkptp.exe"
$sParameters = "-i"
$sWorkingDir = ""
$iFlag = @SW_MAXIMIZE
Global $iProcessID = Run($sPath & $sProgram & " " & $sParameters, $sWorkingDir, $iFlag)

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
newniman

That done the trick water, many thanks.

Do you have any idea why my initial try failed? I'm purely a hobby programer but that was a bit annoying :sweating:

(don't worry if it'd be a long explanation - don't want to waste your time)

Share this post


Link to post
Share on other sites
water

I didn't spend too much time checking your code but I think the way you passed the data to Run everything was seen as a single parameter not as 3 as needed.

  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
SadBunny

Your original code added some commas to the string. Try adding MsgBox(0,0,$final_path) after you construct it with all the string concatenation... That's probably it.

/edit: oh, wait, now I see what you tried to do. Functions don't work that way. A function that takes three arguments is not "secretly a function that takes only one argument but with commas in it"... ;) You have to actually separate the arguments. Which is of course what Water's code did.

Consider this "in-between form", maybe it explains it better. (The naming is intentionally bad, to show the three arguments. Water's naming is what you should use.
 

$sArg1_part1 = "C:\CHDKPTP\"
$sArg1_part2 = "chdkptp.exe"
$sArg1_part3 = "-i"
$sArg2 = ""
$iArg3 = @SW_MAXIMIZE

$final_arg1 = $sArg1_part1 & $sArg1_part2 & " " & $sArg1_part3

Global $iProcessID = Run($final_arg1, $sArg2, $iArg3)

If this is hard to understand, maybe it's a good idea to practice writing a script that contains a function of your own with parameters. Say, try to make this broken piece of code work:
 

$answer = addTwoNumbers(2, 5)
msgbox(0,0,$answer)

$answer = addTwoNumbers(10, 20)
msgbox(0,0,$answer)

func addTwoNumbers()
    return ??? ; make this return the correct value
EndFunc

 

Edited by SadBunny
  • Like 1

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
newniman

Thanks for your further comment water.

SadBunny - excellent info. I feel much more comfortable than before ;)

Share this post


Link to post
Share on other sites
newniman

water,

with so many posts I see you have vast experience. Since you are following this thread I hope you can reply to this even though the subject matter should, perhaps, be posted in a separate thread (of course i'm interested in comment from others too).

Background:

I just started to develop an AutoIt GUI interface with a lua based camera control application a couple of days ago. While AutoIt seems extremely capable, I summarise my experience to date of the GUI development "tools" as... 

Observations so far:

  1. To create a preliminary "mock-up" GUI was quick/easy with coda - but once changes were needed it becomes practically useless.
  2. I spotted this Form Builder beta and the ability to bounce between the GUI design and code seemed ideal, but - there are so many bugs when using this tool that I have currently reverted to manual (and extremely time consuming) creation of the GUI code.

​Query:

Is there a trick i'm missing to speed GUI creation? e.g. something like Form Builder beta but a lot less buggy or some other experience to share that might help cut GUI development time?

 

 

 

Share this post


Link to post
Share on other sites
SadBunny

Did you notice File -> Import -> Import AutoIt Gui in Koda? It regenerates the "wysiwig" from the Koda-generated block you paste into it, so you can easily make changes, regenerate form code and put it back in your script.

You can also open an .au3 script straight from Koda. And push the generated code straight into SciTE from Koda.

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
newniman

I hadn't noticed that, thanks.​

So, I do that and Load/Process -> "Done successfully" reported, now

make a change to the gui and hit "generate code and I get the attached "Import-Regenerate-Error.PNG" error :blink:

 

 

You can also open an .au3 script straight from Koda. And push the generated code straight into SciTE from Koda.

​In Coda, I File/Open/pick my .au3 file and...nothing happens (that i'm aware of at least after 5 mins) :ermm:

 

Import-Regenerate-Error.PNG

Share this post


Link to post
Share on other sites
newniman

Update:

I deleted all but one tabsheet from the single tab in the form. and 

Now, after Load/Process -> "Done successfully" reported / make a change to the gui and hit "generate code" and... code is now generated ;)

That solves a lot of my productivity gap.

 

Thanks SadBunny.  

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

×