This job allows get screenshots of all currently open windows in Axapta.
It based on idea published in
How to get list of all open windows and their names in AX
static void JobAllTheWindowsScreenshots(Args _args)
{
#define.screenshotFolder('q:\\capture\\')
hWnd Parent;
hWnd handle;
hWnd mdi;
#WinApi
dialog d = new Dialog();
DialogTabPage dt;
str text;
// retrieves the visibility state of the specified window -->
DLL _DLL = new DLL('USER32');
DLLFunction _isWindowVisible = new DLLFunction(_DLL, 'IsWindowVisible');
// retrieves the visibility state of the specified window <--
container cHWnd;
int i;
void addTab()
{
if(text)
{
dt = d.addTabPage(text);
d.addText(text);
cHWnd+=handle;
}
}
fileName getSaveName(identifiername name)
{
return #screenshotFolder + name + ".bmp";
}
void captureForm()
{
Image image = new Image();
;
// Take a screenshoot of the form
image.captureWindow(handle);
// reduce the colors (bits/pixel)
image.reduceColorOctree(FALSE,256);
// Save it as bitmap
image.saveImage(getSaveName(text), ImageSaveType::BMP_UNCOMP);
}
;
d.caption("All the windows");
d.windowType(FormWindowType::PopUp);
Parent = infolog.hWnd();
mdi = WinApi::getWindow(Parent, #GW_CHILD);
handle = WinApi::getWindow(mdi, #GW_CHILD);
text = WinApi::getWindowText(handle);
addTab();
if(handle)
{
while(handle)
{
handle = WinApi::getWindow(handle, #GW_HWNDNEXT);
text = WinApi::getWindowText(handle);
addTab();
}
}
// retrieves the visibility state of the specified window -->
_isWindowVisible.returns(ExtTypes::DWord);
_isWindowVisible.arg(ExtTypes::DWord);
// retrieves the visibility state of the specified window <--
for(i=1; i<=conlen(cHWnd); i++)
{
handle = conPeek(cHWnd, i);
if( _isWindowVisible.call(handle) )
{
infolog.activateWindow(handle);
WinApi::updateWindow(handle);
text = strFmt('%1 %2', i, strRem(WinApi::getWindowText(handle), '\\/:*?"<>|'));
captureForm();
}
}
d.run();
}
Note #screenshotFolder definition sets the path to the folder where screenshot collection is storing, so you have to adjusting your path on you own.
No comments:
Post a Comment