- 注册时间
- 2004-11-1
- 最后登录
- 2018-4-24
版主
  
- 积分
- 548
|
只做到获取两个参数,就发现写不下去了。好像dwin库中的IE OLE部分还不支持childNodes,找不到没有id,name的组件。
- import dwin.sys.win32.ie.IE;
- import dfl.all;
- import Integer = tango.text.convert.Integer;
- pragma(lib, "dwin.lib");
- pragma(lib, "pcre.lib");
- pragma(lib, "dfl.lib");
- pragma(lib, "uuid.lib");
- char[] to(uint u)
- {
- return Integer.format(new char[32], u);
- }
- uint to(char[] c)
- {
- return Integer.atoi(c);
- }
- class MyIE : Form
- {
- IWebBrowser2 ie;
- Button OBtn;
- Button CBtn;
- ComboBox ServerListBox;
- Button TBtn;
- this()
- {
- this.text = "牧场OnWeb控制台";
- this.clientSize = Size(400,225);
- this.startPosition = FormStartPosition.CENTER_SCREEN;
- this.maximizeBox = false;
- ServerListBox = new ComboBox();
- ServerListBox.bounds = Rect(0,0,80,18);
- ServerListBox.items.add("稻香");
- ServerListBox.items.add("麦浪");
- ServerListBox.items.add("桃源");
- ServerListBox.items.add("爱情");
- ServerListBox.text = "爱情";
- ServerListBox.parent = this;
- OBtn = new Button();
- OBtn.text = "打开IE";
- OBtn.bounds = Rect(82,0,80,18);
- OBtn.parent = this;
- OBtn.click ~= &this.createIE;
- CBtn = new Button();
- CBtn.text = "关闭IE";
- CBtn.bounds = Rect(164,0,80,18);
- CBtn.parent = this;
- CBtn.click ~= &this.closeIE;
- TBtn = new Button();
- TBtn.text = "测试";
- TBtn.bounds = Rect(246,0,80,18);
- TBtn.parent = this;
- TBtn.click ~= &this.test;
- }
- private void createIE(Object o, EventArgs e)
- {
- switch(ServerListBox.text)
- {
- case "稻香":
- ie = ieCreate(null, "Width",1020, "Height",780,"Navigate", "http://web.iyoyo.com.cn/Account/LoginServer.aspx?SiteID=1&GameID=9&ServerID=1");
- break;
- case "麦浪":
- ie = ieCreate(null, "Width",1020, "Height",780,"Navigate", "http://web.iyoyo.com.cn/Account/LoginServer.aspx?SiteID=1&GameID=9&ServerID=2");
- break;
- case "桃源":
- ie = ieCreate(null, "Width",1020, "Height",780,"Navigate", "http://web.iyoyo.com.cn/Account/LoginServer.aspx?SiteID=1&GameID=9&ServerID=3");
- break;
- case "爱情":
- ie = ieCreate(null, "Width",1020, "Height",780,"Navigate", "http://web.iyoyo.com.cn/Account/LoginServer.aspx?SiteID=1&GameID=9&ServerID=4");
- break;
- default:
- msgBox("没指定现有的服务器!");
- }
- }
- private void closeIE(Object o, EventArgs e)
- {
- ie.Quit();
- }
- private void test(Object o, EventArgs e)
- {
- if(ie is null)
- {
- msgBox("没有打开网页");
- }
- else
- {
- msgBox(to(getMoney(ie)));
- msgBox(to(getPower(ie)));
- }
- }
- private uint getMoney(IWebBrowser2 i)
- {
- auto money = getElementById(i, "tipMoney");
- return to(getInnerText(money));
- }
- private uint getPower(IWebBrowser2 i)
- {
- auto power = getElementById(i, "main");
- return to(getInnerText(power));
- }
- }
- void main()
- {
- int result = 0;
- try
- {
- Application.enableVisualStyles();
- Application.run(new MyIE());
- }
- catch(Object o)
- {
- msgBox(o.toString(), "Fatal Error", MsgBoxButtons.OK, MsgBoxIcon.ERROR);
-
- result = 1;
- }
-
- return result;
- }
复制代码 |
|