上个月QQ空间中的"开心农场"就放出来了,但要黄钻才能体验!前日,QQ校友农场用户发来邀请才给开通了!登陆上去一看,QQ校友和QQzone中都有"开心农场",虽然是同一个游戏,但好友是不尽相同的,结果就是好友多了赚取经验值方便了,两边登陆也就麻烦了,如是就简单写了个登陆器,可方便两边农场切换。
    1111
 
代码如下:
#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <IE.au3>

Opt ( "GUIOnEventMode" , 1 ) ;GUI事件响应模式
Opt ( "TrayMenuMode" , 1 ) ;系统默认的菜单不显示
Opt ( "TrayOnEventMode" , 1 ) ;托盘事件

$Form1 = GUICreate ( "QQ农场" , 160 , 240 , 820 , 100 )
GUICtrlCreateGroup ( "功能" , 5 , 5 , 150 , 60 )
$Button1 = GUICtrlCreateButton ( "隐藏" , 15 , 20 , 60 , 35 , 0 )
$Button2 = GUICtrlCreateButton ( "退出" , 85 , 20 , 60 , 35 , 0 )
GUICtrlCreateGroup ( "" , - 99 , - 99 , 1 , 1 )   ;close group

GUICtrlCreateGroup ( "提示:" , 5 , 70 , 150 , 40 )
$Label = GUICtrlCreateLabel ( "当前显示是:校友农场" , 15 , 87 , 120 , 20 )
GUICtrlSetColor (- 1 , 0xff0000 )
GUICtrlCreateGroup ( "" , - 99 , - 99 , 1 , 1 )   ;close group

GUICtrlCreateGroup ( "农场选择" , 5 , 115 , 150 , 115 )
$Button3 = GUICtrlCreateButton ( "校友农场" , 30 , 130 , 100 , 40 , 0 )
$Button4 = GUICtrlCreateButton ( "QZONE农场" , 30 , 180 , 100 , 40 , 0 )
GUICtrlCreateGroup ( "" , - 99 , - 99 , 1 , 1 )   ;close group

GUICtrlSetOnEvent ( $Button1 , "Gui" )
GUICtrlSetOnEvent ( $Button2 , "Gui" )
GUICtrlSetOnEvent ( $Button3 , "Gui" )
GUICtrlSetOnEvent ( $Button4 , "Gui" )
GUISetOnEvent ( $GUI_EVENT_CLOSE , "Gui" )
GUISetState ( @SW_SHOW )

$Form2 = GUICreate ( "QQ农场登陆助手 -(初始登陆到校友农场)- Powered By Zhuzb" , 745 , 655 , 40 , 40 , 0 ) ;前两个数字为窗口大小,后两个为窗口初始位置,最后0为窗口样式(无控制钮)
$oIE = _IECreateEmbedded ()
GUICtrlCreateObj ( $oIE , 0 , 0 , 735 , 635 )
GUISetState ()

$Xiaoyou = "http://happyfarm.xiaoyou.qq.com"
$Qzone = "http://happyfarm.qzone.qq.com"
_IENavigate ( $oIE , "http://ui.ptlogin2.qq.com/cgi-bin/login?appid=1&s_url=" & $Xiaoyou )

$Hideitem = TrayCreateItem ( "隐藏窗口" )
TrayCreateItem ( "" ) ; 当中空白为分隔线
$Exititem = TrayCreateItem ( "退出程序" )

TrayItemSetOnEvent ( $hideitem , "Tray" ) ;托盘菜单点击后执行函数
TrayItemSetOnEvent ( $exititem , "Tray" )
TraySetOnEvent ( $TRAY_EVENT_PRIMARYDOUBLE , "TrayClick" ) ;设置特殊事件此处为左键双击时,执行函数
TraySetClick ( 8 ) ;鼠标右击一下,显示托盘菜单(默认为9,即左右键单击都可显示)

While 1

WEnd

Func Gui ()
    Switch @GUI_CtrlId      
        Case $GUI_EVENT_CLOSE
            TrayClick ()
        Case $Button1
            $B2text = GUICtrlRead ( $Button1 )
            If $B2text = "隐藏" Then
                GUISetState ( @SW_HIDE , $Form2 )
                GUICtrlSetData ( $Button1 , "显示" )
            Else
                GUISetState ( @SW_SHOW , $Form2 )
                GUICtrlSetData ( $Button1 , "隐藏" )
            EndIf
        Case $Button2
            Exit
        Case $Button3
            _IENavigate ( $oIE , $Xiaoyou )
            GUICtrlSetData ( $Label , "当前显示是:校友农场" )
        Case $Button4
            _IENavigate ( $oIE , $Qzone )
             GUICtrlSetData ( $Label , "当前显示是:QZONE农场" )
    EndSwitch
EndFunc    ;==>gui

Func Tray ()
    Switch @TRAY_ID
        Case $hideitem          
            TrayClick ()
        Case $exititem
            Exit
    EndSwitch
EndFunc    ;==>Tray

Func TrayClick () ;双击托盘隐/显窗口
    GUISetState ( @SW_HIDE , $Form2 )
    GUICtrlSetData ( $Button1 , "显示" )
    GUISetState ( @SW_MINIMIZE , $Form1 ) ;先隐藏浏览窗口,再最小化控制窗口 
    $traytext1 = TrayItemGetText ( $hideitem ) ;读托盘菜单文本
    If $traytext1 = "隐藏窗口" Then
        GUISetState ( @SW_HIDE , $Form1 )
        TrayItemSetText ( $hideitem , "显示窗口" )
    Else
        GUISetState ( @SW_SHOW , $Form1 )
        GUISetState ( @SW_RESTORE , $Form1 ) ;撤消最小化
        TrayItemSetText ( $hideitem , "隐藏窗口" )
    EndIf
EndFunc    ;==>trayclick