Computer Hope
Microsoft => Microsoft DOS => Topic started by: zask on December 29, 2015, 11:36:00 PM
-
okay lets say i have a batch file that says this
@echo off
color 17
set /p "command=Type text here : "
echo %command%
pause
in order for me to type in the display where it says "Type text here :" i have to click on the batch file, is there a way i can automatically click the batch file (in code) without having to click the batch file by mouse?
-
You can start it from command prompt by doing
start nameofbatchfile.bat
instead of double clicking it.
-
Well... yes.
OR, he could schedule it to start at 6:55 every morning.
-
Well... yes.
OR, he could schedule it to start at 6:55 every morning.
I had the feeling he might have wanted it to be automated :D
I though it best to wait and see.
-
I know its possible to run the batch script invisible with vbs, is it possible to do this at the same time?
-
okay lets say i have a batch file that says this
@echo off
color 17
set /p "command=Type text here : "
echo %command%
pause
in order for me to type in the display where it says "Type text here :" i have to click on the batch file, is there a way i can automatically click the batch file (in code) without having to click the batch file by mouse?
It helps in a programming forum to ask an exact question of what you want to do - because programming is an exact set of steps to solve a specific problem.
You're not alone in giving examples of a simplistic task - most people ask questions with bogus information. The problem is that you can't get an accurate answer for an inaccurate question.
-
It helps in a programming forum to ask an exact question of what you want to do - because programming is an exact set of steps to solve a specific problem.
You're not alone in giving examples of a simplistic task - most people ask questions with bogus information. The problem is that you can't get an accurate answer for an inaccurate question.
Im sorry that my question appeared bogus, I couldn't think of anyway to explain it any better than i want the file to automatically click itself at start, but if it helps Nexusfactor answered my previous question
-
I couldn't think of anyway to explain it any better than i want the file to automatically click itself at start
"click itself at start" gives your readers no idea of what you are doing. It doesn't mean anything.
Explaining the task doesn't hurt, surely. ;)
-
"click itself at start" gives your readers no idea of what you are doing. It doesn't mean anything.
Explaining the task doesn't hurt, surely. ;)
well i did add an explanation
"in order for me to type in the display where it says "Type text here :" i have to click on the batch file, is there a way i can automatically click the batch file (in code) without having to click the batch file by mouse?"
-
Define "automatic".
If using windows 7 speech recognition, you could say "click on the batch file" and it would start. But of course, you would have to have your microphone on and the speech module loaded.
Batch, of itself, has not even-driven triggers. It has to have some other code start it upon a specific external event. Such as the user touching something to doing something the computer can sense. Telepathy will not be available for at least seven years. Or more. ::)
-
From what I understand, zask's "issue" is that when he double-clicks a batch file on his desktop, it doesn't have focus, so they need to click it to give it focus, and they want it to do this "automatically".
The confusion likely stems from how this behaviour makes no sense whatsoever. I can't reproduce it anywhere, on any system. if I double click a batch file, it launches and it has the focus.
-
From what I understand, zask's "issue" is that when he double-clicks a batch file on his desktop, it doesn't have focus, so they need to click it to give it focus, and they want it to do this "automatically".
The confusion likely stems from how this behaviour makes no sense whatsoever. I can't reproduce it anywhere, on any system. if I double click a batch file, it launches and it has the focus.
okay i will try to explain, lets say you have a batch fie on your desktop and you click it, then it displays a prompt that says "type here : " if you type anything it will not type until you click the prompt. I am trying to make it automatically type inside the prompt when the file is open, instead of opening the the prompt, clicking it, and then typing. Does that make any more sense?????
-
like really it's not that hard to understand
-
I knew what you meant. And like I said, the confusion probably stems from the fact that what you describe simply is not what happens in a typical Windows Install. If I double-click a batch file on my desktop- or the desktop of any of my Windows systems, keyboard input goes to the command prompt window that appears. I do not have to click it unless I intentionally click elsewhere first. I can double-click the batch file, completely let go of the mouse, and type in the command prompt window without clicking it.
-
From this page...
http://www.computerhope.com/sethlp.htm
@ECHO off
cls
:start
ECHO.
ECHO 1. Print Hello
ECHO 2. Print Bye
ECHO 3. Print Test
set choice=
set /p choice=Type the number to print text.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto hello
if '%choice%'=='2' goto bye
if '%choice%'=='3' goto test
ECHO "%choice%" is not valid, try again
ECHO.
goto start
:hello
ECHO HELLO
goto end
:bye
ECHO BYE
goto end
:test
ECHO TEST
goto end
:end
Is that what he wants? :D
-
I knew what you meant. And like I said, the confusion probably stems from the fact that what you describe simply is not what happens in a typical Windows Install. If I double-click a batch file on my desktop- or the desktop of any of my Windows systems, keyboard input goes to the command prompt window that appears.
That's exactly what happens - and why the question makes absolutely no sense.
That can't be what zask means, because it just doesn't happen in Windows.
like really it's not that hard to understand
I will bet you a puppy that you are not using the code that you showed us :D
...or your Windows is just broken and somehow you never noticed. ;)
-
I knew what you meant. And like I said, the confusion probably stems from the fact that what you describe simply is not what happens in a typical Windows Install. If I double-click a batch file on my desktop- or the desktop of any of my Windows systems, keyboard input goes to the command prompt window that appears. I do not have to click it unless I intentionally click elsewhere first. I can double-click the batch file, completely let go of the mouse, and type in the command prompt window without clicking it.
Well i figured since i said type in it without having t click by mouse that you would automatically understand what i meant
-
From this page...
http://www.computerhope.com/sethlp.htm
@ECHO off
cls
:start
ECHO.
ECHO 1. Print Hello
ECHO 2. Print Bye
ECHO 3. Print Test
set choice=
set /p choice=Type the number to print text.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto hello
if '%choice%'=='2' goto bye
if '%choice%'=='3' goto test
ECHO "%choice%" is not valid, try again
ECHO.
goto start
:hello
ECHO HELLO
goto end
:bye
ECHO BYE
goto end
:test
ECHO TEST
goto end
:end
Is that what he wants? :D
yes exactly thank you
-
not exactly, im trying to keep the screen focused even when you are in a different window
-
The reason is because im trying to do this.
i have 2 batch files name bat1.bat and bat2.bat.
when i type in bat1.bat, bat2.bat needs to always be focused so that what ever i type in bat one also types in bat two at the same time.
i knew this sounds dumb but i thought it could be a cool thing to do if it could be pulled off because it would be easier typing in two consoles at the same time than to have to send this dumb command and start every time or run the bat1.bat inside the bat2.bat.
@echo off
title bat1.bat
set /p "somemessage : "
echo echo %somemessage% >> bat2.bat
start bat2.bat
-
The reason is because im trying to do this.
i have 2 batch files name bat1.bat and bat2.bat.
when i type in bat1.bat, bat2.bat needs to always be focused so that what ever i type in bat one also types in bat two at the same time.
i knew this sounds dumb but i thought it could be a cool thing to do if it could be pulled off because it would be easier typing in two consoles at the same time than to have to send this dumb command and start every time or run the bat1.bat inside the bat2.bat.
@echo off
title bat1.bat
set /p "somemessage : "
echo echo %somemessage% >> bat2.bat
start bat2.bat
-
A mentioned earlier, batch is not much of monitoring events and external conditions.
There are a class or group of program tools that do monitor events and signals. Sometimes the signals are called 'Semaphores' ti identify them as a special way to communicate with the operating system when something happens outside of the computers own world.
If this is of interest to you, you could read this:
https://en.wikipedia.org/wiki/Semaphore_%28programming%29
A trivial semaphore is a plain variable that is changed (for example, incremented or decremented, or toggled) depending on programmer-defined conditions. The variable is then used as a condition to control access to some system resource.
But that is rather simplified...
A useful way to think of a semaphore as used in the real-world systems is as a record of how many units of a particular resource are available, coupled with operations to safely (i.e., without race conditions) adjust that record as units are required or become free, and, if necessary, wait until a unit of the resource becomes available. Semaphores are a useful tool in the prevention of race conditions; however, their use is by no means a guarantee that a program is free from these problems. Semaphores which allow an arbitrary resource count are called counting semaphores,
And it gets more involved...
Semaphores vs. mutexes
A mutex is essentially the same thing as a binary semaphore and sometimes uses the same basic implementation. The differences between them are in how they are used. While a binary semaphore may be used as a mutex, a mutex is a more specific use-case, which allows extra guarantees:
Since only the process that locked the mutex is supposed to unlock it, a mutex may store the id of process that locked it and verify the same process unlocks it.
Mutexes may provide priority inversion safety. If the mutex knows who locked it and is supposed to unlock it, it is possible to promote the priority of that process whenever a higher-priority task starts waiting on the mutex.
Mutexes may also provide deletion safety, where the process holding the mutex cannot be accidentally deleted.
A mutex may be recursive: a process is allowed to lock it multiple times without causing a deadlock.
Someday in the future you will pick up the microphone and tell your computer:
"Please click on the batch files I want to click, but not the ones that don't work."
But the programming tool needed will be more than just batch.
-
Well i figured since i said type in it without having t click by mouse that you would automatically understand what i meant
There is nothing to "understand". It's gibberish. It's like saying "When I click a button in the taskbar, is there a way to type in the window without clicking it?". It makes no sense as a question because The actions you listed already result in exactly what you described as the desired end result.
When you click a batch file, the window that launches will *already* have the focus. You don't need to simulate a mouse click. If you are getting different behaviour than your install is borked.
-
Ir seems others have the same kind of vocabulary. Just not sure if it is English.
A Google search for:
Automatically click a batch file
Brings up lost of posts that sound similar to what the OP said.
Following some suggestions, we find this:
Search Results
Schedule a Batch File to run automatically
Step 1: Create a batch file you wish to run and place it under a folder where you have enough permissions. ...
Step 2: Click on Start and under search, type in Task and click open Task Scheduler.
Step 3: Select Create Basic Task from the Action pane on the right of the window.
Which simply says you make it a task to be run automatically. Presently , the task schedule is driven by the clock. So it is the clock that does the click. Perhaps somebody will develop a device to sense brain waves and click on the batch when you think about it.
Here is a tutorial for Task Manager:
How to Use Task Manager - PCWorld (http://www.pcworld.com/article/241693/how_to_use_task_manager.html)
Windows 10 has a feature that tries to learn your habits.
Cortana (software) - Wikipedia (https://en.wikipedia.org/wiki/Cortana_%28software%29)
Cortana is an intelligent personal assistant created by Microsoft for Windows Phone 8.1, Windows 10 Mobile (where it now supersedes Bing Mobile),[4] Microsoft Band, Xbox One,[5][6] Windows 10, iOS and Android.[7]
Cortana was demonstrated for the first time at the Microsoft BUILD Developer Conference (April 2–4, 2014) in San Francisco.[1] It has been launched as a key ingredient of Microsoft's planned "makeover" of the future operating systems for Windows Phone and Windows.[4] It is named after Cortana,[8] a synthetic intelligence character in Microsoft's Halo video game franchise originating in Bungie folklore,[9] with Jen Taylor, the character's voice actress, returning to voice the personal assistant's US-specific version.[10]
Maybe that is what Zask wants. A personal helper. :)
-
They don't want to automatically click a batch file, despite their topic title. They want to automatically click the batch window programmatically to give it focus. a Redundant operation because it already has focus when it launches on any Windows install that isn't borked.
-
BC_Programmer,
Do you mean he thinks he has to click again to get focus?
In that case, he wants Widows to do what it does even when he does not understand what it does. So now we must ask, Does the OP now understand?
(Set to music of 'Just one look..')
Just one click... that's all it took !
Just one click... that's all it took !
:)
-
His Windows install is probably borked. Could be a result of him allegedly writing malware and other garbage provided to him by his "professional programming teacher".
-
It's clear that zask hasn't shown the real code, as he hasn't refuted my comments - and that's the aspect I brought up very quickly in this thread IIRC.
And which I repeat in every thread where someone wants an accurate answer. but doesn't show an accurate question.
-
It's clear that zask hasn't shown the real code, as he hasn't refuted my comments - and that's the aspect I brought up very quickly in this thread IIRC.
And which I repeat in every thread where someone wants an accurate answer. but doesn't show an accurate question.
I stayed clear away when I saw this the intent of what they want to do is very shady when they want to hide it...
I know its possible to run the batch script invisible with vbs, is it possible to do this at the same time?
Reminds me of long ago when people were asking for work arounds for the COLOR command to set the text and background to same color to hide what is going on in DOS and it wouldnt allow it with the color command such as COLOR FF
-
They don't want to automatically click a batch file, despite their topic title. They want to automatically click the batch window programmatically to give it focus. a Redundant operation because it already has focus when it launches on any Windows install that isn't borked.
I want multiple windows to be focused at the same time as the batch windows, for example if i type in google, or on a game or something, it would also type in the batch screen.
-
His Windows install is probably borked. Could be a result of him allegedly writing malware and other garbage provided to him by his "professional programming teacher".
no its so that i can implement a pixel mouse inside the batch to click a button, dude back off with the negativity. i run my malware in a virtualbox, and i dont use it for illegal purposes. im noting going to bork my windows. thats non sense
-
A mentioned earlier, batch is not much of monitoring events and external conditions.
There are a class or group of program tools that do monitor events and signals. Sometimes the signals are called 'Semaphores' ti identify them as a special way to communicate with the operating system when something happens outside of the computers own world.
If this is of interest to you, you could read this:
https://en.wikipedia.org/wiki/Semaphore_%28programming%29But that is rather simplified...And it gets more involved...Someday in the future you will pick up the microphone and tell your computer:
"Please click on the batch files I want to click, but not the ones that don't work."
But the programming tool needed will be more than just batch.
im just trying to type in two windows at the same time
-
im just trying to type in two windows at the same time
Again, it is not clear what you mean.
Do you ride two bicycles at the same time? (Very Hard.)
Do you walk two dogs at the same time? (Possible.)
Can you type on two typewrites at the same time? (Clark Kent could.)
For users that need to repeat something many l times, they use tools suitable for doing repetition a number of times. Such are called 'macro' devices or tools.
https://en.wikipedia.org/wiki/Macro_%28computer_science%29
(Thus, they are called "macros" because a big block of code can be expanded from a small sequence of characters.)
In batch you can define macros in a special way. There are not called macros, but they are. On batch can call another batch and pass parameters. For an industrial programmer this serves as a macro.
-
It helps in a programming forum to ask an exact question of what you want to do
Im sorry that my question appeared bogus, I couldn't think of anyway to explain it any better than i want the file to automatically click itself at start
like really it's not that hard to understand
no its so that i can implement a pixel mouse inside the batch to click a button
im just trying to type in two windows at the same time
I want multiple windows to be focused at the same time as the batch windows, for example if i type in google, or on a game or something, it would also type in the batch screen.
-
dude back off with the negativity.
Actually I've been quite restrained. I made significant edits to most of my posts before submitting them to fit within forum rules.
-
I still don' get what he really means.
He says type in two windows. You can not do that. But you can switch windows.
Many users reach for the mouse, point to the Taskbar, and then click the button for the window they want to bring to the foreground. That's about the slowest, least convenient method. If you're a fan of keyboard shortcuts, like I am, you probably use Alt-Tab to cycle between open windows.
Now if you have a block of text you wish to send to two destination,s you select it and use the 'send to' option to put in on another location. Or send to clipboard and then to destintion.
-
Okay i dont mean have two windows focused at the same time, i said that wrong, i mean i want to have two windows that implement task and send them to each other, for example like the [Batch] [Colours] [Sound] Honguito98: Limits Of Batch 2 that is found here~
https://www.youtube.com/watch?v=QMiZQxu1Rpo
they all require each window to make it's whole operation work.