I have made a combination of scripts to execute my test.
Now I have a Main script as well, this one executes the others when needed.
I made a batch file to execute my Run.sikuli file.
It looks like this:
start /min C:\Users\<userName>\Documents\Sikuli\runIde.cmd -r C:\Users\<userName>\Documents\Sikuli\Run.sikuli
Now the above part works fine.
The thing is that I would like to display a different colour of text in the command prompt.
So I added above my line: color 0B
color 0B
start /min C:\Users\<userName>\Documents\Sikuli\runIde.cmd -r C:\Users\<userName>\Documents\Sikuli\Run.sikuli
However, my command prompt is still not black with with light blue letters.
The letters are still white.
Can anyone help me with what I am doing wrong here?
By writing start, you are actually starting a separate window (more info here). So when you set your color, it is only applied to your current window. New window will have its default color again.
NOTE: Just to emphasize, this has nothing to do with Sikuli.
Related
I'm trying to do this without opening two windows. I've looked up both commands and tried every combination I can come up with. In every case the program either opens the .exe and changes the colors (but doesn't maximize) or it opens maximized but does not apply the color command.
I am trying to find a way to adjust the window that opens while you are running a batch file WITHOUT using 3rd party programs. I have adjusted the size and color of it, but would like to move the window to the top left corner of the screen. This also has to be self contained in the batch file it self(not right-clicking on title bar and changing the settings of window position that way).
So for example, I have a batch file that opens, you answer the questions it asks then it opens the required program to finish the tasks(such as logging you into putty). But then, I would like the batch window to move to top left(already adjusted size and color to make it more noticeable) so it's easier for the user to click on it to see the "codes" I added to it to use in putty.
This is going to be distributed to multiple users and we can't add 3rd party programs and I don't want to have to explain to everyone how to adjust how the window opens, I just want it to always open top left(no matter how the computers are set up).
Lastly, all PCs are running Windows 7 and thanks in advance for the help!
Run the batch file from Start-Run:
set title=COMMAND PROMPT
reg add "hkcu\console\%title%" /v WindowPosition /t REG_DWORD /d "0" /f
start "%title%" cmd "%~f0 %title%"
exit /b
I have a simple batch file in windows that I run on startup that presents the user with a menu to start certain applications. However by default, whenever I open one of these applications the focus goes to that window and off of the batch file. Is there a way to maintain, or re-divert focus onto the batch window?
Thanks
EDIT: Got it to do what I wanted. Used foxidrives suggestion to start them minimized but they were still taking focus. So I made a short VBScript to make the cmd window the active window after each call and the combination of the two worked. Thanks!
There is no command to steal the focus. As Bill_Stewart posted, that would be a dangerous feature that grants the program too much power over the user. You can however start the applications minimized (they will still be the active window), and then build and call a VBScript to make your batch window the active window:
start "" /MIN "application.exe"
cscript /nologo myVBScript.vbs
myVBScript.vbs
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "myBatchFile"
WScript.Sleep 2000
WshShell.AppActiavte "myBatchFile"
I've read that several people have had trouble with AppActivate on Windows 7. It was not functioning for me, and instead of bringing my target window to the foreground it just blinked in the task bar. Calling it a second time however, for some reason, brought it to the foreground and made it the active window, which is what I wanted. Hope this helps anybody else with a similar issue.
you can't lock the focus to your command prompt window. But what you could do is to set the TopMost flag of the command prompt window. There is a Win32 function called SetWindowPos which does that. Maybe there are some ready to use command line tools around which are doing this for you. Or, if you have visual studio installed, try to compile this one here: How to set a console application window to be the top most window (C#)?
If you use the start command with the /min switch then the application will be minimised and the batch file should remain visible:
#echo off
pause
echo launching notepad
start "" /min notepad
echo notepad is active
pause
I'm new to using batch but I know basic commands. I'm trying to show one message (via echo or something like that) in one color. And another message in another color. (the color command colors all the text in the window instead of letting me choose what to color)
I want to do this without external software (although I am using DOSBox instead of cmd - if it matters at all), please explain your code so I can understand and learn.
Thanks.
http://www.dostips.com/forum/viewtopic.php?f=3&t=4453
Here's a ready for use color function
I have a batch file, this batch file will not start automatically, it will only run when i double click on it.
Can I run the batch file in the background when I double click on it.
Well, you can start it minimized with start, if that is enough. Really hiding it is difficult (although I can think of an option right now).
Basically you need to determine whether the batch has been started by double-clicking it. You can do this by defining a special variable and look for it:
#echo off
if not defined FOO (
set FOO=1
start /min "" %~0
exit /b
)
rem here whatever you wanted to do originally in the batch
As long as the FOO variable isn't defined (which is probably the default almost everywhere), this batch will launch itself minimized again, but with the variable defined first. Environments are passed to subprocesses, which is why this works.
you would generally need something else to run the script in that manor
i.e.
Create a shortcut, and set the “Run” field for the shortcut to “Minimized’.
Once you click or tab away from the cmd.exe window that the batch file is running it, it's "in the background" -- I'm not really sure what you want but it sounds like you might be asking how to run the batch file without displaying the cmd.exe window.
If so I can think of two ways: first, you can create a shortcut to the batch file, right click it, and in the properties there set the shortcut to run minimized (should be a drop down option next to Run).
You can also wrap invocation of the batch file in a VBScript file using Windows Script Host's shell object (calling the Run method) to run the batch file invisibly. Passing 0 as the intWindowStyle parameter will suppress display of a window or anything.
#Ghyath Serhal
I have used cmdow to do this on another program, it is an external application that can be used to modify the command prompt. To use it, you will need to either enter this code (see below) into it's own batch file, or into the command prompt, where it will run 'BatchFile.bat' with a hidden terminal window. I haven't found a way to use this in a single batch file, but I only found out about this today.
cmdow /run /hid 'BatchFile.bat'
Hope this helps.