0
votes

I have the following script:

^!c::
Run stop
Return

Stop is configured to run a program via environment variables.

So if I open up cmd and type “stop” and hit enter the program opens as intended, even if I push winkey + R it does the same thing. However if I use the script with ctrl+alt+c. I do not get the same result.

Why is the script doing something different?

How can I change my script to behave the same way as if it was typed into cmd or winkey + R?

1
Maybe run cmd /c stopwOxxOm
what does the /c do? also no luckAequitas
Is stop a batch file? What does "configured" mean?wOxxOm
yeah it's a bat file, I don't fully understand it but I installed some programs and changed some environment variables, and now when I type in stop it automatically finds the right file somehow.Aequitas
I give up. In my experience run command launches anything that can be launched via Run dialog using the same command line.wOxxOm

1 Answers

2
votes

Simple:

run, %comspec% /c stop

Or if this doesn't work you could just start a cmd window and send it directly

run, %comspec% /k
WinWait, %comspec%
WinActivate
Send stop{Enter}

/c tells the console window to close after execution, /k lets it stay open

or you could use an COM object and even get the output.

objShell := ComObjCreate("WScript.Shell")
objExec := objShell.Exec(ComSpec " /c stop")

strStdOut := ""
while, !objExec.StdOut.AtEndOfStream
{
    strStdOut := objExec.StdOut.ReadAll()
}

Update: Without the run command at all:

SetTitleMatchMode, 2

send #r

WinWait, TITLE_OF_THE_RUN_WINDOW
WinActivate

send cmd{Enter}

WinWait, cmd.exe
WinActivate

WinGetTitle, title
Send stop{Enter}

WinWait, %title%,,, stop
WinClose,

TITLE_OF_THE_RUN_WINDOW replace this with the title of the window, which opens on Win+r. A windows cmd window has the command in its title while it gets executed. So we save the title of the command window, and wait for it to drop the command ("stop") and close it then.

UPDATE: Cmd window close added to solution 4