hi,
I am working with a ICA32 citrix client from windows xp, where I
am trying to use some automation through citrix client so that I can
unmann a tedious file-copy through one of the published apps (Windows
Explorer). I've tried it through VB and found out that SendKeys wont
work with Citrix, so I switched to VC. With some googling this is where
I've reached.
void ReallySetForegr oundWindow( HWND hWnd )
{
DWORD foregroundThrea dID; // foreground window thread
DWORD ourThreadID; // our active thread
// If the window is in a minimized state, maximize now
if (GetWindowLong( hWnd, GWL_STYLE) & WS_MINIMIZE)
{
ShowWindow(hWnd , SW_MAXIMIZE);
UpdateWindow(hW nd);
}
// Check to see if we are the foreground thread
foregroundThrea dID = GetWindowThread ProcessId(GetFo regroundWindow( ),
NULL);
ourThreadID = GetCurrentThrea dId();
// If not, attach our thread's 'input' to the foreground thread's
if (foregroundThre adID != ourThreadID)
AttachThreadInp ut(foregroundTh readID, ourThreadID, TRUE);
// Bring our window to the foreground
SetForegroundWi ndow(hWnd);
//if we attached our thread, detach it now
if (foregroundThre adID != ourThreadID)
AttachThreadInp ut(foregroundTh readID, ourThreadID, FALSE);
// Force our window to redraw
InvalidateRect( hWnd, NULL, TRUE);
}
I am using an .ICA file which has a predefined credentials so that
login is automated, but before I log in to Citrix, there is a network
login-warning message that pops up and I need to hit an ENTER here
programmaticall y. So, I am trying to bring the small dialog to the
front and send it a VK_RETURN with some code like this:
Sleep(2000);
PostMessage(hWn d, WM_KEYDOWN, VK_RETURN, 0x8001);
PostMessage(hWn d, WM_KEYUP, VK_RETURN, 0xc001);
however, this doesnt happen coz the dialog box never activates! I can
see that the application is set to the foreground but the window to
which ENTER has to be sent looks inactive!! It really doesnt make any
sense as the HWND obtained thru spy++ is exactly the one I am passing
to this function.
can anyone please throw some light on to why this could happen? Am I
doing something wrong?