免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1816 | 回复: 1
打印 上一主题 下一主题

做了个邮箱登陆的小工具-那位大神指点下如何让登陆支持tab键切换输入框 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-05-07 14:18 |只看该作者 |倒序浏览
做了个邮箱登陆的小工具-那位大神指点下如何让登陆支持tab键切换输入框
代码在2楼

126163.rar

1.39 MB, 下载次数: 34

论坛徽章:
0
2 [报告]
发表于 2012-05-07 14:19 |只看该作者
  1. #!/usr/bin/perl

  2. #********************
  3. #*Written by freewind31        *
  4. #*May 7, 2012 Beijing     *
  5. #********************

  6. use strict;
  7. use warnings;
  8. use Cwd;
  9. use Win32::GUI qw( MB_ICONINFORMATION MB_OK );
  10. use Win32::GUI::AxWindow;
  11. use Win32::OLE;

  12. my $font = Win32::GUI::Font->new(
  13.                 -name => "Times New Roman",    #字体名称
  14.                 -size => 12,                 #字体大小
  15.         );  

  16. #主窗口
  17. my $Window = new Win32::GUI::Window (
  18.     -title    => "163",
  19.     -pos     => [0, 0],
  20.     -size    => [1280, 1024],
  21.     -name     => "Window",
  22. ) or die "new Window";

  23. #添加tab控件,以提高空间利用率
  24. $Window->AddTabStrip(
  25.     -name  => "tbTab",
  26.     -left   => 0,
  27.     -top    => 0,
  28.     -width  => 1280,
  29.     -height => 1000,
  30. );

  31. #添加第一个tab页面
  32. $Window->tbTab->InsertItem(
  33.     -name=> "163",
  34.         -text => "          163          ",
  35.         -font => $font,        # Font对象
  36.         -height       => 20,
  37. );

  38. # Create AxWindow with a webbrowser
  39. my $Control1 = new Win32::GUI::AxWindow  (
  40.                -parent  => $Window->tbTab,
  41.                -name    => "Control1",
  42.                -pos     => [20, 50],
  43.                -size    => [1240, 900],
  44.                -control => "Shell.Explorer.2",
  45. ) or die "new Control";

  46. # Navigate to 163
  47. $Control1->CallMethod("Navigate", 'http://mail.163.com/');

  48. $Window->tbTab->AddCombobox(
  49.         -name         => "BCB1",
  50.         -dropdownlist => 1,
  51.         -left         => 20,
  52.         -top          => 20,
  53.         -height       => 30,
  54.         -width        => 1240,
  55.         -font => $font,        # Font对象
  56.         -onChange     => sub { $Control1->CallMethod("Navigate", $_[0]->Text()); },
  57.         -tabstop      => 1,
  58. );
  59. $Window->tbTab->BCB1->Add('http://mail.163.com/', 'http://mail.126.com/');
  60. $Window->tbTab->BCB1->SetCurSel(0);


  61. #添加第二个tab页面
  62. $Window->tbTab->InsertItem(
  63.     -name=> "126",
  64.         -text => "          126          ",
  65.         -font => $font,        # Font对象
  66.         -height       => 20,
  67. );

  68. # Create AxWindow with a webbrowser
  69. my $Control2 = new Win32::GUI::AxWindow  (
  70.                -parent  => $Window->tbTab,
  71.                -name    => "Control2",
  72.                -pos     => [20, 50],
  73.                -size    => [1240, 900],
  74.                -control => "Shell.Explorer.2",
  75. ) or die "new Control";

  76. # Navigate to 126
  77. $Control2->CallMethod("Navigate", 'http://mail.126.com/');

  78. $Window->tbTab->AddCombobox(
  79.         -name         => "BCB2",
  80.         -dropdownlist => 1,
  81.         -left         => 20,
  82.         -top          => 20,
  83.         -height       => 30,
  84.         -width        => 1240,
  85.         -font => $font,        # Font对象
  86.         -onChange     => sub { $Control2->CallMethod("Navigate", $_[0]->Text()); },
  87.         -tabstop      => 1,
  88. );
  89. $Window->tbTab->BCB2->Add('http://mail.163.com/', 'http://mail.126.com/');
  90. $Window->tbTab->BCB2->SetCurSel(0);


  91. #各个tab页面之间切换
  92. sub tbTab_Click
  93. {
  94.     my $current_tab = $Window->tbTab->SelectedItem();
  95.     my ($key, $refs, $tabid);
  96.    
  97.     foreach $key (keys %{$Window->tbTab}) {
  98.         # Skip these items - what remains should be just widgets.
  99.         next if (grep(/^${key}$/,qw(-handle -name -type)));
  100.                 #next if (grep(/^${key}$/,qw(-handle)));
  101.         $refs = $Window->tbTab->{$key};
  102.      
  103.         if ($refs eq "0")
  104.         {
  105.            next;
  106.         }
  107.         $tabid = substr($refs->{-name},-1);
  108.         if ($current_tab == ($tabid-1))
  109.                 {
  110.             $refs->Show();
  111.         }
  112.         else
  113.                 {
  114.             $refs->Hide();
  115.         }
  116.     }
  117. }
  118. # Event loop
  119. $Window->Center();
  120. $Window->Show();
  121. tbTab_Click();  # Initialize display of first tab (only).
  122. Win32::GUI::Dialog();

  123. sub Window_Terminate
  124. {

  125.                 $Control1->Release();
  126.                 $Control2->Release();
  127.                 return -1;
  128.         }

  129. sub Window_Resize
  130. {

  131.   if (defined $Window) {
  132.         #$Window->tbTab->Resize($Window->ScaleWidth()-20,$Window->ScaleHeight()-20);
  133.     #($width, $height) = ($Window->GetClientRect)[2..3];
  134.     #$Control->Move   (10, 40);
  135.     #$Control->Resize ($width-50, $height-50);
  136.   }
  137. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP