Take Command Console WinAPI Functions

Take Command Console WinAPI Functions

Back To TCC Table of Contents



Back To TCC Table of Contents


CloseClipboard

CloseClipboard=`%@winapi[user32.dll,CloseClipboard,0]`

Example:

echo %@winapi[user32.dll,CloseClipboard,0]
1

If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.

Top Of Page


EnumClipboardFormats

set uFormat=`%@winapi[user32.dll,EnumClipboardFormats,%uFormat]`

Examples:

:clipistext
if %@winapi[user32.dll,OpenClipboard,0] LE 0 return -1
set rv=0
set uFormat=0
do until %uFormat == 0
    set uFormat=%@winapi[user32.dll,EnumClipboardFormats,%uFormat]
    if %uFormat == 1 .or. %uFormat == 7 .or. %uFormat == 13 (set rv=1 & leave)
enddo
set junk=%@winapi[user32.dll,CloseClipboard]
return %rv

More details on the JPSoft Forum: Detect Clipboard Format

Top Of Page


FindWindowClass

FindWindowClass=`%@winapi[user32,FindWindow,"%$",0]`

Examples:

echo %@FindWindowClass[Shell_TrayWnd]
65690

echo %@FindWindowClass[Notepad]
1379358

echo %@FindWindowClass[Progman]
65818

Top Of Page


FindWindowTitle

FindWindowTitle=`%@winapi[user32,FindWindow,0,"%$"]`

Examples:

echo %@FindWindowTitle[Untitled - Notepad]
1379358

echo %@FindWindowTitle[Admin: Take Command Console]
394834

echo %@FindWindowTitle[%_winfgwindow]
394834

echo %@findwindowtitle[%_wintitle]
394834

echo %@findwindowtitle[Start]
65938

Top Of Page


GetCurrentProcessID

GetCurrentProcessID=`%@winapi[kernel32.dll,GetCurrentProcessId]`

Example:

echo %@GetCurrentProcessID[]
14640

echo %_pid
14640

Top Of Page


GetForegroundWindow

GetForegroundWindow=`%@winapi[user32.dll,GetForegroundWindow]`

Example:

echo %@GetForegroundWindow[]
394834

GetSystemMenu

GetSystemMenu=`%@winapi[user32.dll,GetSystemMenu,%1,0]`

Examples:

set hWnd=%@GetForegroundWindow[]
echo %hwnd
394834

echo %@GetSystemMenu[%hwnd]
198257

Top Of Page


IsWindow

IsWindow=`%@winapi[user32.dll,IsWindow,%1]`

Example:

set fgWnd=%@getforegroundwindow[]
echo %@IsWindow[%fgWnd]
1

Top Of Page


OpenClipboard

OpenClipboard=`%@winapi[user32.dll,OpenClipboard,0]`

Example:

echo %@winapi[user32.dll,OpenClipboard,0]
1

If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero.

Top Of Page


SetEnvironmentVariable

SetEnvironmentVariable=`%@winapi[kernel32.dll,SetEnvironmentVariable,%1,%2]`

Examples:

echo %@setenvironmentvariable["a","10"]
1

set a
10

Top Of Page


StrFormatByteSize

StrFormatByteSize=`%@winapi[shlwapi.dll,StrFormatByteSizeA,%1,aBUFFER,256]`

Examples:

echo %@StrFormatByteSize[1024]
1.00 KB

echo %@StrFormatByteSize[10240]
10.0 KB

echo %@StrFormatByteSize[102400]
100 KB

echo %@StrFormatByteSize[1024000]
0.97 MB

echo %@StrFormatByteSize[10240000]
9.76 MB

Top Of Page