Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove commented & dead code, fix typos. Bump version to 1.5.0. diff --git a/VERSION.txt b/VERSION.txt index 5c0d430..8de8338 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -This version of Cmdow is v1.4.8 +This version of Cmdow is v1.5.0 diff --git a/args.cpp b/args.cpp index aa4320d..578a2bb 100644 --- a/args.cpp +++ b/args.cpp @@ -32,7 +32,7 @@ void ParseArgs(int argc, char *argv[], struct ARGS *a) int form2; /* count of form2 options - operation performed on all windows */ int form3; /* count of form3 options - operation performed on selected windows */ int form4; /* count of form4 options - run/open a program/file */ - int form5; /* count of form5 options - rename this console window 7*/ + int form5; /* count of form5 options - rename this console window */ int fcount; /* count of number of forms used */ int exist; /* test window exists (implemented via taskless wait) */ @@ -240,7 +240,7 @@ void ParseArgs(int argc, char *argv[], struct ARGS *a) if(form2) ++fcount; if(form1) ++fcount; - // make sure only one, and only one form has been used + // make sure one, and only one, form has been used if(fcount != 1) Quit(CONARG); if(form5) { @@ -312,14 +312,6 @@ HWND atoHandle(const char *src) else return h; } -int atoCoord(const char *src) -{ - int i; - i = 0; atoi(src); - return i; -} - - char *LoadString(char **dest, const char *src) { *dest = (char *) HeapAlloc(GetProcessHeap(), 0, sizeof(char) * (lstrlen(src) + 1)); diff --git a/header.h b/header.h index eca63db..61cbc51 100644 --- a/header.h +++ b/header.h @@ -1,4 +1,3 @@ -//#ifdef _MERGE_RDATA_ #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #define _WIN32_WINNT 0x0500 @@ -7,15 +6,13 @@ #include <stdlib.h> #include <ctype.h> #include <shellapi.h> -#include <winperf.h> -#include <conio.h> // #define WM_CASCADE_WINDOWS (403) #define WM_TILE_HORIZONTALLY (404) #define WM_TILE_VERTICALLY (405) #define WM_MINIMIZE_ALL (415) -#define WM_UNDO_WINDOWS (413) +#define WM_UNDO_WINDOWS (416) // Used by Set/GetConsoleDisplayMode functions #define FULL_SCREEN_MODE 1 @@ -24,7 +21,7 @@ /* Error messages */ #define MEMERR 0 /* Memory allocation failed */ #define MOVERR 1 /* /MOV command requires left and top arguments */ -#define SIZERR 2 /* /SIZ command requires width and height agrguments */ +#define SIZERR 2 /* /SIZ command requires width and height arguments */ #define RENERR 3 /* /REN command requires a new caption to be specified */ #define UNRARG 4 /* Unrecognized argument(s). Use CMDOW /? for help */ #define CONARG 5 /* Conflicting argument(s). Use CMDOW /? for help */ @@ -126,7 +123,6 @@ enum TASK PopTask(enum TASK tasks[]); int IsTask(enum TASK tasks[], enum TASK t); char *LoadString(char **dest, const char *src); HWND atoHandle(const char *); -int atoCoord(const char *); char *GetArgs(); char *GetRestCmdline(char *Cmd); @@ -169,5 +165,3 @@ void RunWin(struct WLIST *w, struct ARGS *a); void TopWin(struct WLIST *w, struct ARGS *a); void NotWin(struct WLIST *w, struct ARGS *a); void SlpWin(struct WLIST *w, struct ARGS *a); - -int __cdecl _ConvertCommandLineToArgcArgv( void ); diff --git a/help.cpp b/help.cpp index 55eb0d0..a5d7d5c 100644 --- a/help.cpp +++ b/help.cpp @@ -288,8 +288,9 @@ printf( } else { printf( - "CMDOW [Version 1.4.8] Win32 Commandline Window Utility for NT4/2000/XP/7.\n" - "(C) Copyright 2001-2014 Ritchie Lawrence, http://www.commandline.co.uk.\n\n" + "CMDOW [Version 1.5.0] Win32 Commandline Window Utility for NT4/2000/XP/7.\n" + "(C) Copyright 2001-2014 Ritchie Lawrence, http://www.commandline.co.uk.\n" + " 2019 Jason Hood, https://github.com/adoxa/cmdow.\n\n" // ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 " CMDOW [window | /T] [/B] [/F] [/P]\n" " CMDOW window /E\n" diff --git a/main.cpp b/main.cpp index 43aebd4..49bdc58 100644 --- a/main.cpp +++ b/main.cpp @@ -36,17 +36,14 @@ int main(int argc, char* argv[]) ShowHelp(args.helpcmd); break; case CW: - //CascadeWindows(NULL, 0, NULL, 0, NULL); hWnd = FindWindow("Shell_TrayWnd", ""); if(hWnd) PostMessage(hWnd, WM_COMMAND, WM_CASCADE_WINDOWS, 0); break; case TV: // tile vertically - //TileWindows(NULL, MDITILE_VERTICAL, NULL, 0, NULL); hWnd = FindWindow("Shell_TrayWnd", ""); if(hWnd) PostMessage(hWnd, WM_COMMAND, WM_TILE_VERTICALLY, 0); break; case TH: // tile horizontally - //TileWindows(NULL, MDITILE_HORIZONTAL, NULL, 0, NULL); hWnd = FindWindow("Shell_TrayWnd", ""); if(hWnd) PostMessage(hWnd, WM_COMMAND, WM_TILE_HORIZONTALLY, 0); break; @@ -54,21 +51,12 @@ int main(int argc, char* argv[]) AltTab(); break; case MA: // minimize all - //keybd_event(VK_LWIN, 0, 0, 0); - //keybd_event(77, 0, 0, 0); // 77 is 'M' - //keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0); hWnd = FindWindow("Shell_TrayWnd", ""); if(hWnd) PostMessage(hWnd, WM_COMMAND, WM_MINIMIZE_ALL, 0); break; case UW: // undo minimize all - //keybd_event(VK_LWIN, 0, 0, 0); - //keybd_event(VK_SHIFT, 0, 0, 0); - //keybd_event(77, 0, 0, 0); - //keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0); - //keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0); - //break; hWnd = FindWindow("Shell_TrayWnd", ""); - if(hWnd) PostMessage(hWnd, WM_COMMAND, 416, 0); + if(hWnd) PostMessage(hWnd, WM_COMMAND, WM_UNDO_WINDOWS, 0); break; case WM: // switch to window mode res = WINDOW_MODE; diff --git a/wlist.cpp b/wlist.cpp index cbbe58e..1d2b9d4 100644 --- a/wlist.cpp +++ b/wlist.cpp @@ -138,7 +138,7 @@ BOOL GetWindowInf(HWND hwnd, struct WLIST *w) w->parent = parent = GetParent(hwnd); // - // determine windows' level. 0=desktop, 1=toplevel, 2+ = child + // determine window's level. 0=desktop, 1=toplevel, 2+ = child // if(hwnd == desktop) w->level = 0; else if( (parent == w->owner) || (parent == desktop) ) w->level = 1; @@ -151,7 +151,7 @@ BOOL GetWindowInf(HWND hwnd, struct WLIST *w) } // - // Get windows' coords and determine width and height + // Get window's coords and determine width and height // GetWindowRect(hwnd, &rect); w->left = rect.left; @@ -315,7 +315,7 @@ void LstWin(struct WLIST *w, struct ARGS *a) // // Notes: I couldn't find any documentation on this but it appears a window is // shown on the taskbar if: - -// > its not hidden AND +// > it's not hidden AND // > does not have WS_EX_TOOLWINDOW style AND // > does not have an owner AND // > is level 1 @@ -407,7 +407,7 @@ void ResWin(struct WLIST *w, struct ARGS *a) } // -// Activate the window, if window is hidden, it gets focus but stays hidden, +// Activate the window, if window is hidden, it gets focus but stays hidden // void ActWin(struct WLIST *w, struct ARGS *a) { @@ -425,7 +425,6 @@ void InaWin(struct WLIST *w, struct ARGS *a) if(w->hwnd == GetForegroundWindow()) AltTab(); } - // // Enable window // @@ -459,7 +458,7 @@ void VisWin(struct WLIST *w, struct ARGS *a) } // -// politely ask the window to close +// Politely ask the window to close // void ClsWin(struct WLIST *w, struct ARGS *a) { @@ -467,24 +466,16 @@ void ClsWin(struct WLIST *w, struct ARGS *a) } // -// End process associated with window (all windows with same Pid are killed!!! +// End process associated with window (all windows with same Pid are killed!!!) // void EndWin(struct WLIST *w, struct ARGS *a) { HANDLE hProcess; - hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, w->pid); - if (hProcess) { - hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, w->pid); - if (hProcess == NULL) { - return; - } - if(!TerminateProcess(hProcess, 1)) { - CloseHandle(hProcess); - return; - } + hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, w->pid); + if(hProcess) { + TerminateProcess(hProcess, 1); CloseHandle(hProcess); - return; } } @@ -568,7 +559,7 @@ void RenWin(struct WLIST *w, struct ARGS *a) // // Retrieve the bounding rectangle of a window: the monitor's work area for a -// top-level window; otherwise the parent's client area. +// top-level window; otherwise the parent's client area // void GetBounds(struct WLIST *w, RECT &r) { @@ -628,40 +619,6 @@ void RunWin(struct WLIST *w, struct ARGS *a) { #define SHELLEXEC_SUCCESS 33 int RetVal; - // FindExecutable() Retrieves the name of and handle to the executable (.exe) file associated with the specified file name - /*STARTUPINFO si; - PROCESS_INFORMATION pi; - char buf[1024]; - HMODULE hModule; - - - hModule = GetModuleHandle(a->cmdline); - GetModuleFileName(hModule, buf, 1024); - - FindExecutable(a->cmdline, NULL, buf); - - - ZeroMemory(&si, sizeof(si)); - - //si.dwFlags = STARTF_USESHOWWINDOW; - //si.wShowWindow = SW_HIDE; - si.lpTitle = "Rascal"; - - CreateProcess( - NULL, // appname - a->cmdline, // cmdline - NULL, // process security attribs - NULL, // thread security attribs - TRUE, // inherit handles - 0, // creation flags - NULL, // new environment block - NULL, // current directory name - &si, // startupinfo - &pi // processinfo - ); - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread);*/ -// printf("file [%s], params [%s]\n", a->file, a->params); RetVal = (int) ShellExecute(NULL, NULL, a->file, a->params, NULL, a->sw_state); if(RetVal < SHELLEXEC_SUCCESS) Quit(EXEERR); @@ -671,7 +628,7 @@ void RunWin(struct WLIST *w, struct ARGS *a) // Function: AltTab // // Synopsis: Activates taskbar window with the lowest Z order. In the event of -// there being no taskbar windows, the desptop is activated. +// there being no taskbar windows, the desktop is activated. // // Arguments: None // @@ -682,7 +639,7 @@ void RunWin(struct WLIST *w, struct ARGS *a) // the lowest window, this moves to the top of the Z order, and all other // move down one. If this function was to activate the next window in the // Z order, then repeated calls to this function would only alternate -// between two windows (as happens when repeatly pressing [Alt]-[Tab]) +// between two windows (as happens when repeatedly pressing [Alt]-[Tab]) // //---------------------------------------------------------------------------- void AltTab(void) @@ -692,7 +649,7 @@ void AltTab(void) long styles; // // a handle to any toplevel window is required, so may as well use this - // consoles' handle, as guaranteed to exist + // console's handle, as guaranteed to exist // me = GetMyHandle();
- Loading branch information