How to stop windows console cursors from blinking - windows

I know how to completely hide a cursor,
But is their any way to just stop it from blinking?
It's oddly disturbing...
I'm not gonna install 3rd party software for this,
what I want is simple solution using few lines of C++.

Go to Run prompt (Win+R)
Paste into Open box:
control main.cpl keyboard
Press OK Keyboard properties dialog appears.
Set Cursor blink rate to None. Press OK

For the record, by cmd you can do the same
You can save this code as desable_cursor_blink.cmd, and click/run...
Windows Registry Editor Version 5.00; [HKEY_CURRENT_USER\Control Panel\Desktop]"CursorBlinkRate"="-1"
reg import %~f0
By command line, you also can try:
%__APPDIR__%reg add "HKCU\Control Panel\Desktop" /v CursorBlinkRate /t REG_SZ /d -1 /f

Related

How to correctly add Sublime Text in windows context menu?

I want to add the ability to open a folder with Sublime Text to the context menu, as it is by default in VS Code, I tried the following script:
#echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for folders
#reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
#reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
#reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
pause
This works, but every time I open a folder, all previous folders open in separate windows too. Can I fix it somehow?
You should use subl.exe and not sublime_text.exe for carrying out this action; subl is meant for interacting with the running instance of Sublime (and will start it if it's not already running), while sublime_text is the application itself.
Regardless of that however, your issue is also (somewhat) related to this setting, which as seen here defaults to being turned on:
// Exiting the application with hot_exit enabled will cause it to close
// immediately without prompting. Unsaved modifications and open files will
// be preserved and restored when next starting.
//
// Closing a window with an associated project will also close the window
// without prompting, preserving unsaved changes in the workspace file
// alongside the project.
"hot_exit": true,
When this is enabled you can quit Sublime at any point and have it save it's session (including unsaved file changes, selection states, etc) and then restore that to put you back to where you were.
So, if you previously quit Sublime while you had windows open, then when you carry out your action above Sublime will restore it's session (and all other windows) and then create the new one.
Turning the setting off stops that from happening so that every startup of Sublime is a "clean" state with no restored windows or state. However this also implies that when you quit Sublime you need to ensure that you save changes or your work will be lost.
Given your provided information and based upon the information provided in the command help, reg add /?, I'd assume that your batch file should look something like this:
#Set "st3Path=%%Program Files%%\Sublime Text 3\sublime_text.exe"
#Set "regPath=HKCU\Software\Classes\Folder\shell\Open with Sublime Text 3"
#%__AppDir__%reg.exe Add "%regPath%" /VE /D "Open with Sublime Text 3" /F >NUL
#%__AppDir__%reg.exe Add "%regPath%" /V Icon /T REG_EXPAND_SZ /D "\"%st3Path%\",0" /F >NUL
#%__AppDir__%reg.exe Add "%regPath%\command" /VE /D "\"%st3Path%\" \"%%~1\"" /F >NUL
As for your Software opening previously opened 'folders', I'm sure that, you can configure the software not to reopen previous files on startup, directly in the Software or by editing its config files. That is therefore outside of the scope of your code issue, and to be dealt with separately.
You'll notice that I've used the 'Current User' registry, not the 'Local Machine', as it doesn't require to be 'Run as administrator' and you shouldn't be globally making personalization changes; not everyone wants them.
If you wish to do it for all users, however, just replace HKCU on line 2 with HKLM.
Please also note, that I have no knowledge of your software itself, so taking account of the information provided in the OdatNurd's answer, please consider whether to replace sublime_text.exe on line 1 with subl.exe
For sublime 4 (not sure about sublime 3) on windows, you just need to run the setup file again.
It will ask you if you want to add it to context menu.

In Powershell, how can I prevent my insert key status from turning to "overwrite" every time I run a command?

First off, I know this is not default behavior. In fact, I've never seen anything like this happen and I'm a long time Powershell user.
I have no problems with the Insert key in any other application. However, in Powershell, its initial state is off, or "overwrite" - which is barely if every used anymore. When I press Insert to turn it on and run a command, it then turns back off.
This has become overwhelmingly frustrating as I frequently press Up Arrow to go to the previous command to edit it, and find that it's in overwrite mode and it really messes me up.
I googled and found nothing, so I decided screw it, I'm getting a new work PC soon anyhow, so I'll just get in the habit of hitting Insert every time I press Enter. Works fine - until I switch PCs and now at home I've been hitting Insert by habit and driving myself nuts.
This behavior happens in all Powershell windows - 64-bit, inside VSCode, etc.
On demand answer:
Check the InsertMode value in HKCU\Console registry key (and all subkeys). If present, then the value should be 1 for most console prompt-like programs, e.g. as follows (output truncated for brief: removed Ubuntu and multiple Command Prompt):
^^> reg query HKCU\Console /V InsertMode /S
HKEY_CURRENT_USER\Console
InsertMode REG_DWORD 0x1
HKEY_CURRENT_USER\Console\Command Prompt
InsertMode REG_DWORD 0x1
HKEY_CURRENT_USER\Console\powershell
InsertMode REG_DWORD 0x1
HKEY_CURRENT_USER\Console\Windows PowerShell
InsertMode REG_DWORD 0x1
HKEY_CURRENT_USER\Console\Windows PowerShell (x86)
InsertMode REG_DWORD 0x1
End of search: 9 match(es) found.
You'll probably want to go to the PowerShell properties to make sure that the Insert Mode is checked (set on) at the Options tab.
%APPDATA%\Microsoft\Windows\Start Menu\Programs\Windows PowerShell\ folder seems to be the right place where the Windows PowerShell.lnk shortcut is used to be saved. However, there could be more PowerShell shortcuts. Check
where.exe /R "%USERPROFILE%" *Powershell*.lnk|findstr /V /C:"Shell ISE"
or even (run from an elevated command prompt)
2>NUL where.exe /R C:\ *Powershell*.lnk|findstr /V /C:"Shell ISE"

Refresh Internet Options through command

I have two .bat files to enable and disable proxy through registry:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet
Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet
Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
However the only way to make them work is to open up Internet Options and open up the LAN Settings tab.
The changes are made, but it's as if they aren't being applied/saved.
Is there a way I can do this through a command etc.
To apply change in registry for enable and disable the proxy in Internet Explorer from command line you have Two way.
First way:
1- Run command line As Administrator
2- Terminate Internet Explorer before change your registry.
Taskkill /F /IM iexplore.exe
3- change the proxy enable or disable from registry as you did in your question.
second way :
1- Run command line as administrator
2- Change proxy enable/disable as you did in your question
3- Terminate the windows Explorer and then Reopen after you change registry Already
taskkill /F /IM explorer.exe && start /w /b explorer.exe
In my case Internet Explorer is disabled so terminating iexplore.exe first is not possible as it's not runnung, and restarting explorer.exe each time is undesirable. But I have found out that at least in Windows 7 proxy settings refresh the moment you click OK in the 'LAN settings' window inside Internet Options.
As I was unable to find any other way to do this using command prompt, I wrote a simple AutoHotkey script that clicks all the necessary buttons automatically. The only downside is that this happens in the foreground, changing window focus, and there is no way to minimize or hide this that I'm aware of.
Enter this in run/command prompt or add to a bat file to open Internet Options window:
control /name Microsoft.InternetOptions
Run this AHK script before opening Internet Options window because script waits for the window to appear and may not work if the window already exists:
; wait for 'Internet Options' window to appear
WinWait, Internet Properties
; delays should account for any interface lag. Increase them if you find them insufficient for your particular case
Sleep 100
; focus on 'Internet Options' window, just in case focus is stolen by other window
WinWaitActive, Internet Properties
Sleep, 50
; hold Ctrl and press Tab 4 times to switch to 'Connections' tab
Send {Ctrl down}{tab 4}{Ctrl up}
Sleep, 250
; press Alt+l (keyboard shortcut for 'LAN Settings'). Change this if your system/user locale differs from English
send !l
Sleep, 500
; pressing enter here clicks OK in 'LAN settings' window, closing it. Using 'ControlClick OK' here results in AHK pressing OK button of the parent window instead to no effect
send {enter}
Sleep, 250
; click OK
ControlClick OK
return

Windows 10 System settings using CMD

Can you change windows 10 system settings using cmd.
I try to make a batch file that change the Windows settings how i want them.
Eexample : my screen is 100% and i want to make my screen 125% can i use a commannd for that ?
i was just wondering if its possible to change windows user options using a batch file. doesnt matter if its the monitor or other windows settings.
Various Windows settings are controlled by Registry keys. You can find the right key for your particular setting by Google search. As an example, to change DPI scaling to 150%, save this script to test.bat, run from open Admin Cmd Prompt, then re-login:
#echo off
reg add "HKCU\Control Panel\Desktop" /v LogPixels /t reg_dword /d 144
exit /b

Sublime as default editor

Is there a way to set Sublime Text as the default text editor for file formats on Windows 7?
Also, if anyone knew a Sublime Text Tutorial or Wiki that would be really helpful.
Actually it is not my answer, I have just googled it:
Open regedit (Win+R, type "regedit", select OK).
Navigate to HKEY_CLASSES_ROOT\Applications\sublime_text.exe\shell\open\command
Verify that the path is accurate, correct it if it is not. Exit regedit.
Open task manager via Ctrl+Alt+Del (or Ctrl+Shift+Esc for later versions of Windows), kill explorer.exe, go to run (Win+R) and type "explorer.exe" (or skip this step and simply reboot).
Now attempt the same thing, right click a text file, open with, navigate to sublime, and it should now appear in the list of available applications.
For me that value pointed to the Desktop where portable version previously was placed. Thus it just didn't work.
P.S. And for me the reboot or logout were not necessary (WinXP).
Edit on Nov 21, 2014
Tim Lewis pointed out in the comment that there is a more generic version at http://www.binaryfortress.com/NotepadReplacer/, which works better.
Original Answer
Try this: https://github.com/grumpydev/Sublime-Notepad-Replacement
Here are some ways to associate Sublime Text Portable. The following text needs to be saved as a file with a .reg extension and then on that file Right Click > Merge.
This will add a Sublime right click menu entry to all files:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell]
#="Sublime"
[HKEY_CLASSES_ROOT\*\shell\Sublime]
#="&Sublime"
[HKEY_CLASSES_ROOT\*\shell\Sublime\command]
#="\"D:\\PortableApps\\SublimeText\\sublime_text.exe\" \"%1\""
This will have Sublime Text replace all calls to notepad.exe:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\Notepad.exe]
"Debugger"="\"D:\\PortableApps\\SublimeText\\sublime_text.exe\" -z"
This will create a SublimeFile class which you can then associate with any extension.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\SublimeFile\shell]
#="edit"
[HKEY_CLASSES_ROOT\SublimeFile\DefaultIcon]
#="\"D:\\PortableApps\\SublimeText\\sublime_text.exe\",0"
[HKEY_CLASSES_ROOT\SublimeFile\shell\edit\command]
#="\"D:\\PortableApps\\SublimeText\\sublime_text.exe\" \"%1\""
This will then associate the .ext extension with SublimeFile:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.ext]
#="SublimeFile"
1: You can also set your associations in Control Panel:
Control Panel > Default Programs > Associate a file or protocol with a specific program:
2: Or, call it from code via IApplicationAssociationRegistrationUI::LaunchAdvancedAssociationUI ;)
HRESULT LaunchAdvancedAssociationUI(
[in] LPCWSTR pszAppRegName
);
You can just run CCleaner's registry cleaner tool and then choose and add the default program as usual. It worked for me when upgrading from ST2 to ST3.
Open context menu on file with desired extension in Explorer, than select Open with->You editor ( may be you need to browse for its binary before it appears in the list of available programs ) and set checkbox "Always use the selected program to open this kind of file".
I tried all options to make sublime text 3 as the default program for my .php, .css and/or .js files
I don't exactly know why it all failed, I think it is related to windows 10 current version bug
But the good news is there is some working way for me, also for those who love CMD
open CMD as administrator
run this line: FTYPE sublime="C:\Program Files\Sublime Text 3\sublime_text.exe" "%1"
for .php files use this command: ASSOC .php=sublime for js use this: ASSOC .js=sublime and so on...
Try this,
#echo off
SET st2Path=C:\Program Files\Sublime Text 2\sublime_text.exe
rem add it for all file types
#reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
#reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
#reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
rem add it for folders
#reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
#reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
#reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
pause
I tested this for SublimeText 3(Portable) also and working fine. Create a .bat file with the above code and run it as administrator.
Reference : https://gist.github.com/mrchief/5628677
sublime can be set as the default text editor by following these steps:
right-click on the .txt file and select properties.
then in Open with: option click on Change.
if the sublime is listed in the list of apps then select it, if not scroll down and click on the look for another app on this PC and select the sublime app file
I was facing the same problem.
the only solution was correct it manually
--> open regedit and navigate to Computer\HKEY_CLASSES_ROOT\Applications\, find the sublime_text.exe entry, and delete it. You should now be able to set Sublime Text 3 as the default editor for anything you want.
i found this solution in this post:https://forum.sublimetext.com/t/cant-make-default-editor-in-windows/10747/14
If you are using the portable version, you can't set Sublime as the default program for any files because Windows won't acknowledge it as a program that can open things.

Resources