Everytime I input data in InputBox, the input text changes Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SpiicyPuddiing
Posts: 7
Joined: 19 Oct 2021, 15:21

Everytime I input data in InputBox, the input text changes

19 Oct 2021, 15:32

I am trying to get this code to return the result when I input a link.
Basically, enter text then cmd opens and runs the text
But, my text is changed every single time.
Like, when I input "aB8iL" it changes to "AB8iL" when entering the input text in CMD

Code:

Code: Select all

InputBox, vid_url, Enter Url Please:
run, %comspec% /k ,,,pid1
WinWaitActive, %ComSpec% ahk_pid %PID1%
controlsend,,youtube-dl -f best -g %vid_url%`n,ahk_pid %pid1%
No Idea what I am doing wrong.
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Everytime I input data in InputBox, the input text changes

19 Oct 2021, 20:20

It worked when I tested it.

image211019-2119-001_cr.png
Output
image211019-2119-001_cr.png (13.02 KiB) Viewed 1100 times

I don't know why you need to use ControlSend, or why you need to use ComSpec.
SpiicyPuddiing
Posts: 7
Joined: 19 Oct 2021, 15:21

Re: Everytime I input data in InputBox, the input text changes

20 Oct 2021, 07:52

mikeyww wrote:
19 Oct 2021, 20:20
It worked when I tested it.


image211019-2119-001_cr.png


I don't know why you need to use ControlSend, or why you need to use ComSpec.
That was just me trying to simplify things -__-
Could you try an actual youtube link?
Like I entered https://www.youtube.com/watch?v=A4LE1WlNy3A
And this was entered in CMD.
image.png
image.png (24.23 KiB) Viewed 1053 times

About ControlSend or ComSpec, I just did what others did in their code in the community or stack overflow.

What would you do instead of ComSpec or ControlSend?
I have no tech background btw.
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Everytime I input data in InputBox, the input text changes  Topic is solved

20 Oct 2021, 09:01

If your target window is active, you can use Send.

If you are sending text with special characters such as "!" or "+", you can precede the string with {Text} so that AHK will not interpret those as it usually does. Explained: Text mode
SpiicyPuddiing
Posts: 7
Joined: 19 Oct 2021, 15:21

Re: Everytime I input data in InputBox, the input text changes

20 Oct 2021, 10:39

No, I will be using "hide" in a Gui to do this in the background so Send doesnt work. Yet to write the code for the Gui, but trying to achieve the CMD functionality with InputBox first.

The Text mode worked for the text btw. So I guess it is solved.
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Everytime I input data in InputBox, the input text changes

20 Oct 2021, 10:57

Also, why not run the command directly?

Code: Select all

InputBox, vid_url, Enter Url Please:
run, %comspec% /k youtube-dl -f best -g %vid_url%
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Everytime I input data in InputBox, the input text changes

20 Oct 2021, 11:27

That was part of my original question. To clarify, since your YT downloader is a program that you simply need to run, you can use it instead of ComSpec as the parameter of your Run command.
RussF
Posts: 1242
Joined: 05 Aug 2021, 06:36

Re: Everytime I input data in InputBox, the input text changes

20 Oct 2021, 11:28

All of this assumes that the path to youtube-dl is contained in the PATH environment variable. There really should be no reason to use comspec at all if you know where the executable resides. Why not:

Code: Select all

Run, PathToYoutube-dlHere\youtube-dl.exe "/k youtube-dl -f best -g %vid_url%"
I have found from experience that you have to play with when and where the quote marks go. Sometimes you need them, sometimes not. You may also be able to place the %vid_url% outside the quotes. Try many variations.

Russ
SpiicyPuddiing
Posts: 7
Joined: 19 Oct 2021, 15:21

Re: Everytime I input data in InputBox, the input text changes

20 Oct 2021, 11:41

joedf wrote:
20 Oct 2021, 10:57
Also, why not run the command directly?

Code: Select all

InputBox, vid_url, Enter Url Please:
run, %comspec% /k youtube-dl -f best -g %vid_url%
I didnt know that could have been done. This is where I originally picked it up from...
image.png
image.png (36.46 KiB) Viewed 923 times
SpiicyPuddiing
Posts: 7
Joined: 19 Oct 2021, 15:21

Re: Everytime I input data in InputBox, the input text changes

20 Oct 2021, 11:43

RussF wrote:
20 Oct 2021, 11:28
All of this assumes that the path to youtube-dl is contained in the PATH environment variable. There really should be no reason to use comspec at all if you know where the executable resides. Why not:

Code: Select all

Run, PathToYoutube-dlHere\youtube-dl.exe "/k youtube-dl -f best -g %vid_url%"
I have found from experience that you have to play with when and where the quote marks go. Sometimes you need them, sometimes not. You may also be able to place the %vid_url% outside the quotes. Try many variations.

Russ
All this doesnt need to assume youtube-dl is in the PATH variables. The user will have the ahk script and youtube-dl in an isolated folder and they will open it from there. TO help keep the downloads in that folder as well.
That works, doesnt it? Tho ffmpeg is in the PATH variables.
SpiicyPuddiing
Posts: 7
Joined: 19 Oct 2021, 15:21

Re: Everytime I input data in InputBox, the input text changes

20 Oct 2021, 11:45

mikeyww wrote:
20 Oct 2021, 11:27
That was part of my original question. To clarify, since your YT downloader is a program that you simply need to run, you can use it instead of ComSpec as the parameter of your Run command.
SO, if I am getting it right %Comspec% is only needed when the command is exclusive to CMD? If it is an executable, it doesnt need Comspec?
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Everytime I input data in InputBox, the input text changes

20 Oct 2021, 12:03

Possibly this, though I did not test it:

Code: Select all

RunWait, PathToYoutube-dlHere\youtube-dl.exe -f best -g %vid_url%
Since the URL would not contain a space, you should be OK.
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Everytime I input data in InputBox, the input text changes

20 Oct 2021, 14:04

@SpiicyPuddiing Yup! :+1: what @mikeyww said.
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: Everytime I input data in InputBox, the input text changes

20 Oct 2021, 14:55

SpiicyPuddiing wrote:
20 Oct 2021, 10:39
but trying to achieve the CMD functionality with InputBox first.
Then you could prefer direct assignment instead of inputbox since it just stores the input text to the var vid_url.
vid_url = https://www.youtube.com/watch?v=A4LE1WlNy3A
SpiicyPuddiing
Posts: 7
Joined: 19 Oct 2021, 15:21

Re: Everytime I input data in InputBox, the input text changes

21 Oct 2021, 06:37

mikeyww wrote:
20 Oct 2021, 12:03
Possibly this, though I did not test it:

Code: Select all

RunWait, PathToYoutube-dlHere\youtube-dl.exe -f best -g %vid_url%
Since the URL would not contain a space, you should be OK.
It actually might have spaces at times. At times of batch download when I dump a lot of links separated by comma, As in ', '
User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Everytime I input data in InputBox, the input text changes

21 Oct 2021, 07:14

In this case without ComSpec, whatever you would put on the Windows command line is what you would put here.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, mmflume and 167 guests