Advanced Batch features via auxiliary .exe programs

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Sounak@9434
Posts: 100
Joined: 16 Dec 2016 22:31

Re: Advanced Batch features via auxiliary .exe programs

#61 Post by Sounak@9434 » 09 Feb 2017 23:32

@aGerman: Cool Tool! :D
Thanks Steffen.
Just a few things:-
1) Does conin stands for console input ? I know it's not a serious question, just asking though.
2) Is it possible to have a timer, so that if no input is given within a specified amount of time conin.exe will close itself? I'm too nit picky, am I?
3)
aGerman wrote:Also I used the technique that I learned from carlos in order to skip the overhead caused by the main function in C.

Is the technique available for public? :mrgreen:
Last edited by Sounak@9434 on 10 Feb 2017 11:53, edited 1 time in total.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Advanced Batch features via auxiliary .exe programs

#62 Post by aGerman » 10 Feb 2017 07:00

Sounak@9434 wrote:1) Does conin stands for console input ?

Yes. (Exactly as noted in the batch code.)

Sounak@9434 wrote:3) Is the technique available for public?

Everything noted in the source code. It's GCC specific. The underlying __start routine will be overridden.

Sounak@9434 wrote:2) Is it possible to have a timer, so that if no input is given within a specified amount of time conin.exe will close itself?

Sure.

Code: Select all

@echo off &setlocal EnableDelayedExpansion

:: conin.exe - Read Console Input
:: timeout: %errorlevel% = 0
:: type:    %errorlevel%>>29 (0=keyboard, 1=left click, 2=right click, 3=mouse move)
:: key:     %errorlevel% (either character code or (for extended keys) 256 + key code)
:: mouse:   row = (%errorlevel%>>14)&0x3FFF, column = %errorlevel%&0x3FFF

:: the utility times out after the passed number of milliseconds, it will wait infinite if you don't pass an argument

for /l %%i in () do (
  conin.exe 1000
  set /a "key=!errorlevel!, type=key>>29, y=(key>>14)&0x3FFF, x=key&0x3FFF"

  if !key! == 0 (
    echo timeout
  ) else if !type!==1 (
    echo mouse left  x=!x!, y=!y!
  ) else if !type!==2 (
    echo mouse right x=!x!, y=!y!
  ) else if !type!==3 (
    echo mouse move  x=!x!, y=!y!
  ) else (
    echo keyboard !key!
  )
)


Steffen
Attachments
conin.zip
(2.82 KiB) Downloaded 889 times

Sounak@9434
Posts: 100
Joined: 16 Dec 2016 22:31

Re: Advanced Batch features via auxiliary .exe programs

#63 Post by Sounak@9434 » 10 Feb 2017 10:02

@aGerman: Thank you very much steffen. The latest version works beautifully. Thanks again.
aGerman wrote:
Sounak@9434 wrote:3) Is the technique available for public?

Everything noted in the source code. It's GCC specific. The underlying __start routine will be overridden.


Whoa! :shock: Never realized that was the trick. I have to try it out next time for sure. :)

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Advanced Batch features via auxiliary .exe programs

#64 Post by aGerman » 10 Feb 2017 14:52

I had to update the tool because the console mode was not reset if the timeout elapsed.
But now I don't want to occupy Antonio's thread any longer... :wink:

Steffen

Sounak@9434
Posts: 100
Joined: 16 Dec 2016 22:31

Re: Advanced Batch features via auxiliary .exe programs

#65 Post by Sounak@9434 » 10 Feb 2017 23:58

aGerman wrote:But now I don't want to occupy Antonio's thread any longer... :wink:


:mrgreen:

That reminds me my initial request was for Antonio to update his getmouse.exe . Maybe he doesn't want to add keyboard support to a tool named getmouse.exe :D

Thanks though you all. You people are a great help.

thefeduke
Posts: 211
Joined: 05 Apr 2015 13:06
Location: MA South Shore, USA

Re: Advanced Batch features via auxiliary .exe programs

#66 Post by thefeduke » 03 Jan 2018 01:10

I ran into a limitation in the use of window.exe with no operands to get the TITLE of the current window. For some time, I have been handling some cases like this:

Code: Select all

:: . . .
Rem Window.exe returns blanks when Title + 3 + Command exceeds 60
    If NOT Defined Ttl Set "WinTtl=Undetermined - error, blank or too long to handle."
(EndLOCAL & If /I "%~1" NEQ "" (Set "%1=%WinTtl%") Else Echo.%WinTtl%)
:: . . .
Like most of your auxiliary .exe programs, it runs without complaint. The lack of output is the only indication. Would this be a firm limitation of the Windows interfaces that you use to get the information?

John A.

cha_lan_cito
Posts: 1
Joined: 06 Feb 2019 23:35

Re: Advanced Batch features via auxiliary .exe programs

