DosTips.com

A Forum all about DOS Batch
It is currently 23 Aug 2017 02:09

All times are UTC-06:00




Post new topic  Reply to topic  [ 65 posts ]  Go to page Previous 1 2 3 4 5
Author Message
PostPosted: 09 Feb 2017 23:32 
Offline

Joined: 16 Dec 2016 22:31
Posts: 100
@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.

Top
   
PostPosted: 10 Feb 2017 07:00 
Offline
Expert

Joined: 22 Jan 2010 18:01
Posts: 2770
Location: Germany
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 39 times
Top
   
PostPosted: 10 Feb 2017 10:02 
Offline

Joined: 16 Dec 2016 22:31
Posts: 100
@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. :)


Top
   
PostPosted: 10 Feb 2017 14:52 
Offline
Expert

Joined: 22 Jan 2010 18:01
Posts: 2770
Location: Germany
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


Top
   
PostPosted: 10 Feb 2017 23:58 
Offline

Joined: 16 Dec 2016 22:31
Posts: 100
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.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 65 posts ]  Go to page Previous 1 2 3 4 5

All times are UTC-06:00


Who is online

Users browsing this forum: Bing [Bot] and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited