473,383 Members | 1,855 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Application Activation using VC

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 ReallySetForegroundWindow( HWND hWnd )
{
DWORD foregroundThreadID; // 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(hWnd);
}
// Check to see if we are the foreground thread
foregroundThreadID = GetWindowThreadProcessId(GetForegroundWindow(),
NULL);
ourThreadID = GetCurrentThreadId();
// If not, attach our thread's 'input' to the foreground thread's
if (foregroundThreadID != ourThreadID)
AttachThreadInput(foregroundThreadID, ourThreadID, TRUE);

// Bring our window to the foreground
SetForegroundWindow(hWnd);

//if we attached our thread, detach it now
if (foregroundThreadID != ourThreadID)
AttachThreadInput(foregroundThreadID, 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
programmatically. 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(hWnd, WM_KEYDOWN, VK_RETURN, 0x8001);
PostMessage(hWnd, 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?

Jan 4 '06 #1
3 1659
could this be your problem? (see below)
i had the same problem once, and it was caused by this.

see
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/setforegroundwindow.htm
for more info.

kind regards
Bruno.

With this change, an application cannot force a window to the foreground
while the user is working with another window. Instead, Foreground and
Background Windows will activate the window (see SetActiveWindow) and call
the function to notify the user. However, on Microsoft® Windows® 98 and
Windows Millennium Edition (Windows Me), if a nonforeground thread calls
SetForegroundWindow and passes the handle of a window that was not created
by the calling thread, the window is not flashed on the taskbar. To have
SetForegroundWindow behave the same as it did on Windows 95 and Microsoft
Windows NT® 4.0, change the foreground lock timeout value when the
application is installed. This can be done from the setup or installation
application with the following function call:

SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (LPVOID)0,
SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
This method allows SetForegroundWindow on Windows 98/Windows Me and Windows
2000/Windows XP to behave the same as Windows 95 and Windows NT 4.0,
respectively, for all applications.



"kill.segfault" <ki***********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
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 ReallySetForegroundWindow( HWND hWnd )
{
DWORD foregroundThreadID; // 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(hWnd);
}
// Check to see if we are the foreground thread
foregroundThreadID = GetWindowThreadProcessId(GetForegroundWindow(),
NULL);
ourThreadID = GetCurrentThreadId();
// If not, attach our thread's 'input' to the foreground thread's
if (foregroundThreadID != ourThreadID)
AttachThreadInput(foregroundThreadID, ourThreadID, TRUE);

// Bring our window to the foreground
SetForegroundWindow(hWnd);

//if we attached our thread, detach it now
if (foregroundThreadID != ourThreadID)
AttachThreadInput(foregroundThreadID, 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
programmatically. 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(hWnd, WM_KEYDOWN, VK_RETURN, 0x8001);
PostMessage(hWnd, 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?

Jan 4 '06 #2
Bruno, Thanks for the response. I tried what you said. But, It didnt
work.
The window never gets active!
I've learnt from SPy++ that the class of window is "Transparent Windows
Client"!
I never heard about anything of this sort. Any ideas?

Jan 4 '06 #3
sorry, not for the moment. your situation is different from mine.
should i think of anything else i'll let you know.

kind regards,
Bruno.
"kill.segfault" <ki***********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Bruno, Thanks for the response. I tried what you said. But, It didnt
work.
The window never gets active!
I've learnt from SPy++ that the class of window is "Transparent Windows
Client"!
I never heard about anything of this sort. Any ideas?

Jan 4 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: (Pete Cresswell) | last post by:
Just fired it up to see what it looked like. They wanted me to "Activate" the product before the 50th use. Geeze, I paid my money....now they want me to jump through their hoops? Brings back...
0
by: ElGordo | last post by:
I have a .Net application which includes a function to open a command shell and run an executable (for a file extraction program, 7zip). I can run the same exact command line manually with no...
7
by: Bobby C. | last post by:
My company is in the process of getting ready (well actually QTR 2 2004) to roll out a rewritten version of a vertical market application for the municipal market (small and medium sized cities). ...
11
by: ML | last post by:
Does anyone have any info on sample code for handling activation/licensing for a vb.net app? Just looking for something fairly basic to implement the ability to have an application registered and...
0
by: Mart | last post by:
Hi, I have just written (my first) VB.net app using MS Visual Basic 2005 Express Edition Beta. It is fairly simple, it reads some configuration data from an XML file then opens a new window...
6
by: Josef Brunner | last post by:
Hi, I published my application (VS 2005) and am now trying to install it when I get this error message. It worked before...even on a different machine. Here is the detailed description: ...
2
by: Michael Kalika | last post by:
Hi, We have developed a VSTO 2005 Excel application and we would like to leverage ClickOnce deployment mechanism for distribution of this application. How can we do that? I was digging in MSDN...
0
by: Tifer | last post by:
Hello, I am building my first .Net Application. The first couple of Publish and Installs I did went fine. But after a couple of builds, I get a modal dialogue box error every time upon trying...
0
by: coopdog | last post by:
This is a new issue as of an install to sp1 on vb express 2005. When I publish the application to my drive then I try to install it is wants to be installed from the same location as it was...
0
by: Andrus | last post by:
I created .NET 3.5 SP1 Winforms application setup by pressing publish button in VCSE 2008 SP1 Running created setup.exe in same computer causes error below "Reference in the manifest does not...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.