Other Software > Developer's Corner
Commandline execution VC++ using ShellExec
renjithcr:
Hi i am trying to save a screenshot file to the following path C:\Users\Rn\Desktop\ScreenshotCaptor. But i cant change the screenshot directory.
i used the following link to find the commandline options : https://www.donationcoder.com/Software/Mouser/screenshotcaptor/help/index.html
please find my code below. any help is appreciated.
////////////////////////////// VC++ code //////////////////////////////
CString sApp = _T("C:\\Program Files (x86)\\ScreenshotCaptor\\ScreenshotCaptor.exe");
CString sParameters = _T("-show -capture screen -format png -dir \"C:\\Users\\Rn\\Desktop\\ScreenshotCaptor\" ");
CString sWorkDir = _T("C:\\Users\\Rn\\Desktop\\ScreenshotCaptor");
int nRet = (int)ShellExecute(NULL, NULL, sApp, sParameters, sWorkDir, SW_SHOWNORMAL);
/////////////////////////////////////////////////////////////////////////////
mouser:
For what you are trying to do (commandline screenshot grabbing), may I recommend Screenshot Captor's little brother: MiniCap
It is made to do exactly what you are doing and is built with same codebase as SC.
renjithcr:
Thanks Mouser... it works with ShellExecute()
is there any way to wait until the screen capture is completed? I mean using ShellExecuteEx and WaitForSingleObject functions?
my following code is not working
SHELLEXECUTEINFO ShExecInfo = { 0 };
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = GetMiniCapAppPath().AllocSysString();
ShExecInfo.lpParameters = sParameters.AllocSysString();
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOWNORMAL;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
mouser:
When you say your code isn't working -- specifically what is happening?
renjithcr:
With ShellExecute() i can make a screenshot.
CString sParameters = _T("-save \"") + sImagePath + _T("\" -captureappbyname \"") + sUniNgeExeName + _T("\" -exit");
iRet = (int)ShellExecute(NULL, NULL, GetMiniCapAppPath(), sParameters, NULL, SW_SHOWNORMAL);
but with ShellExecuteEx() and then WaitForSingleObject() as described in my previous post i want to wait until the MiniCap executable exits (using -exit in sParameters). but i see the executable on Task manager. and the function call WaitForSingleObject() waits.
Navigation
[0] Message Index
[#] Next page
Go to full version