#67 Post by cha_lan_cito » 06 Feb 2019 23:47

Hello,
Uups, I was trying to check if your StdDate.exe pgm could help me, but my Windows 10 - 64 bits OS says that "16 bit pgms are not compatible"
May be you may provide me with a pgm version for at least 32 bits (or better 64 bits)?
Best regards.
Juan Manuel Carrillo Campos

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Advanced Batch features via auxiliary .exe programs

#68 Post by aGerman » 07 Feb 2019 13:55

How did you get the tool? In the initial post you will find a download link for all tools compressed in a ZIP file. I can ensure you that the StdDate.exe in this archive is a 32Bit executable and it's running without any problems on Win10 x64, too.

Steffen

nsky
Posts: 2
Joined: 20 Jul 2020 07:05

Re: Advanced Batch features via auxiliary .exe programs

#69 Post by nsky » 09 Aug 2020 09:20

Hi all!
I tested the CursorPos program and suddenly came across a question to which I have not yet found an answer.
The problem is as follows.
CursorPos description wrote:
Get or set cursor position.

CursorPos [[±]col [±]row]

If no parameter is given, return current cursor position as col+(row<<16) in ERRORLEVEL.

If any coordinate have sign, the position given is relative to the current one.

If cursor is moved, the Ascii code of the character at new position is returned in ERRORLEVEL.
Me debug printing did not help me answer the question - how to get Ascii code of the character at new cursor position.
My debug script is inherently very simple as it consists of repeating blocks.

Code: Select all

:: chkCursorPos.cmd
@echo off
setlocal enableDelayedExpansion
pushd %~dp0

cls
echo.A
echo. B
echo.  C
echo.   D
<nul set /p =qwErty

CursorPos.exe
::GetCoords Cols= Lines=
set /a "$X=%ErrorLevel%&0xFFFF, $Y=(%ErrorLevel%>>16)&0xFFFF, $E=%ErrorLevel%"
>%~nx0.log (
	echo.step0: backup current cursor pos?
	echo.CursorPos.exe
	echo.current pos:
	set $
	echo.::::::::::::::::::::
)
>nul pause

CursorPos.exe 0 0
set /a "_X=%ErrorLevel%&0xFFFF, _Y=(%ErrorLevel%>>16)&0xFFFF, _E=%ErrorLevel%"
>>%~nx0.log (
	echo.step1: move new pos 0 0    - simbol "A"
	echo.CursorPos.exe 0 0
	echo.
	set _
	echo.====================
)
>nul pause

CursorPos.exe +1 +1
set /a "_X=%ErrorLevel%&0xFFFF, _Y=(%ErrorLevel%>>16)&0xFFFF, _E=%ErrorLevel%"
>>%~nx0.log (
	echo.step2: move new pos +1 +1 - simbol "B"
	echo.3: CursorPos.exe +1 +1
	set _
	echo.-------------------
)
>nul pause

CursorPos.exe 1 1
set /a "_X=%ErrorLevel%&0xFFFF, _Y=(%ErrorLevel%>>16)&0xFFFF, _E=%ErrorLevel%"
>>%~nx0.log (
	echo.step2': move pos 1 1      - simbol "B"
	echo.3: CursorPos.exe 1 1
	set _
	echo.:::::::::::::::::::
)
>nul pause

CursorPos.exe +1 +1
set /a "_X=%ErrorLevel%&0xFFFF, _Y=(%ErrorLevel%>>16)&0xFFFF, _E=%ErrorLevel%"
>>%~nx0.log (
	echo.step3: move new pos +1 +1  - simbol "C"
	echo.CursorPos.exe +1 +1
	set _
	echo.-------------------
)
>nul pause

CursorPos.exe 1 1
set /a "_X=%ErrorLevel%&0xFFFF, _Y=(%ErrorLevel%>>16)&0xFFFF, _E=%ErrorLevel%"
>>%~nx0.log (
	echo.step3': move pos 1 1       - simbol "B"
	echo.3: CursorPos.exe 1 1
	set _
	echo.:::::::::::::::::::
)
>nul pause

CursorPos.exe +2 +2
set /a "_X=%ErrorLevel%&0xFFFF, _Y=(%ErrorLevel%>>16)&0xFFFF, _E=%ErrorLevel%"
>>%~nx0.log (
	echo.step4: move new pos +2 +2  - simbol "D"
	echo.CursorPos.exe +2 +2
	set _
	echo.-------------------
)
>nul pause

CursorPos.exe -1 +1
set /a "_X=%ErrorLevel%&0xFFFF, _Y=(%ErrorLevel%>>16)&0xFFFF, _E=%ErrorLevel%"
>>%~nx0.log (
	echo.step5: move new pos -1 +1  - simbol "E"
	echo.CursorPos.exe -1 +1
	set _
	echo.-------------------
)
>nul pause

