thanks Rob....all end. finally make it.
Code:
var cmd = sp.ExpandEnvironmentVariables("%temp%\\dopusrt.exe.lnk");
sp.Run(cmd + " /cmd go up");
this is the first code, that use the .lnk file. as a backup solution here.
and i also find out a way to run by the window.
Code:
var exePath = action.Window.Process.MainModule.FileName;
var result = exePath.replace(/(\\dopus)\.exe/, "$1rt.exe");
sp.Run('"' + result + '" /cmd go up')
all start with:
Code:
var cmd = sp.ExpandEnvironmentVariables("%temp%\\text.exe");
sp.MessageBox(cmd, "Expanded");
since this works it kind of open my mind, then i try to re-search in the `script help document`, then i do find something else that actully could make it work.
but yes, i'm not a programer. so i ask ChatGpt. and with some hint, it really works....
like:
The return types are either project specific (StrokesPlus.net or a dependency), or they are native .NET Framework types. So if you're looking for a list of properties/methods of one of the return types below, try searching MSDN. For example the Process property is a .NET framework System.Diagnostics.Process class, which has many methods/properties like .Kill()
// Action script, get the name of the executable where the gesture started
var exeName = action.Window.Process.MainModule.ModuleName;
so can u get the path of the process?
Yes, you can get the path of the process using the MainModule.FileName property. Here's an example of how to retrieve the path of the executable for the process associated with the window where the gesture started:
javascript
var exePath = action.Window.Process.MainModule.FileName;
sp.MessageBox(exePath, "Executable Path");
In this code snippet, action.Window.Process.MainModule.FileName will return the full path to the executable for the process associated with the window where the gesture started. You can then display this path in a message box or use it as needed in your script.
the test record, really really massive words. if try to enjoy some fun,
sp.MessageBox(action.Window.ExecutablePath, "Expanded");
sp.MessageBox(action.Window.ExecutableName, "Expanded");
output: undefine.
but this works↓ the window move to center.
sp.ForegroundWindow().Center();
var exeName = action.Window.Process.MainModule.ModuleName;
sp.MessageBox(exeName, "Expanded");
output: dopus.exe
var wnd = sp.ForegroundWindow();
sp.MessageBox(wnd, "Expanded");
output: ManagedWinapi.Windows.SystemWindow
sp.RunProgram(cmd, '/cmd go up', '', 'normal', false, false, false)
Script execution failed.
Error: The specified executable is not a valid application for this
OS platform.
at Script:7:4 -> sp.RunProgram(cmd, /cmd go up', ", 'normal',
false, false, false)
var cmd = sp.ExpandEnvironmentVariables("%temp%\\dopusrt.exe.lnk");
//sp.MessageBox(cmd, "Expanded");
sp.Run(cmd + " /cmd go up");
//sp.Run(cmd + "/cmd go up") ←this can't work because ` "/cmd ` don't have a space before ` / ` ....that really kills me and thanks to chatgpt again.
//sp.Run(cmd)
//sp.Run(cmd,"/cmd go up")
//sp.RunOrActivate(cmd + '/cmd go up');
//sp.RunProgram()
//sp.RunProgram(cmd, '/cmd go up', '', 'normal', false, false, false)
/*
var wnd = sp.ForegroundWindow();
sp.MessageBox(action.Window.ExecutablePath, "Expanded");
sp.MessageBox(action.Window.ExecutableName, "Expanded");
sp.MessageBox(wnd, "Expanded");
*/
----make it simple....↓
var cmd = sp.ExpandEnvironmentVariables("%temp%\\dopusrt.exe.lnk");
sp.Run(cmd + " /cmd go up");
/*
↓confirm the path issue.
sp.MessageBox(cmd, "Expanded");
The reason why your code snippet works without explicitly calling sp.Run is that the sp.ExpandEnvironmentVariables function resolves the environment variables in the provided string and returns the expanded path.
In your case, when you use sp.ExpandEnvironmentVariables("%temp%\\dopusrt.exe.lnk"), it replaces %temp% with the actual temporary directory path, resulting in the expanded path to the dopusrt.exe.lnk file.
So, when you display the expanded path using sp.MessageBox(cmd, "Expanded"), it shows you the resolved path, and subsequently, when you use this resolved path in sp.Run(cmd + " /cmd go up"), it executes the command using the resolved path.
In summary, the sp.ExpandEnvironmentVariables function is resolving the environment variables, and by using the resolved path in sp.Run, you are able to execute the command without needing to explicitly wrap the path in double quotes.
*/
---------------keep on trying, input dopusrt.exe command with active dopus window
var path = sp.GetActiveExplorerPath(action.Window.HWnd);
sp.MessageBox(path, "Expanded");
and it reports :
error: object reference not set to an instance of an object.
at script -> sp.MessageBox(path, "Expanded");
--
var items = sp.GetItemsInExplorer(action.Window.HWnd, false, false, true);
sp.MessageBox(items, "Expanded");
i think it means get nothing, the output:
system.string[]
oh, is these two command only work for `windows explorer`?
--
var exePath = action.Window.Process.MainModule.FileName;
sp.MessageBox(exePath, "Executable Path");
output: d:\apo\dp.exe
yes, full path and filename get
--need to process, remove the dp.exe
var exePath = action.Window.Process.MainModule.FileName;
var directoryPath = exePath.substring(0, exePath.lastIndexOf("\\") + 1);
sp.MessageBox(directoryPath, "Executable Directory");
or
var exePath = action.Window.Process.MainModule.FileName;
var directoryPath = exePath.replace(/[^\\]+$/, '');
sp.MessageBox(directoryPath, "Executable Directory");
--error when test.
var path = "D:\\Program Files\\GPSoftware\\Directory Opus\\dopus.exe";
var result = path.replace(/\\dopus\.exe/, '');
sp.MessageBox(result, "Modified Path");
var tt = result + "\\#third_part_program\\killb.cmd"
sp.MessageBox(tt, "Executable Directory");
sp.Run(tt);
it's working, .cmd is running.
↓yes this works.
"D:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /cmd go up
var tt = result + "\\dopusrt.exe"
sp.MessageBox(tt, "Executable Directory");
sp.Run(tt + " /cmd go up");
**strangely it can't work, can't find the file.
sp.Run('"' + tt + '" /cmd go up')
/*
but `sp.Run('"' + tt + '" /cmd go up');` just strings, so need double quotes?
"You are correct. In the code snippet you provided earlier, since the sp.Run function requires a string containing the executable file path and its parameters as its argument, it's important to ensure that the path is properly enclosed in double quotes, especially when the path contains spaces or special characters.
By using double quotes to wrap the complete executable file path, you can ensure that the sp.Run function correctly interprets the path and executes the corresponding command. This approach is taken to ensure the safety and accuracy of the path, especially when dealing with paths containing spaces or other special characters."
*/
var exePath = action.Window.Process.MainModule.FileName;
//sp.MessageBox(exePath, "Executable Path");
//var result = exePath.replace(/\\dopus\.exe/, '');
var result = exePath.replace(/(\\dopus)\.exe/, "$1rt.exe");
//sp.MessageBox(result, "Modified Path");
sp.Run('"' + result + '" /cmd go up')
and finaly ↓
var result = path.replace(/(\\dopus)\.exe/, "$1rt.exe");
-----------here comes the full script
var exePath = action.Window.Process.MainModule.FileName;
var result = exePath.replace(/(\\dopus)\.exe/, "$1rt.exe");
sp.Run('"' + result + '" /cmd go up')
oh, by the way....sometimes i really think most of the forum font size a little too small that i need to focus to read the words....like seducing me to get more closer to the monitor.