I saw this topic: viewtopic.php?f=3&t=5860 automating the Bell character. Now, is there a way to store the Ctrl+C character as a variable?
Meerkat
Store Ctrl+C Char
Moderator: DosItHelp
Re: Store Ctrl+C Char
This is EXT character - DEC/HEX/OCT code is 03.
Check GenCHR
or Certutil
or dbenham's forfiles subtoutine:
(I can put only two links so the last one is in code block)
it is possible also with mshta,WSH/JScript/VBScript,powershell,built-in .net compilers.
Check GenCHR
or Certutil
or dbenham's forfiles subtoutine:
Code: Select all
http://www.dostips.com/forum/viewtopic.php?p=23888
(I can put only two links so the last one is in code block)
it is possible also with mshta,WSH/JScript/VBScript,powershell,built-in .net compilers.
Re: Store Ctrl+C Char
Using the same technique - control c is ascii character 3
Code: Select all
@echo off
for /f %%i in ('forfiles /m "%~nx0" /c "cmd /c echo 0x03"') do set "cc=%%i"
>file.txt echo "%cc%"
Re: Store Ctrl+C Char
I tried this:
...but this is the output:
Meerkat
Code: Select all
@echo off
setlocal
::Define a Linefeed variable
set LF=^
::above 2 blank lines are critical - do not remove.
call :hexprint "0x03" var
set var
exit /b
:hexPrint string [rtnVar]
for /f eol^=^%LF%%LF%^ delims^= %%A in (
'forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(%~1"'
) do if "%~2" neq "" (set %~2=%%A) else echo(%%A
exit /b
...but this is the output:
Code: Select all
var=♥
Meerkat
Re: Store Ctrl+C Char
Meerkat wrote:...but this is the output:Code: Select all
var=♥
Yep - That is how the console displays a Ctrl-C (0x03) character
Dave Benham
Last edited by dbenham on 16 Aug 2015 08:16, edited 2 times in total.
Re: Store Ctrl+C Char
dbenham wrote:Meerkat wrote:...but this is the output:Code: Select all
var=♥
Yep - That is how the console displays a Ctrl-C (0x03) character
Dave Benham
Yeah, that's quite weird. Sorry I thought that "heart" symbol is not the char (I am new into this), but I applied it to my code and it works smoothly!
Thanks everyone!
Meerkat
Re: Store Ctrl+C Char
Depending on your goal, you might find this link useful: Programmatically "press" Ctrl-C / Exit batch inside CALL
Dave Benham
Dave Benham