Jump to content

Run - challenge


Recommended Posts

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

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

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?

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.  

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...