找回密码
 加入
搜索
查看: 1891|回复: 5

复选框问题 求高手解答

[复制链接]
发表于 2008-10-25 16:55:40 | 显示全部楼层 |阅读模式
新手学习,所以写得比较差,望大家不要笑哦。
问题1:复选框勾上以后,任何一个按钮按下,执行完代码后自动关闭程序自身。反之不勾则不关闭。(具体不知道怎么写那段代码和值,望高手解答)
问题2:第一个和第二个按钮其实执行的代码是一样的,但只是变量不同。我想问一下可不可以改一下代码,只写一段执行代码,然后两个按钮都可以执行,只是变量是INI里分别指定的。

#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=D:\autoit3\Aut2Exe\Icons\TLB.ico
#AutoIt3Wrapper_outfile=QQ自动登录器.exe
#AutoIt3Wrapper_Res_Comment=QQ自动登录器
#AutoIt3Wrapper_Res_Description=QQ自动登录器
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_LegalCopyright=Copyright (C) 残风败鳞 2008-2010.All rights reserved.
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$user1 = IniRead("mone.ini","QQ","号码1","")
$user2 = IniRead("mone.ini","QQ","号码2","")
$pwd1 = IniRead("mone.ini","密码","密码1","")
$pwd2 = IniRead("mone.ini","密码","密码2","")
$Form1 = GUICreate("XX专用", 130, 180, 193, 115)
GUISetIcon("D:\Program Files\QQ\QQ.exe")
$Button1 = GUICtrlCreateButton($user1, 24, 10, 81, 33, 0)
$Button2 = GUICtrlCreateButton($user2, 24, 54, 81, 33, 0)
$Button3 = GUICtrlCreateButton("广告位招租", 24, 98, 81, 33, 0)
$Label1 = GUICtrlCreateLabel("作者:残风败鳞", 48, 137, 128, 15)
$Label2 = GUICtrlCreateLabel("QQ:00000000", 54, 152, 128, 15)
$Checkbox1 = GUICtrlCreateCheckbox("自动关闭本程序", 24, 166, 105, 15)
GUICtrlSetFont(-1, 9, 400, 0, "Terminal")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                case $Button1
                        Run("D:\Program Files\QQ\QQ.exe")
                        WinActivate("QQ用户登录")
                        WinWait("QQ用户登录")
                        ControlClick("QQ用户登录","","Edit1")
                        ControlSend("QQ用户登录","登录","Edit1",$user1)
                        ControlClick("QQ用户登录","","Edit12")
                        Send($pwd1)
                        send("{enter}")
                Case $Button2
                        Run("D:\Program Files\QQ\QQ.exe")
                        WinActivate("QQ用户登录")
                        WinWait("QQ用户登录")
                        ControlClick("QQ用户登录","","Edit1")
                        ControlSend("QQ用户登录","登录","Edit1",$user2)
                        ControlClick("QQ用户登录","","Edit12")
                        Send($pwd2)
                        Send("{enter}")
                Case $Button3
                        MsgBox("64","提示","广告位招租 如果需要请联系作者!QQ:00000000")
        EndSwitch
WEnd


INI文件内容:
mone.ini
[QQ]
号码1=123456
号码2=456789
[密码]
密码1=1abcd
密码2=1abcd
[说明]
因为QQ版本问题,所以不同版本密码输入会有不同,如果输入的是正确密码
却提示密码不正确,请在密码前面加个1。

[ 本帖最后由 gs008970 于 2008-10-25 17:44 编辑 ]
 楼主| 发表于 2008-10-25 17:12:34 | 显示全部楼层
自己顶起来,千万不能沉啊。老大们速度来解决哦。
发表于 2008-10-25 17:12:43 | 显示全部楼层
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=D:\autoit3\Aut2Exe\Icons\TLB.ico
#AutoIt3Wrapper_outfile=QQ自动登录器.exe
#AutoIt3Wrapper_Res_Comment=QQ自动登录器
#AutoIt3Wrapper_Res_Description=QQ自动登录器
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_LegalCopyright=Copyright (C) 阮文 2008-2010.All rights reserved.
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$user1 = IniRead("mone.ini", "QQ", "号码1", "")
$user2 = IniRead("mone.ini", "QQ", "号码2", "")
$pwd1 = IniRead("mone.ini", "密码", "密码1", "")
$pwd2 = IniRead("mone.ini", "密码", "密码2", "")
$Form1 = GUICreate("XX专用", 130, 180, 193, 115)
GUISetIcon("D:\Program Files\QQ\QQ.exe")
$Button1 = GUICtrlCreateButton($user1, 24, 10, 81, 33, 0)
$Button2 = GUICtrlCreateButton($user2, 24, 54, 81, 33, 0)
$Button3 = GUICtrlCreateButton("广告位招租", 24, 98, 81, 33, 0)
$Label1 = GUICtrlCreateLabel("作者:残风败鳞", 48, 137, 128, 15)
$Label2 = GUICtrlCreateLabel("QQ:00000000", 54, 152, 128, 15)
$Checkbox1 = GUICtrlCreateCheckbox("自动关闭本程序", 24, 166, 105, 15)
GUICtrlSetFont(-1, 9, 400, 0, "Terminal")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        login($user1)
                Case $Button2
                        login($user2)
                Case $Button3
                        MsgBox("64", "提示", "广告位招租 如果需要请联系作者!QQ:00000000")
        EndSwitch
