Cmdwiz - 54 operation cmd helper tool (now with Unicode)
Moderator: DosItHelp
Re: Cmdwiz - cmd helper tools
Archive was updated after some bug fixes and addons.
1. InspectBlock did not return -1 on error, now fixed
2. Operation showcursor now returns the previous state of the cursor, so 0 if it was off, or 1-100 (the show percentage) if it was on.
3. Bug in print operation fixed. If using % in the string, things could go very bad...
4. Also for print operation, it now accepts \" to print a ".
5. Operations setwindowpos and setmousecursorpos now accepts "keep"(or short, "k") as x and/or y coordinate, meaning keep current position.
6. New operation "gettitle" was added. It prints the title of the current window to stdout. I added it as 10.5 above, see description there.
No Unicode yet.
1. InspectBlock did not return -1 on error, now fixed
2. Operation showcursor now returns the previous state of the cursor, so 0 if it was off, or 1-100 (the show percentage) if it was on.
3. Bug in print operation fixed. If using % in the string, things could go very bad...
4. Also for print operation, it now accepts \" to print a ".
5. Operations setwindowpos and setmousecursorpos now accepts "keep"(or short, "k") as x and/or y coordinate, meaning keep current position.
6. New operation "gettitle" was added. It prints the title of the current window to stdout. I added it as 10.5 above, see description there.
No Unicode yet.
Re: Cmdwiz - cmd helper tools
this and the cmdgfx is amazing tools to make some games
thanks
thanks
Re: Cmdwiz - cmd helper tools
Thanks, happy to hear that
Let me know if you finish some games, would be nice to see!
There are a few games included in the cmdgfx/gotoxy archives to look at as well, but you have probably already seen that.
Let me know if you finish some games, would be nice to see!
There are a few games included in the cmdgfx/gotoxy archives to look at as well, but you have probably already seen that.
-
- Posts: 100
- Joined: 16 Dec 2016 22:31
Re: Cmdwiz - cmd helper tools
A request from me.
Could you possibly remove all the helping text from the tool? (which appears on cmdwiz operation /? or cmdwiz /?)
I think it would lower down the file size significantly and make it more usable. You can add a readme.txt file with the download to explain the features.
Could you possibly remove all the helping text from the tool? (which appears on cmdwiz operation /? or cmdwiz /?)
I think it would lower down the file size significantly and make it more usable. You can add a readme.txt file with the download to explain the features.
Re: Cmdwiz - cmd helper tools
Of course the help text will increase the size of the tool (the same size as the text has) but it will not decrease the performance of the tool in a manner as you may think. In the attachment are 2 "Hello World" programs. In the first is also a dummy text of 5.5 KB included that you can see if you open it in a text editor. Just try ...
A useful help message is rather a matter of usability and comfort in my opinion. I would never remove it (but that's misol101's decision).
Steffen
A useful help message is rather a matter of usability and comfort in my opinion. I would never remove it (but that's misol101's decision).
Steffen
- Attachments
-
- test.zip
- (10.91 KiB) Downloaded 1271 times
Re: Cmdwiz - cmd helper tools
I'm with aGerman on this one, I don't think it would have the effect (make it more usable(?)) that you would like (is it more speed you are thinking of?). Also I like the fact that the info can be retrieved without looking at a separate file.
aGerman: I generally agree that file size doesn't matter for speed, what does matter though is the compiler used and how much overhead it adds to the program startup. I must regretfully admit that some quick tests shows that Aacini's "GetKey.exe /n" is "much faster" than "cmdwiz getch noWait" ("much faster" in this context means a few milliseconds, which only matters if you do stuff like animated graphics).
They do essentially exactly the same thing, so I think the difference in speed is due to the overhead added by gcc, and also due to linking libraries like user32, winmm, gdi32 needed for other operations), whereas GetKey has very little overhead and is written in assembler for a very specific purpose.
aGerman: I generally agree that file size doesn't matter for speed, what does matter though is the compiler used and how much overhead it adds to the program startup. I must regretfully admit that some quick tests shows that Aacini's "GetKey.exe /n" is "much faster" than "cmdwiz getch noWait" ("much faster" in this context means a few milliseconds, which only matters if you do stuff like animated graphics).
They do essentially exactly the same thing, so I think the difference in speed is due to the overhead added by gcc, and also due to linking libraries like user32, winmm, gdi32 needed for other operations), whereas GetKey has very little overhead and is written in assembler for a very specific purpose.
Re: Cmdwiz - cmd helper tools
Overhead may be a problem of any compiled language. Only Assembly doesn't need a compiler for the translation into machine code.
Never mind. We are talking about string literals. Loading them into memory doesn't noticeably decrease the performance of a utility. Scheduling the process by the operating system takes much longer.
Steffen
Never mind. We are talking about string literals. Loading them into memory doesn't noticeably decrease the performance of a utility. Scheduling the process by the operating system takes much longer.
Steffen
-
- Posts: 100
- Joined: 16 Dec 2016 22:31
Re: Cmdwiz - cmd helper tools
@misol101
I am not saying about speed or stuff but usually batch files are meant to be small. If there are games or other stuff to be made I think the size really matters. Though 74.4 KB is not much but still. It's obviously upto you.
You can just create or add a secondary file in the zip in which no help text is added, you don't need to remove the real one at all.
But all in all it's upto you what to do.
I am not saying about speed or stuff but usually batch files are meant to be small. If there are games or other stuff to be made I think the size really matters. Though 74.4 KB is not much but still. It's obviously upto you.
You can just create or add a secondary file in the zip in which no help text is added, you don't need to remove the real one at all.
But all in all it's upto you what to do.
Re: Cmdwiz - cmd helper tools
Archive and repo update (http://www.mediafire.com/download/8xywdi36hca4dgo/gotoxy.zip).
The following was done:
1. setfont operation now works for Win10
2. Support bitwise operations for the insertbmp operation. It's now e.g. possible to "fake" transparency (see 10.1 above)
3. moveblock operation can now specify a character/color to fill in the area where the block moved from (see 9.2)
4. New operation: gxyinfo. This is used to print out the dimensions of a gxy/txt file, plus give additional info (see 10.6)
5. The insertbmp and saveblock operations now return negative values on error, to make them consistent with the other operations (10.1, 9.3)
6. New operations: getwindowstyle/setwindowstyle. These are used to get/set properties of the console window. It's pretty complicated to use and I will only briefly document it, but it's there to use anyway (see 1.7 and 1.8 )
The following was done:
1. setfont operation now works for Win10
2. Support bitwise operations for the insertbmp operation. It's now e.g. possible to "fake" transparency (see 10.1 above)
3. moveblock operation can now specify a character/color to fill in the area where the block moved from (see 9.2)
4. New operation: gxyinfo. This is used to print out the dimensions of a gxy/txt file, plus give additional info (see 10.6)
5. The insertbmp and saveblock operations now return negative values on error, to make them consistent with the other operations (10.1, 9.3)
6. New operations: getwindowstyle/setwindowstyle. These are used to get/set properties of the console window. It's pretty complicated to use and I will only briefly document it, but it's there to use anyway (see 1.7 and 1.8 )
Re: Cmdwiz - cmd helper tools
Another update (same link).
Changes:
1. New operations: setpalette/getpalette. As the names suggest they are used to get or set the color palette used by the current cmd window (see 1.9 and 1.10 above)
2. New operation: showmousecursor. Used to disable or enable showing the mouse cursor over the cmd window (see 8.3). Thanks to carlos for the code which is from the fscreen program
3. get/setwindowstyle: now accepts 0x in front of value so these can be copied straight from the Microsoft page(s) (see 1.7 and 1.8 )
4. (hopefully) all operations now return a negative Errorlevel value (usually -1) if an error occured
Changes:
1. New operations: setpalette/getpalette. As the names suggest they are used to get or set the color palette used by the current cmd window (see 1.9 and 1.10 above)
2. New operation: showmousecursor. Used to disable or enable showing the mouse cursor over the cmd window (see 8.3). Thanks to carlos for the code which is from the fscreen program
3. get/setwindowstyle: now accepts 0x in front of value so these can be copied straight from the Microsoft page(s) (see 1.7 and 1.8 )
4. (hopefully) all operations now return a negative Errorlevel value (usually -1) if an error occured
Re: Cmdwiz - cmd helper tools
Version 1.0 release!
Archive was updated, see first post for link.
What's new?
1. Unicode support! Yes, Steffen only had to wait almost 2 years for his feature request to be implemented Sorry about that. More about Unicode and versions below
2. This version is officially called 1.0, which can be seen if starting cmdwiz without arguments or with /?
3. Some operations were previously not working if stdin and/or stdout were in use (typically, if running inside a pipe, for example with cmdgfx_input as stdin and cmdgfx as stdout). This is now fixed.
4. New operation: fullscreen (see 1.11 above). Used to set fullscreen on/off for the console window
5. New operation: showwindow (see 1.12). Used to minimize/maximize/restore etc the console window
6. Topmost argument added for setwindowpos (see 1.5). Used to make the console a topmost window (i.e. always on top of other windows)
7. ReportFailedOpen argument added for cache operation (see 10.4). Used if you want an error message printed for each file in the cache list that could not be opened
8. File size cut down about 35kb due to using "strip" on the binary
About Unicode support:
Cmdwiz.exe is the new Unicode enabled version. I'm fairly confident it works for all operations, but just to be on the safe side there is also cmdwiz-ascii.exe included in the archive, which is the legacy version without Unicode support.
So what does it mean Cmdwiz now supports Unicode?
1. For all operations that read or write a file, the file name can now include Unicode characters. These operations are: saveblock, playsound, getexetype, cache, insertbmp, savefont, setfont, gxyinfo
2. For operations that writes user decided output to stdout, they will now print Unicode characters (provided of course that the font used has the character). These operations are: print, gettitle
3. String operations stringlen and stringfind now accept Unicode as well
4. The file used by the cache operation can now contain file names with Unicode characters. The cache file can be saved as either Utf-8, Utf-8 BOM, Utf-16 LE, or Ansi (OEM or Windows codepage). If this sounds like overkill for such an obscure operation as "cache", then you are correct, but I used it for educating myself. Beware though, Utf-16 BE is not supported!
What is *not* Unicode?
1. The saveblock operation support saving the file with Unicode characters in the filename. However, the block saved does NOT preserve any Unicode characters. The gxy file format does not even support coding characters above 0xff at the moment, so there is no point. Also note that it is not actually recommended to save a gxy file with Unicode characters in the filename, because cmdgfx will not even be able to read it (gotoxy will, partly).
2. I might be wrong about this, but a more general problem seems to be that for Unicode command line arguments to a C program in general, you can support either Utf-8 or Utf-16, but not both, because there is no way to know which one is coming in. Utf-16 is standard on Windows (and is what I use), but there are some situations where this is not true (I can provide an example, but I don't want to get too long-winded).
Archive was updated, see first post for link.
What's new?
1. Unicode support! Yes, Steffen only had to wait almost 2 years for his feature request to be implemented Sorry about that. More about Unicode and versions below
2. This version is officially called 1.0, which can be seen if starting cmdwiz without arguments or with /?
3. Some operations were previously not working if stdin and/or stdout were in use (typically, if running inside a pipe, for example with cmdgfx_input as stdin and cmdgfx as stdout). This is now fixed.
4. New operation: fullscreen (see 1.11 above). Used to set fullscreen on/off for the console window
5. New operation: showwindow (see 1.12). Used to minimize/maximize/restore etc the console window
6. Topmost argument added for setwindowpos (see 1.5). Used to make the console a topmost window (i.e. always on top of other windows)
7. ReportFailedOpen argument added for cache operation (see 10.4). Used if you want an error message printed for each file in the cache list that could not be opened
8. File size cut down about 35kb due to using "strip" on the binary
About Unicode support:
Cmdwiz.exe is the new Unicode enabled version. I'm fairly confident it works for all operations, but just to be on the safe side there is also cmdwiz-ascii.exe included in the archive, which is the legacy version without Unicode support.
So what does it mean Cmdwiz now supports Unicode?
1. For all operations that read or write a file, the file name can now include Unicode characters. These operations are: saveblock, playsound, getexetype, cache, insertbmp, savefont, setfont, gxyinfo
2. For operations that writes user decided output to stdout, they will now print Unicode characters (provided of course that the font used has the character). These operations are: print, gettitle
3. String operations stringlen and stringfind now accept Unicode as well
4. The file used by the cache operation can now contain file names with Unicode characters. The cache file can be saved as either Utf-8, Utf-8 BOM, Utf-16 LE, or Ansi (OEM or Windows codepage). If this sounds like overkill for such an obscure operation as "cache", then you are correct, but I used it for educating myself. Beware though, Utf-16 BE is not supported!
What is *not* Unicode?
1. The saveblock operation support saving the file with Unicode characters in the filename. However, the block saved does NOT preserve any Unicode characters. The gxy file format does not even support coding characters above 0xff at the moment, so there is no point. Also note that it is not actually recommended to save a gxy file with Unicode characters in the filename, because cmdgfx will not even be able to read it (gotoxy will, partly).
2. I might be wrong about this, but a more general problem seems to be that for Unicode command line arguments to a C program in general, you can support either Utf-8 or Utf-16, but not both, because there is no way to know which one is coming in. Utf-16 is standard on Windows (and is what I use), but there are some situations where this is not true (I can provide an example, but I don't want to get too long-winded).
Re: Cmdwiz - cmd helper tools
Don't worry about that. I was quite sure you would implemt this feature sooner or later
You would need to make some efforts to support both but it's actually not worth it (first check the char* arguments character by character whether they contain multibyte UTF-8 characters). It may sound weird but even ASCII parameters are passed to the program UTF-16-encoded. The C-implementation is narrowing them down to ANSI again. So your best bet is to use the wmain() entry point using Visual Studio or the __wgetmainargs() function for any other compiler. Passing a UTF-16 file name to the program is the real problem since you might not be able to have it hard-coded in a batch file. You would need ugly workarounds using a FOR loop with an asterisk or question mark as search pattern, then pass the FOR variable (which is able to contain the Unicode file name). Parameter variables are also possible where you need to drag/drop the file to the script.misol101 wrote: ↑09 Jul 2018 11:19I might be wrong about this, but a more general problem seems to be that for Unicode command line arguments to a C program in general, you can support either Utf-8 or Utf-16, but not both, because there is no way to know which one is coming in. Utf-16 is standard on Windows (and is what I use), but there are some situations where this is not true (I can provide an example, but I don't want to get too long-winded).
Steffen
Re: Cmdwiz - cmd helper tools (now with Unicode)
Here is version 1.1 of Cmdwiz (see updated archive link in first post)
What's new?
1. showwindow: Added options to make the window topmost, top, or bottom. Also added close in order to close the window. Topmost option was removed from setwindowpos operation. (see 1.12 above)
2. New operation: sendkey. As the name suggests, it can be used to simulate keyboard input (see 8.4)
3. The fullscreen operation now uses official Windows API SetConsoleDisplayMode, which is 100% fullscreen. The old method can still be used with the legacy argument. Legacy mode is also used automatically if new API fails (1.11)
4. setmousecursorpos now also supports middle button click, plus mouse wheel and horizontal mouse wheel (8.2)
5. setbuffersize now supports using - as argument to remove vertical and/or horizontal scrollbar (1.2)
6. gettitle operation now has a strip argument to attempt removal of last part of the title (10.5)
7. getkeystate operation now accepts 0x before virtual key values to allow straight copying from Microsoft's website (2.2)
8. Fixed a bug where using setwindowpos after setwindowstyle in some cases caused graphical artifacts
What's new?
1. showwindow: Added options to make the window topmost, top, or bottom. Also added close in order to close the window. Topmost option was removed from setwindowpos operation. (see 1.12 above)
2. New operation: sendkey. As the name suggests, it can be used to simulate keyboard input (see 8.4)
3. The fullscreen operation now uses official Windows API SetConsoleDisplayMode, which is 100% fullscreen. The old method can still be used with the legacy argument. Legacy mode is also used automatically if new API fails (1.11)
4. setmousecursorpos now also supports middle button click, plus mouse wheel and horizontal mouse wheel (8.2)
5. setbuffersize now supports using - as argument to remove vertical and/or horizontal scrollbar (1.2)
6. gettitle operation now has a strip argument to attempt removal of last part of the title (10.5)
7. getkeystate operation now accepts 0x before virtual key values to allow straight copying from Microsoft's website (2.2)
8. Fixed a bug where using setwindowpos after setwindowstyle in some cases caused graphical artifacts
Re: Cmdwiz - cmd helper tools (now with Unicode)
Version 1.2 of CmdWiz is out (usual link at the top or get the repo).
This version is something of a game changer, as it allows all window operations to be used not only for the cmd window, but for any currently open window!
Big thanks to Steffen, whose code for enumerating/finding windows I reused (with permission) with a few modifications.
These operations are available for all windows: setwindowpos, setwindowsize, getwindowbounds, setwindowtransparency, showwindow, getwindowstyle, setwindowstyle, insertbmp
To get available windows,use the new windowlist operation.
Essentially, this means that cmdwiz can now be used as a general automation tool for Windows, especially when combining the above operations with the sendkey and setmousecursorpos operations. Granted, there are more powerful alternatives like AutoHotkey, but not that can be easily integrated with Batch (I think).
I will document the new operations and usage of finding windows soon. In the meantime, here is a little example automation script, which does the following: closes down existing notepad.exe instances, opens a new one, wait for it to pop up, puts the window on top, changes its size, centers it on the desktop, writes text to the document, sets the window transparency, injects a bitmap image (if available) into the document, moves the window around randomly, selects and deletes the text and image, writes some more text and then quits
This version is something of a game changer, as it allows all window operations to be used not only for the cmd window, but for any currently open window!
Big thanks to Steffen, whose code for enumerating/finding windows I reused (with permission) with a few modifications.
These operations are available for all windows: setwindowpos, setwindowsize, getwindowbounds, setwindowtransparency, showwindow, getwindowstyle, setwindowstyle, insertbmp
To get available windows,use the new windowlist operation.
Essentially, this means that cmdwiz can now be used as a general automation tool for Windows, especially when combining the above operations with the sendkey and setmousecursorpos operations. Granted, there are more powerful alternatives like AutoHotkey, but not that can be easily integrated with Batch (I think).
I will document the new operations and usage of finding windows soon. In the meantime, here is a little example automation script, which does the following: closes down existing notepad.exe instances, opens a new one, wait for it to pop up, puts the window on top, changes its size, centers it on the desktop, writes text to the document, sets the window transparency, injects a bitmap image (if available) into the document, moves the window around randomly, selects and deletes the text and image, writes some more text and then quits
Code: Select all
@echo off
setlocal EnableDelayedExpansion
taskkill /F /IM notepad.exe >nul 2>nul
call :WAITWIN notepad.exe 1
start notepad.exe
call :WAITWIN notepad.exe 0
cmdwiz showwindow top /N:notepad.exe
cmdwiz setwindowsize 600 480 /N:notepad.exe
cmdwiz getdisplaydim w & set SW=!errorlevel!
cmdwiz getdisplaydim h & set SH=!errorlevel!
cmdwiz getwindowbounds w /N:notepad.exe & set WINW=!errorlevel!
cmdwiz getwindowbounds h /N:notepad.exe & set WINH=!errorlevel!
set /a WPX=%SW%/2-%WINW%/2,WPY=%SH%/2-%WINH%/2
cmdwiz setwindowpos %WPX% %WPY% /N:notepad.exe
cmdwiz delay 500
cmdwiz sendkey 0x10 d & cmdwiz sendkey 0x48 p & cmdwiz sendkey 0x10 u
for %%a in (0x45 0x4C 0x4C 0x4F 0x20 0x57 0x4f 0x52 0x4c 0x44) do cmdwiz sendkey %%a p
cmdwiz sendkey 0x10 d & cmdwiz sendkey 0x31 p & cmdwiz sendkey 0x10 u
cmdwiz delay 1000
cmdwiz setwindowtransparency 10 /N:notepad.exe
cmdwiz delay 1000
if exist gotoxy-examples\123.bmp cmdwiz insertbmp gotoxy-examples\123.bmp 10 50 100 /N:notepad.exe
cmdwiz delay 1000
set /a TIMES=30
:MOVERANDOMLOOP
set /a "X=(!RANDOM! %% %SW%) - 300, Y=(!RANDOM! %% %SH%) - 240, TIMES-=1"
cmdwiz setwindowpos %X% %Y% /N:notepad.exe
cmdwiz delay 100
if %TIMES% gtr 0 goto :MOVERANDOMLOOP
cmdwiz setwindowpos %WPX% %WPY% /N:notepad.exe
cmdwiz delay 1000
cmdwiz sendkey 0x11 d & cmdwiz sendkey 0x41 p & cmdwiz sendkey 0x11 u
cmdwiz delay 1000
cmdwiz sendkey 0x08 p
cmdwiz delay 1000
cmdwiz sendkey 0x10 d & cmdwiz sendkey 0x42 p & cmdwiz sendkey 0x10 u
for %%a in (0x59 0x45 0xbe 0xbe 0xbe) do cmdwiz sendkey %%a p
cmdwiz delay 1000
taskkill /F /IM notepad.exe >nul 2>nul
endlocal
goto :eof
:WAITWIN <procName> <findVal>
cmdwiz windowlist | find "%1">nul
if %errorlevel% neq %2 goto :WAITWIN
Re: Cmdwiz - cmd helper tools (now with Unicode)
By the way, Steffen and Carlos are now mentioned in both the in-program help text and the source code for CmdWiz, since I have used code snippets from both of you for some of the operations.
Please let me know if you for whatever reason prefer not to be mentioned, or prefer to be mentioned by your alias only, or similar.
Thank you again.
Please let me know if you for whatever reason prefer not to be mentioned, or prefer to be mentioned by your alias only, or similar.
Thank you again.