Page 1 of 3
Mouse Hovering in Batch
Posted: 16 Dec 2016 23:18
by Sounak@9434
Well I am a new user here but I have learned decent batch programming with available online resources.
Well, I like to keep it short so, Is there any tool available to detect batch hovering?
I have found
GetInput by Aacini which accesses both mouse and keyboard input(Something I was looking for) but not hovering
(see edit).
There is also another file called
Input.exe http://www.thebateam.org/2016/06/input-function-v10-by-kvc.html by KVC but it's detection is much slower compared to the next but unusable alternative.
Finally in advanced bat to exe converter
http://www.battoexeconverter.com by compiling
rem mousecmd GET it contains a fast hovering support but it prints only to the title and to clipboard so it is unable to be used inside batch file additionally it does not support keyboard input as additional input.
So is there any
batch mouse supporting utility that supports mouse hovering fast and also has a keyboard support?EDIT: Getinput.exe now supports mouse hovering.Sounak
Re: Mouse Hovering in Batch
Posted: 17 Dec 2016 09:43
by misol101
Yeah, cmdwiz can do that
Re: Mouse Hovering in Batch
Posted: 17 Dec 2016 13:06
by TSnake41
Re: Mouse Hovering in Batch
Posted: 17 Dec 2016 22:19
by Sounak@9434
Well, Cmdwiz meets almost all my needs.
It has a fast mouse detection function as well as supports timer and keyboard but can you guys make the block color inverted on which mouse is in like in the attached file.(It wont works if quickedit is on)
P.S. It was Advanced bat to exe's mousecmd menu example.
Re: Mouse Hovering in Batch
Posted: 18 Dec 2016 06:37
by Sounak@9434
well, darkbox_i is also fast and works good. But it does not supports both keyboard and mouse input on the same time, does it?
Re: Mouse Hovering in Batch
Posted: 18 Dec 2016 11:31
by misol101
Gotoxy, which is in the same archive as cmdwiz, can print inverted characters by xor'ing, using the somewhat cryptic format:
gotoxy 13 20 "\xX\G" f f
Print the existing character (\G) at position 13,20, using xor for both foreground color and background color with color f and f to inverse both.
If you want to print several characters, just add more \G after each other (or use M switch to repeat: gotoxy 13 20 "\xX\M20{\G}" f f x)
You will have to manually restore the old color (by using the same xor operation) when the mouse moves. Also, you might get "extra" mouse events so you should do the xor operation only for the first event of a new location.
Regarding quickedit, cmdwiz can turn that on/off (setquickedit operation)
Re: Mouse Hovering in Batch
Posted: 18 Dec 2016 23:08
by Sounak@9434
It would be quite tough to keep on changing the Colors. By the way misol101 your tool cmdwiz is cool. It contains so many features in such a low file size. Insertbmp is awesome too.
Same for TSnake41's darkbox, it prints colored text at the maximum speed I have ever seen.
I think using this tools creating a game would be very easy.
If there is any other tools or solutions available please post them too.
Re: Mouse Hovering in Batch
Posted: 19 Dec 2016 14:31
by misol101
Sounak: Thanks! Maybe have a look at cmdgfx too for games, if you haven't already.
It's not really hard to do what I said, this script will let you move around an inverted single character with the mouse similar to what happens in the example executable you sent.
Code: Select all
@echo off
setlocal ENABLEDELAYEDEXPANSION
cmdwiz showcursor 0
cmdwiz getquickedit & set QE=!errorlevel!
cmdwiz setquickedit 0
cls
type %~n0.bat
set /a MX=-100, MY=-100
:LOOP
cmdwiz getch_and_mouse>mouse_out.txt
for /F "tokens=1,3,5,7,9,11,13,15,17,19,21 delims= " %%a in (mouse_out.txt) do set EVENT=%%a&set KEY=%%b&set MOUSE_EVENT=%%c&set NEW_MX=%%d&set NEW_MY=%%e&set LMB=%%f&set RMB=%%g&set LDBL=%%h&set RDBL=%%i&set MWHEEL=%%j
if "%EVENT%"=="NO_EVENT" goto LOOP
if "%MOUSE_EVENT%"=="0" goto NOMOUSEINPUT
set OR=0 & (if %NEW_MX% neq %MX% set OR=1) & (if %NEW_MY% neq %MY% set OR=1) & if !OR!==1 (
gotoxy !MX! !MY! "\xX\G" f f
set /a MX=!NEW_MX!, MY=!NEW_MY!
gotoxy !MX! !MY! "\xX\G" f f
)
:NOMOUSEINPUT
if not %KEY% == 27 goto LOOP
del /Q mouse_out.txt>nul
cmdwiz setquickedit %QE%
endlocal
cmdwiz showcursor 1
Re: Mouse Hovering in Batch
Posted: 20 Dec 2016 00:28
by Sounak@9434
That is awsome! It is just like the one in my example.
Though speed is a little factor. It's a bit slower(in milliseconds), which is obvious as there are so many functions and calculations, but in batch I don't think we can get better than that.
I have edited a few lines in you script like directly using the output of cmdwiz in for loop by using singlequote.
Thanks anyway it's a great solution. As for cmdgfx I think that's a great tool to add some animation into my game but it would take some time to learn.(It seemed complex on the first look but cool enough to give it a shot
)
Re: Mouse Hovering in Batch
Posted: 20 Dec 2016 03:48
by misol101
There are various ways to speed that script up, like 1. Get rid of goto as much as possible 2. Call gotoxy.exe once instead of twice. This should be a little faster:
Code: Select all
@echo off
setlocal ENABLEDELAYEDEXPANSION
cmdwiz showcursor 0
cmdwiz getquickedit & set QE=!errorlevel!
cmdwiz setquickedit 0
cls
type %~n0.bat
set /a MX=-100, MY=-100
:LOOP
for /L %%1 in (1,1,300) do if not defined STOP (
cmdwiz getch_and_mouse>mouse_out.txt
for /F "tokens=1,3,5,7,9,11,13,15,17,19,21 delims= " %%a in (mouse_out.txt) do set EVENT=%%a&set KEY=%%b&set MOUSE_EVENT=%%c&set NEW_MX=%%d&set NEW_MY=%%e&set LMB=%%f
if "!MOUSE_EVENT!"=="1" (
set /a OR=0& (if !NEW_MX! neq !MX! set OR=1) & (if !NEW_MY! neq !MY! set OR=1) & if !OR!==1 (
gotoxy !MX! !MY! "\xX\G\p!NEW_MX!;!NEW_MY!;\G" f f
set /a MX=!NEW_MX!, MY=!NEW_MY!
)
)
if !KEY! == 27 set STOP=1
)
if not defined STOP goto LOOP
del /Q mouse_out.txt>nul
cmdwiz setquickedit %QE%
endlocal
cmdwiz showcursor 1
As for cmdgfx, yes I understand it can seem itimidating at first.
But actually, as long as you stay away from the operations "3d" and non-basic use of "block" I would say it is actually pretty straight forward. Start with "gfxtest.bat" in the archive.
Re: Mouse Hovering in Batch
Posted: 20 Dec 2016 11:56
by Sounak@9434
Yeah cmdgfx is not that much tough as it seems to be. I am currently using the gfxtest.bat(and trying to create some new). That's a pretty great tool indeed for graphics. Hope i can move onto 3d and stuff after learning the basics.
Re: Mouse Hovering in Batch
Posted: 21 Dec 2016 00:56
by Sounak@9434
@misol101
I don't know what problem is happening but even when the script is started with "
@echo off" though in cmd window it is typing the whole source. Here is a screenshot of my problem.
Re: Mouse Hovering in Batch
Posted: 21 Dec 2016 02:07
by misol101
Sounak: Hehe, that is by design, I just wanted to have some text in the background.
Remove this line:
type %~n0.bat
And if you don't want to clear the screen, also remove this line:
cls
Re: Mouse Hovering in Batch
Posted: 21 Dec 2016 02:37
by Sounak@9434
@misol101
Oops. Sorry. Didn't noticed the 'type %~n0.bat'.
%~n0.bat expands to the file name(in my case mouse.bat) and type types that.
Sorry for bothering for such a stupid question.
Re: Mouse Hovering in Batch
Posted: 21 Dec 2016 19:17
by Aacini
Sounak@9434 wrote:Mouse Hovering in Batch. So is there any batch mouse supporting utility that supports mouse hovering fast and also has a keyboard support?
The first time I read this request I had a problem somewhat difficult to explain.
I am not a native English speaker and sometimes I don't understand certain apparently common terms. In these cases I consult my Casio EX-word translator, but the translation of "Hover" verb provided by the Oxford English-Spanish dictionary indicated the action of an "helicopter", and not any computer-related term. I looked for "Hovering" in Google and apparently I got it: this term refers to the effect of change the text
inside a selection box when the mouse pointer pass over the selection box! Then, in order to see an example of the desired effect, I reviewed the other application mentioned here:
misol101 wrote:Yeah, cmdwiz can do that
Sounak@9434 wrote:Well, Cmdwiz meets almost all my needs.
However, at this point I was confused again: cmdwiz application does
not have any means to define
selection boxes!. How such an application "supports mouse hovering" if it does not support selection boxes?
Finally, I understood the puzzling point: you may write a Batch file that repeatedly review the position of the mouse pointer via an application designed to do so, and as soon as the mouse enters to a certain zone, you
manually change the text in such a zone to other color. You may use
any method to show the text in other color (even FINDSTR) as long as the mouse pointer enters and leaves the zone at a speed suitable for the show-text-in-color method. However, the possibility of write
this Batch file using a certain auxiliary program that returns the mouse pointer position certainly does
NOT means that the mouse supporting utility "supports mouse hovering"!
I added mouse hovering support to GetInput.exe auxiliary program. I invite you to review the description of this new feature at
this post.
Antonio