Please enable JavaScript to view this site.

KOL/MCK - User Guide

System Functions and Working with Windows

 

This set of functions rather expands the API than just an adapter, and can be used for a variety of purposes (interaction between windows, including between different applications, identifying any characteristics of the operating system).

 

GetWindowChild(wnd, kind) - allows you to get a child window of this window with the specified characteristics (owning the keyboard input focus, carriage, seizing the mouse in exclusive use or having an activated menu);

GetFocusedChild(wnd) - a subspecies of the previous function, interested only in windows in the input focus;

FindWindowByThreadID(t) - Finds a window belonging to the specified flow of execution of instructions;

 

Stroke2Window(wnd, s) - sends a line to the window in focus, as if the user had typed this line on the keyboard;

Stroke2WindowEx(wnd, s, wait) - the same as the previous function, but allows you to "press" including control keys on the keyboard, such as arrows, page turning, etc .;

 

WindowsShutdown(s, force, reboot) - stops the session / shuts down / reboots the computer;

 

WinVer - returns the Windows version (the TWindowsVersion return type is defined as an ordered list of constants wv31, wv95, wv98, vwME *, wvNT, wvY2K, wvXP, wvVista, wvWin7);

IsWinVer(wv) - checks if the Windows version is one of the specified wv;

 

ExecuteWait(AppPath, CmdLine, DfltDirectory, Show, TimeOut, ProcID) - launches for execution and waits for completion (specified period of time) the specified application;

ExecuteIORedirect(AppPath, CmdLine, DfltDirectory, Show, ProcID, InPipe, OutPipeWr, OutPipeRd) - launches a console application, redirecting its input / output to the specified objects of the pipe type (pipe, literally, a kind of file streams in Windows);

ExecuteConsoleAppIORedirect(const AppPath, CmdLine, DfltDirectory, Show, InStr, OutStr, WaitTimeout) - the same as the previous function, but after the application is launched, the string InStr is "fed" to it, and upon completion, the contents of its console in the OutStr line are read at the output;

 

GetDesktopRect - returns a rectangle on the screen that is free for application windows (excluding, for example, the Windows taskbar, and other panels at the edges of the screen);

GetWorkArea - the same as the previous function, but the result is obtained in a slightly different way, through SystemParametersInfo. For various purposes, it is more correct to use either this function or the previous one. For Windows 7, the GetDesktopRect function is always redirected to the GetworkArea function, for example.

 

Perhaps, in the same section, it is worth adding a couple of functions from KOL.pas, which can be used to control the uniqueness of a running instance of an application (it may be necessary that an application does not allow the user to launch itself repeatedly):

JustOne(wnd, s) - returns true if only the application is launched in a single instance (if at the moment of application launch it is found that such is already among those running, false is returned);

JustOneNotify(wnd, s, onanother) - similar to the previous one, but in addition sets an event handler OnAnotherInstance, which is triggered in the first running application, and when the second is launched, when triggered, the event handler receives as a parameter the command line from which the second (and other) instance (s) of the application was launched. For example, if, when making a text editor at the beginning of work, when the main form is still invisible, make a call:

 

if not JustOneNotify (MainForm.Handle, 'My.Super.Puper.Text.Editor', OnAnotherMyEditor) then

MainForm.Close;

 

then when you restart it, the launch will not take place (the application will not even appear on the screen), and the handler in the first instance of the application will receive information about the command line of the second instance, and can load the requested text into a new tab, for example.

 

KOL / MCK User Guide - Created by Carl Peeraer - Diamant Soft, based on the work of Vladimir Kladov - Artwerp.be

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Nav Header: ALT+n
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Exit Menu/Up: ESC