Find Window from Client-Side (ActiveX?) to Copy Contents into Web

G

Guest

Hello,

I'm running an asp.net, intranet web application using .net framework 1.1 on
IIS5.1 / 6.0. Through the web application, I would like to press a button on
the web page, have another window (not web-based or part of current
application) brought to the front and focused (findwindow api) and have the
button scrape the contents of the focused window so the contents can be
parsed and entered into the web application.

Ideally, I would like to do this server-side, but I don't think I can get to
a window on the client's pc to bring it to the front. I'm definitely open to
javascript since this is an intranet application and the environment is
controlled.

I've considered and attempted to create an ActiveX control that will be in a
web page (object tag). The class library project contains an interface,
IScreenScrape, that defines the method and properties available (COM
support?). If I run the ActiveX control and exit before it attempts to
"activate" the other application's window, the properties are accessible and
contain values, and the process finishes successfully. The ActiveX control
seems to work until it attempts to "activate" the other application's window
where I get a System.Security.Permissions.SecurityPermission error. This
action is initiated through Javascript by calling
USSActiveX.GetVisionInformation().

Things I've tried:
1) I've added my local pc to the "Trusted Sites" in IE 7;
2) I've modified code-access security in LocalIntranet_Zone to FullTrust and
Everything;
3) I've strong-name signed the dll that houses the ActiveX control (when I
did this, I started getting a Javascript error indicating "object does not
support this property or method" even though it exists).

Any help that can be provided is appreciated. Thanks.

Web Application calling code:

<%@ Page language="c#" Codebehind="WebForm4.aspx.cs" AutoEventWireup="false"
Inherits="Test_ActiveXDotNetWeb.WebForm4" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm4</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script type="text/javascript">
function doScript()
{
USSActiveX.GetVisionInformation();
Form1.hdnName.value = USSActiveX.ApplicantName;
Form1.hdnSSN.value = USSActiveX.ApplicantSSN;
Form1.hdnOTA.value = USSActiveX.OrgTypeApplicationNumber;
Form1.hdnScreen.value = USSActiveX.VisionScreen;

}
</script>
</HEAD>
<body>
<OBJECT id="USSActiveX"
classid="Unicorn.ScreenScrapeActiveX.dll#Unicorn.ScreenScrapeActiveX.ScreenScrape"
name="USSActiveX" VIEWASTEXT>
</OBJECT>
<form id="Form1" method="post" runat="server">
<input type="hidden" id="hdnName" runat="server" NAME="hdnName"> <input
type="hidden" id="hdnSSN" runat="server" NAME="hdnSSN">
<input type="hidden" id="hdnOTA" runat="server" NAME="hdnOTA"> <input
type="hidden" id="hdnScreen" runat="server" name="hdnScreen">
<br>
<input type="text" name="txt" value="Enter text here">
<br>
<asp:Button ID="butSetText" Runat="server" Text="Set Text"></asp:Button>
</form>
</body>
</HTML>

The butSetText onclick event is assigned server side using:
this.butSetText.Attributes.Add("onclick","doScript();");
 
A

Alvin Bruney [MVP]

You really mean you have a managed user control, that's sthe only reason you
could get a security error. You simply need to update your cas policy with
the appropriate permissions.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
 
G

Guest

Thanks for your response Alvin.

What permissions do I give it? I tried SecurityPermission to no avail. I
tried to give the LocalIntranet_Zone both FullTrust and Everything and that
didn't work. Is there some sort of Win32Permission to give the assembly?

The code I'm working with is in a Class Library DLL, not a UserControl. Do I
need to move it into a UserControl? I don't intend for any user interface
components to be on the web page (at least not visible)... I just want to be
able to have the user push a button which will then instantiate the ActiveX
to scrape data from another window for use in the web app.

Thanks.
Greg
 
A

Alvin Bruney [MVP]

Use the .net configuration console application (mscorcfg.msc at a Visual
Studio command prompt). Right click on the evaluate assembly node found in
my computer node. Find your dll. It tells you where the application will be
run from and what permissions it needs.

Actually there is a better, simpler way. Run the application and wait for it
to choke. Open your browser, and find the temporary file. Look for a
fusionlog file in the list of temporary file. Open that file in notepad by
dragging it into notepad. That file is a stack dump of the permissions
error. The stack dump tells you which permission is missing. Add that
permission to your cas policy (1st paragraph). Reset IIS you should be all
set. I have an article about this on MSDN but i forget where it is. google
if you feel lucky.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
https://www.microsoft.com/MSPress/books/10933.aspx
OWC Black Book www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top