CursorPos.exe %$E%
>>%~nx0.log (
	echo.step6: restore pos 
	echo.CursorPos.exe %$E%
	set $
	echo.====================
)
>nul pause
exit /b
Debug txt-file:

Code: Select all

step0: backup current cursor pos?
CursorPos.exe
current pos:
$E=262150
$X=6
$Y=4
::::::::::::::::::::
step1: move new pos 0 0    - simbol "A"
CursorPos.exe 0 0

_E=262150
_X=6
_Y=4
====================
step2: move new pos +1 +1 - simbol "B"
3: CursorPos.exe +1 +1
_E=0
_X=0
_Y=0
-------------------
step2': move pos 1 1      - simbol "B"
3: CursorPos.exe 1 1
_E=65537
_X=1
_Y=1
:::::::::::::::::::
step3: move new pos +1 +1  - simbol "C"
CursorPos.exe +1 +1
_E=65537
_X=1
_Y=1
-------------------
step3': move pos 1 1       - simbol "B"
3: CursorPos.exe 1 1
_E=131074
_X=2
_Y=2
:::::::::::::::::::
step4: move new pos +2 +2  - simbol "D"
CursorPos.exe +2 +2
_E=65537
_X=1
_Y=1
-------------------
step5: move new pos -1 +1  - simbol "E"
CursorPos.exe -1 +1
_E=196611
_X=3
_Y=3
-------------------
step6: restore pos 
CursorPos.exe 262150
$E=262150
$X=6
$Y=4
====================
ErrorLevel values are 5-6-digit numbers in the debug log.
It does not seem that they, in addition to the coordinates, contain an Ascii code character.

Has anyone got the Ascii character codes via CursorPos? Give an example.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Advanced Batch features via auxiliary .exe programs

#70 Post by aGerman » 10 Aug 2020 10:58

If I run your script the log file contains

Code: Select all

step0: backup current cursor pos?
CursorPos.exe
current pos:
$E=262150
$X=6
$Y=4
::::::::::::::::::::
step1: move new pos 0 0    - simbol "A"
CursorPos.exe 0 0

_E=65
_X=65
_Y=0
====================
step2: move new pos +1 +1 - simbol "B"
3: CursorPos.exe +1 +1
_E=66
_X=66
_Y=0
-------------------
step2': move pos 1 1      - simbol "B"
3: CursorPos.exe 1 1
_E=66
_X=66
_Y=0
:::::::::::::::::::
step3: move new pos +1 +1  - simbol "C"
CursorPos.exe +1 +1
_E=67
_X=67
_Y=0
-------------------
step3': move pos 1 1       - simbol "B"
3: CursorPos.exe 1 1
_E=66
_X=66
_Y=0
:::::::::::::::::::
step4: move new pos +2 +2  - simbol "D"
CursorPos.exe +2 +2
_E=68
_X=68
_Y=0
-------------------
step5: move new pos -1 +1  - simbol "E"
CursorPos.exe -1 +1
_E=69
_X=69
_Y=0
-------------------
step6: restore pos 
CursorPos.exe 262150
$E=262150
$X=6
$Y=4
====================
This seems to be the expected behavior. So, unfortunately I can't reproduce your issues.

Steffen

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Advanced Batch features via auxiliary .exe programs

#71 Post by Aacini » 10 Aug 2020 11:36

It seems there are two versions of CursorPos.exe! I found this new Help file:

Code: Select all

NEW: CursorPos version 1.2

This version includes two modifications:
- When the cursor is moved, the value returned is previous cursor position.
- If coordinates have this form: -cols +0 and the resulting column is negative,
  the position is adjusted to the end of previous line.
It seems that in the last .zip file I posted the new version of the code, but forgot to update the Help text.

I'll try to post here an old, version 1, of CursorPos.exe

Antonio

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Advanced Batch features via auxiliary .exe programs

#72 Post by aGerman » 10 Aug 2020 12:42

Oh. In this case ignore my previous comment. The tool I tested with was from spring 2016 :lol:

Steffen

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Advanced Batch features via auxiliary .exe programs

#73 Post by Aacini » 10 Aug 2020 13:08

Thanks Steffen. Could you post it here in a .zip file?

Antonio

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Advanced Batch features via auxiliary .exe programs

#74 Post by aGerman » 10 Aug 2020 13:37

Sure I can :)

Steffen
Attachments
CursorPos.zip
(768 Bytes) Downloaded 564 times

nsky
Posts: 2
Joined: 20 Jul 2020 07:05

Re: Advanced Batch features via auxiliary .exe programs

#75 Post by nsky » 12 Aug 2020 04:04

Well!
The new version from 2016.03.16 works as stated.
It remains to update the link to download the entire package from the first post of the topic (downloaded 2214 times).
Thanks!

Post Reply