0
votes

I have script looks like this:

DetectHiddenWindows, On 
Run,%comspec% /k, , hide, pid2 
WinWait, ahk_pid %pid2% 
ControlSend, ,winscp.com script="path\to\script.txt", ahk_pid %pid2% 
sleep,3000 
;-- close hidden DOS window -- 
Process, Close, %pid2% 
Process, WaitClose, %pid2%

But the problem is sometimes the controlsend works and send right letters and sometimes it change the double columns to single one and sometimes change the winscp.com to winscp>com and etc which I dont know from where these letters sometimes come so Any idea how to fix this issue and make it always send the right letters cuz this really frustrate me and makes the whole script mess up.

Thanks a lot

Max

1
Instead of that code simply use run, winscp.com script="path\to\script.txt",,hide and add exit in your script.txt. - wOxxOm
This is great solution but I still want to detect when the process has finished uploading all data to continue the script also I am kind of curious person who would love to know why this issue was occurring if anyone's know. Thanks. - Wild Lion
So simply add a pid variable and use process, waitclose exactly the way you already have. - wOxxOm
That's perfect with me. I won't ask again for reason for issue so as I don't be bothering but can u show me how to add pid to run command as an example if u don't mind? - Wild Lion
You already have it, and you can read in the help file: Run, program and arguments, , hide, pid2 << pid2 here is the Process ID variable (PID). - wOxxOm

1 Answers

0
votes
DetectHiddenWindows, on

Run, winscp.com script="path\to\script.txt", , hide, pid2

Sleep 6000

Process, close, %pid2%
Process, WaitClose, %pid2%

That was the best way for me to ensure all upload is done and ready to continue with the script.

Note: I could use the RunWait with /c command (which substitute the sleep command) to summarize whole script I provided above but I was afraid it still gives same issue I mentioned above so I prefered just directly using run with and process close and WaitClose commands.

Max