Changing CMD window properties programmatically - windows

How can I change the appearance of my current CMD window?
I know there is a 'mode' and 'color' commands that give you some control, but it's not enough...
Is it possible to change Screen Buffer Size separately? To turn QuickEdit mode on/off?
Is there an API for this?

Search engines are amazing things :).
Search for Windows Console API and the 2nd link is: this. Digging in a tiny bit more and you find the interestingly named "SetConsoleMode" and "SetConsoleScreenBufferSize" APIs which appear to set the console mode (which includes quick edit mode) and screen buffer size.
I've not used the APIs so I don't know if there are any caveats, but from the documentation, these seem to be what you're looking for.

another way: use reg /? to query your registry for reg query HKEY_CURRENT_USER\Console. There you can see keys like ScreenBufferSize etc. Use reg to delete the key and add it back with new values. Type reg /? on the command line to see its help usage. make sure you backup registry before trying.

Related

Mac OS option key shortcuts not working, how to make it work?

I have a very long line which I want to view as wrapped.
There is an option called word wrap that can help me achieve this.
Anyhow the shortcut method option + z doesn't work, instead inserts a ˀ there.
Any solutions?
Looks like one of your extension might be overriding your VSCode config. Try ⌘+SHIFT+P/CMD+SHIFT+P and then search for View: Toggle Word Wrap/Toggle Word Wrap.
You will then be able to see the shortcut assigned to that command on your local PC. Alternatively, ⌘+SHIFT+P/CMD+SHIFT+P and search for Keyboard Shortcuts. In there search for OPTION+z and check for the answers which pop up.

Check Text Size Via Command Prompt Windows 7

I'm using Sikuli to do some tests which requires the computers resolution and text size to be set to a certain size. In this case, the text size should be set as "smaller - 100%". I'd like the computer to check to make sure this is the case before it actually wastes time attempting to run the test.
Is there a command you can type into command prompt that will tell you what the text size setting is set to? Or another quick way of finding the information? The only way I know of to get the information is Control Panel\Appearance and Personalization\Display. Using Sikuli to open up the control panel and visually check the text size wouldn't be worth the time, so I'd like a quick way of checking.
Also, I'd rather this be without any addon or anything like that.
Thanks.
HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics
AppliedDPI DWord
This is a per user setting.

Modifying How Windows Path is Displayed in CMD

I need to modify the way the CMD shows the path, whether it's in a batch file or not.
For example:
~/Users/MyName/Desktop
instead of:
C:\Users\MyName\Desktop
It would also be appreciated if somene could tell me how to use colours in CMD in the following way:
echo /color1Blah/color2Blah
This takes me back to the days when everyone knew and used DOS!
There is a environment variable that controls how the prompt is displayed in the command window.
PROMPT=$P$G
You can kind of accomplish what you want, but with limitations. For instance, if you go to a command window and type:
C:\>prompt ~$P[space] (don't type the C:\> and [space] is an actual space), your prompt will change to:
~c:\[space]
You can type prompt /? to see all of the available options. Once you have found a combination that you like, edit the environment variable and it will be set for all future command windows. The biggest limitation is that you cannot change the backslashes to forward slashes.
As for colors, type color /? from the command line. You can set the entire background and foreground colors, but not individual elements on the screen. That is unless you can get a copy Ansi.sys and get Windows to load it when you open a Command Window. Here are a couple of cool links to sites that use color in the PROMPT.
http://www.robvanderwoude.com/ansi.php
http://www.robvanderwoude.com/prompt.php
I Googled ansi.sys windows 7 and found a few people that said they got it working (like here). I don't have Ansi.sys anywhere to give it a try.
The first path is a Linux path the second is a windows path - never the two shall meet.

Type a pre defined text when a shortcut key is pressed in Windows 7

I work on mainframes and don't have much knowledge about windows other than playing warcraft :-) hence pardon me if I ask something nooby/silly.
I have a requirement to enter a particular long-text in the current position of a cursor whenever a shortcut key is pressed.
I am thinking of creating a bat file and assigning a windows keyboard shortcut to the bat file and whenever I have requirement to enter the long text, I press the windows shortcut key
and the long text gets typed in the current position of the cursor.
The current position of the cursor can be in any application, like Excel, Word or notepad or Windows dialog prompts.
Could you please let me know if this is possible and point me where I could get some information about this "technique".
Thanks & Regards,
Vasanth.S
To make a single key combo do what you are asking, you may need another program. You can make a link to a batch file, hook up a shortcut and then use the clip command to copy text from a file onto the clipboard. That would require the shortcut and then a Ctrl+V to paste. The batch file would look like this:
clip < c:\SomeDir\sometext.txt
You might like to look at using a clipboard manager - which saves a history of clipboard entries, can search for an entry, and paste it at the cursor.
Ditto and CLCL are both useful and free - which one you use depends on your windows version.
They are hotkey driven for ease of use, but mouse can be used.

Reuse Edit Control as Command Window

This is a GUI application (actually MFC). I need a command window with the ability to display a prompt like such:
Name of favorite porn star:
The user should be able to enter text after the prompt like such:
Name of favorite porn star: Raven Riley
But I need to prevent the user from moving the cursor into the prompt area. Users should also be prevented from backspacing into the prompt in order to prevent the following:
Rrraven Rrrileeey Ruuuulez!!! Name of favorite porn star:
Also need to control text selection and so on. And finally, I should have no problem retrieving only the text the user entered (minus prompt text).
Will it be better to create my own window class from scratch (i.e inherit from CWnd) or should I reuse the Windows EDIT control (i.e. inherit from CEdit)?
A similar command window can be seen in AutoCAD and Visual Studio (in debug mode).
I think you'd be better off creating a subclass of CEdit and limiting filtering key-presses. I suppose the hard part is not letting the user move the caret to the prompt area, but you can probably write some code to make sure the caret always get sent back to where it belongs (the input part).
Anyway, if you really, really want to implement your own control (it's not that difficult after all) I recommend you read Jacob Navia's "technical documentation" on how he built the LCC compiler and environment. Actually, it seems the docs are not online anymore, but I'm sure you can get them through his e-mail (jacob#jacob.remcomp.fr).
Edit: I liked your previous example better. Keep it classy, LOL :)
I had a very similar requirement and did exactly what davidg suggested; subclassed a edit control and filtered key presses. This was actually using Qt not MFC but the principle will be exactly the same.
You need to remember to filter keys such as home as well as left and backspace. I just checked to see if the move would move the caret into the prompt and if it did ignored the keypress.
Another thing to watch for is pasting multiline text, you will have to choose whether to just paste the first line or all lines, adding the prompt on all lines after the first. When subclassing the control you get lots of behaviour which won't work exactly as you want it.

Resources