WEnd

Func login($user)
        Run("D:\Program Files\QQ\QQ.exe")
        WinActivate("QQ用户登录")
        WinWait("QQ用户登录")
        ControlClick("QQ用户登录", "", "Edit1")
        ControlSend("QQ用户登录", "登录", "Edit1", $user1)
        ControlClick("QQ用户登录", "", "Edit12")
        Send($pwd1)
        Send("{enter}")
        If GUICtrlRead($Checkbox1) = 1 Then
                Exit
        EndIf
EndFunc   ;==>login
 楼主| 发表于 2008-10-25 17:35:28 | 显示全部楼层
谢谢3楼的朋友帮我解决了复选框的问题。

经过再一次修改,终于实现了同一段代码获取不同值了。(LOGIN后面多加一个$PWD1和$PWD2。Func login后面再多加一个$PWD)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        login($user1,$pwd1)
                Case $Button2
                        login($user2,$pwd2)
                Case $Button3
                        MsgBox("64", "提示", "广告位招租 如果需要请联系作者!QQ:00000000")
        EndSwitch
WEnd

Func login($user,$pwd)
        Run("D:\Program Files\QQ\QQ.exe")
        WinActivate("QQ用户登录")
        WinWait("QQ用户登录")
        ControlClick("QQ用户登录", "", "Edit1")
        ControlSend("QQ用户登录", "登录", "Edit1", $user)
        ControlClick("QQ用户登录", "", "Edit12")
        Send($pwd)
        Send("{enter}")
        If GUICtrlRead($Checkbox1) = 1 Then
                Exit
        EndIf
EndFunc   ;==>login

这样就可以了。

[ 本帖最后由 gs008970 于 2008-10-25 17:41 编辑 ]
发表于 2008-10-25 17:41:06 | 显示全部楼层
刚才复制代码的时候复制错了
这才是
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=D:\autoit3\Aut2Exe\Icons\TLB.ico
#AutoIt3Wrapper_outfile=QQ自动登录器.exe
#AutoIt3Wrapper_Res_Comment=QQ自动登录器
#AutoIt3Wrapper_Res_Description=QQ自动登录器
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_LegalCopyright=Copyright (C) 阮文 2008-2010.All rights reserved.
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$user1 = IniRead("mone.ini", "QQ", "号码1", "")
$user2 = IniRead("mone.ini", "QQ", "号码2", "")
$pwd1 = IniRead("mone.ini", "密码", "密码1", "")
$pwd2 = IniRead("mone.ini", "密码", "密码2", "")
$Form1 = GUICreate("XX专用", 130, 180, 193, 115)
GUISetIcon("D:\Program Files\QQ\QQ.exe")
$Button1 = GUICtrlCreateButton($user1, 24, 10, 81, 33, 0)
$Button2 = GUICtrlCreateButton($user2, 24, 54, 81, 33, 0)
$Button3 = GUICtrlCreateButton("广告位招租", 24, 98, 81, 33, 0)
$Label1 = GUICtrlCreateLabel("作者:残风败鳞", 48, 137, 128, 15)
$Label2 = GUICtrlCreateLabel("QQ:00000000", 54, 152, 128, 15)
$Checkbox1 = GUICtrlCreateCheckbox("自动关闭本程序", 24, 166, 105, 15)
GUICtrlSetFont(-1, 9, 400, 0, "Terminal")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        login($user1,$pwd1)
                Case $Button2
                        login($user2,$pwd2)
                Case $Button3
                        MsgBox("64", "提示", "广告位招租 如果需要请联系作者!QQ:00000000")
        EndSwitch
WEnd

Func login($user,$pwd)
        Run("D:\Program Files\QQ\QQ.exe")
        WinActivate("QQ用户登录")
        WinWait("QQ用户登录")
        ControlClick("QQ用户登录", "", "Edit1")
        ControlSend("QQ用户登录", "登录", "Edit1", $user)
        ControlClick("QQ用户登录", "", "Edit12")
        Send($pwd)
        Send("{enter}")
        If GUICtrlRead($Checkbox1) = 1 Then
                Exit
        EndIf
EndFunc   ;==>login
 楼主| 发表于 2008-10-25 17:43:05 | 显示全部楼层
呵呵。刚才我拿你改的代码看了一下。自己改了一下就好了。就是差那两个密码的变量。谢谢你了。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-10 06:54 , Processed in 0.078744 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表