D1时有个dwin库,可以操作iE,请问D2现用什么操作iE啊?

ilovetopview 2012-02-23
D1时有个dwin库,可以操作iE,请问D2现用什么操作iE啊?
betty_betty2008 2012-02-23
Juno,juno 的com
ilovetopview 2012-02-23
原来有dwin下边的代码可用
module adr;
import dwin.sys.win32.ie.IE;

void main(char[][] args)
{
    auto ie = ieCreate(null, "Width",800, "Height",600, "ToolBar",true, "MenuBar",true,
"Navigate", "http://114.255.93.220");
  
    Sleep(500);
    
    auto result = getElementsByName(ie, "btnG");  
  
    result[0].click();
   
}
但juno的com怎么用啊?
betty_betty2008 2012-02-23
module junoautod2; 

import juno.base.native;
import juno.com.core; 
import std.stdio; 
import std.string;
import std.conv;

extern(Windows)
alias DllImport!("user32.dll","MessageBoxW",int function(uint handle,in wchar* msg,in wchar* caption,int style))MessageBox;
void testIE() 
{ 
   auto ieApp=coCreate!(IDispatch)("InternetExplorer.Application",ExecutionContext.LocalServer); 
   setProperty(ieApp,"Visible","true");
   invokeMethod(ieApp,"Navigate","http://www.amazon.com"); 
} 
void testWord() 
{ 
   IDispatch wordApp=coCreate!(IDispatch)("Word.Application",ExecutionContext.LocalServer);
   setProperty(wordApp,"Visible","true");
   IDispatch documents=getProperty!(IDispatch)(wordApp,"Documents"); 
   IDispatch doc=invokeMethod!(IDispatch)(documents,"Add");
   /*IDispatch*/ doc=invokeMethod!(IDispatch)(documents,"Add");
   invokeMethod!(IDispatch)(documents,"Add");
   VARIANT count=getProperty(documents,"Count"); 
   //writefln("There are %s documents",count); 
   MessageBox(0,to!(wchar[])(format("总共 %s documents",count)).ptr,
		"info",0);
} 
void testExcel() 
{ 
   IDispatch excelApp=coCreate!(IDispatch)("Excel.Application",ExecutionContext.LocalServer); 
   setProperty(excelApp,"Visible",true); 
   IDispatch workbooks=getProperty!(IDispatch)(excelApp,"Workbooks"); 
   IDispatch newWorkbook=invokeMethod!(IDispatch)(workbooks,"Add"); 
   IDispatch worksheet=getProperty!(IDispatch)(excelApp,"Worksheets",1); 
   setProperty(worksheet,"Cells",5,3,"data"); 
   //invokeMethod!(IDispatch)(workbooks,"SaveAs");
   
} 

void main() 
{ 
   testIE; 
   testWord; 
   testExcel; 
} 
ilovetopview 2012-02-23
你做得挺好啊。
学习了,谢了。
感觉比c#还好用啊。
Global site tag (gtag.js) - Google Analytics