StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Register | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General Discussion
 General Discussion
 acRunProgram: variable before other cmd parameters
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

poweruser84

Russia
24 Posts

Posted - 04/23/2014 :  17:03:17  Show Profile  Reply with Quote
Hi all

I have a question about acRunProgram.
I need to insert a global variable(as first command line parameter) before additional command line parameters.

Here is necessary behavior:


variable1 = acGetForegroundWindow
acRunProgram c:\\Windows\\SysWOW64\\Prog.exe "variable1(it's value)" "additional command line parameters for Prog.exe"


Please give me suggestion about correct syntax.

Edited by - poweruser84 on 04/23/2014 17:19:19

Rob

USA
2601 Posts

Posted - 04/24/2014 :  11:14:17  Show Profile  Visit Rob's Homepage  Reply with Quote
This should work:
local var1 = acGetForegroundWindow()
acRunProgram("c:\\Windows\\SysWOW64\\Prog.exe",var1,0, 1)
For the sake of describing syntax, two periods will concatenate; though it's not required above since you're passing parameters in via the parameter option for acRunProgram. For example:
local textA = "Hi!"
local textB = "Rob"
acMessageBax(textA.." My name is "..textB)
Go to Top of Page

poweruser84

Russia
24 Posts

Posted - 04/28/2014 :  14:26:20  Show Profile  Reply with Quote
But how i can add additional command line parameters for Prog.exe (the following parameters after first parameter variable1) through the acRunProgram function?

I want to set execution of prog.exe(through the acRunProgram) with parameters. I'll try to explain better. Command line should work in that way:

Prog.exe variable1 parameter1 parameter2

Where:
variable1 - is value of local variable from S+
parameter1 and parameter1 - standard command line parameters supported by Prog.exe


Can you provide the right syntax for acRunProgram?

Edited by - poweruser84 on 04/28/2014 14:32:44
Go to Top of Page

Rob

USA
2601 Posts

Posted - 04/28/2014 :  14:40:48  Show Profile  Visit Rob's Homepage  Reply with Quote
Ok, first of all, acRunProgram simply calls the Windows API call to start a program. This means that the path to and name of the executable can only be the fully qualified name; no parameters.

For example, this will work since that is the full and correct path to the Notepad executable:

acRunProgram("c:\\windows\\notepad.exe","",0, 1)

This, however, will not work:

acRunProgram("c:\\windows\\notepad.exe C:\\MyTextFile.txt","",0, 1)

...because c:\windows\notepad.exe C:\MyTextFile.txt is not a valid path and executable name.

However, this would work:

acRunProgram("c:\\windows\\notepad.exe","C:\\MyTextFile.txt",0, 1)

...because it starts c:\windows\notepad.exe and passes the parameter C:\MyTextFile.txt; essentially, it is the same as c:\windows\notepad.exe C:\MyTextFile.txt

Does that make sense?

What you want is to put the parameters where var1 is located:

acRunProgram("c:\\Windows\\SysWOW64\\Prog.exe",var1,0, 1)

For example:

local var1 = "Something"
acRunProgram("c:\\Windows\\SysWOW64\\Prog.exe",var1.." parameter1 parameter2",0, 1)

This would result in the equivalent of:

c:\Windows\SysWOW64\Prog.exe Something parameter1 parameter2
Go to Top of Page

poweruser84

Russia
24 Posts

Posted - 04/28/2014 :  17:51:08  Show Profile  Reply with Quote
Thank you, Rob.

But i am getting error message "[string "ActionScript":36: attemp to concentrate global 'processhandle'(a function value)

Full script:

acActivateWindow(acGetOwnerWindowByPoint(acGetMouseLocationX(), acGetMouseLocationY()),0,0)
processhandle=acGetForegroundWindow
local exename = acGetExecutableName(acGetForegroundWindow(), 0, 0)
if exename ~= "explorer.exe" then
acRunProgram("C:\\Windows\\nircmd.exe","win flash foreground 1 1000",0,1)
acDelay(2000)
acMinimizeWindow(nil, acGetMouseLocationX(), acGetMouseLocationY())
acRunProgram("c:\\Windows\\SysWOW64\\GetPID.exe",processhandle.." pssuspend.exe $$$$",0,1)
else
end

Note: GetPID.exe is indended to run external program with specified parameters + PID as an last parameter.
Go to Top of Page

Rob

USA
2601 Posts

Posted - 04/28/2014 :  20:20:46  Show Profile  Visit Rob's Homepage  Reply with Quote
Have you tried putting () after acGetForegroundWindow? I'm on my phone, so I can't test at the moment
Go to Top of Page

Rob

USA
2601 Posts

Posted - 04/28/2014 :  20:21:51  Show Profile  Visit Rob's Homepage  Reply with Quote
Also, precede it with "local" since there's no need for it to be global
Go to Top of Page

poweruser84

Russia
24 Posts

Posted - 04/29/2014 :  18:13:26  Show Profile  Reply with Quote
Thank you Rob! I am missed syntax error.

quote:
Also, precede it with "local" since there's no need for it to be global


I use this variable in another gesture.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000