System.Appdomain objapdom =System.Appdomain. currentdomain;
Object OBJ = objapdom. getdata ("app_launch_url ");
| Value of "name" |
Attribute |
| "Appbase" |
Applicationbase |
| "App_config_file" |
Configurationfile |
| "Dynamic_base" |
Dynamicbase |
| "Dev_path" |
(No attribute) |
| "App_name" |
Applicationname |
| "Cache_base" |
Privatebinpath |
| "Binpath_probe_only" |
Privatebinpathprobe |
| "Shadow_copy_dirs" |
Shadowcopydirectories |
| "Force_cache_install" |
Shadowcopyfiles |
| "Cache_base" |
Cachepath |
| (ApplicationProgramSpecific) |
Licensefile |
ErrorCode:
// Application domain
System.Appdomain objapdom =System.Appdomain. currentdomain;
Object OBJ = objapdom. getdata ("app_launch_url ");
If (OBJ = NULL)
{
Strurl = "";
}
Else
{
Strurl = obj. tostring ();
}
First, import c: \ windows \ system32 \Mshtml. TLB,InterOP. shdocvw. dllTwo dynamic library files
-Shrink
C # Code /// <Summary>
/// Return the ihtmldocument2 object in the IE window of the specified URL.
/// </Summary>
/// <Returns> ihtmldocument2 </returns>
Public Static Ihtmldocument2 getihtmldocument2byurl ( String URL)
{
Shdocvw. shellwindows = New Shdocvw. shellwindowsclass ();
Foreach (Shdocvw. internetexplorer IE In Shellwindows)
{
String Filename = system. Io. Path. getfilenamewithoutextension (ie. fullname). tolower ();
If (Filename. Equals ( "Iexplore" ) & Ie. locationurl = URL)
{
Return Ie. Document As Ihtmldocument2;
}
}
}
You can use the getihtmldocument2byurl method to obtain the ihtmldocument2 object in the window with the address specified in the opened ie window.
With this object, you can perform related operations.
1. Fill in the form
-Shrink
C # Code ihtmldocument2 ihtmldocument2 = getihtmldocument2byurl ( Http://www.163.com" );
Ihtmlinputelement input = (ihtmlinputelement) ihtmldocument2.all. Item ( "Username" , 0 ); // Obtain the object with the specified name
Input. Value = "Xiao" ; // Assign a value
2. click the button
-Shrink
C # Code ihtmldocument2 ihtmldocument2 = getihtmldocument2byurl ( Http://www.163.com" );
Htmldocumentclass OBJ = (htmldocumentclass) ihtmldocument2;
Ihtmlelement = Null ;
Ihtmlelementcollection c = obj. getelementsbytagname ( "Input" );
Foreach (Ihtmlelement E In C)
{
If (E. outerhtml. indexof ( "Login" )! =-1)
{
Ihtmlelement = E;
Break ;
}
}
If (Ihtmlelement! = Null )
{
Ihtmlelement. Click (); // Click the logon button.
}
Winform obtains the current ieurl address
- System. Diagnostics. Process [] _ list = system. Diagnostics. process. getprocessesbyname ("Iexplore");
- [Dllimport ("User32.dll")]
- Public Static Extern IntEnumchildwindows (intptr hwndparent, enumwindowsproc EWP,IntLparam );