找回密码
 加入
搜索
查看: 5269|回复: 10

[GUI管理] 检测窗口函数

  [复制链接]
发表于 2010-2-23 17:04:49 | 显示全部楼层 |阅读模式
本帖最后由 kb5077 于 2010-2-23 17:21 编辑

这个很好懂,就是指定窗口出现就关闭,因为我需要检测两个窗口,所以不知道用什么函数检测最好,还有我如果在点击了开始按钮后,怎么使这个开始按钮变成灰色,还有我如果按了开始菜单后如果点退出和关闭窗口就退出程序,请求高手指点。。。

#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=C:\Tools\ico\wlds.ICO
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("雨人一卡通辅助工具", 400, 217, 437, 237)
GUISetFont(10, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Copyright (C) 2010.2 ", 224, 192, 172, 18)
GUICtrlSetFont(-1, 11, 800, 0, "宋体")
$Button1 = GUICtrlCreateButton("开始", 72, 72, 99, 49)
GUICtrlSetFont(-1, 16, 800, 0, "宋体")
$Button2 = GUICtrlCreateButton("退出", 232, 72, 99, 49)
GUICtrlSetFont(-1, 18, 800, 0, "宋体")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch

        Select
          Case $nmsg = $Button1
               WinSetState ( "雨人一卡通辅助工具", "", @SW_MINIMIZE )
          While 1         
                        if WinActive("音乐影视") or WinActive("视频转换") then
                       Sleep(1000)
               WinClose("[ACTIVE]", "")
           endif      
          WEnd
                 Case $nmsg = $Button2
               exit
         ExitLoop

       EndSelect

WEnd
 楼主| 发表于 2010-2-23 17:54:21 | 显示全部楼层
请求高手帮我修改下程序,小弟在此感激不尽啊。。。。现在我这程序非常费CPU啊
发表于 2010-2-23 18:16:44 | 显示全部楼层
本帖最后由 afan 于 2010-2-23 18:20 编辑
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Icon=C:\Tools\ico\wlds.ICO
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("雨人一卡通辅助工具", 400, 217, 437, 237)
GUISetFont(10, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Copyright (C) 2010.2 ", 224, 192, 172, 18)
GUICtrlSetFont(-1, 11, 800, 0, "宋体")
$Button1 = GUICtrlCreateButton("开始", 72, 72, 99, 49)
GUICtrlSetFont(-1, 16, 800, 0, "宋体")
$Button2 = GUICtrlCreateButton("退出", 232, 72, 99, 49)
GUICtrlSetFont(-1, 18, 800, 0, "宋体")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $Button2
                        Exit

                Case $Button1
                        GUICtrlSetState($Button1, $Gui_DISABLE)
                        WinSetState("雨人一卡通辅助工具", "", @SW_MINIMIZE)
                        Dim $bj = 0
                        While 1
                                If $bj = 2 Then ExitLoop
                                $nMsg1 = GUIGetMsg()
                                If $nMsg1 = $Button2 Or $nMsg1 = -3 Then Exit
                                If WinActive("音乐影视") Or WinActive("视频转换") Then
                                        Sleep(1000)
                                        WinClose("[ACTIVE]", "")
                                        $bj += 1
                                EndIf
                        WEnd
                        WinSetState("雨人一卡通辅助工具", "", @SW_RESTORE)
                        GUICtrlSetState($Button1, $Gui_ENABLE)
        EndSwitch

WEnd
 楼主| 发表于 2010-3-2 21:25:31 | 显示全部楼层
谢谢版主的修改,我不需要计数器,还有为什么我在点了开始变成灰色后,再点击关闭按钮或退出按钮无法退出呢?
发表于 2010-3-2 21:36:40 | 显示全部楼层
回复 4# kb5077


    计数器是因为你要关闭2个窗口(音乐影视And?or?视频转换)
3#的代码不能退出吗?
 楼主| 发表于 2010-3-4 16:18:56 | 显示全部楼层
我的意思是这两个窗口可能出现N次,不是出现二次就终止循环,程序不必自动终止循环,而是由使用者不需要使用程序了自己按退出或关闭按钮退出程序。还有如果程序运行15秒都没有操作,程序可以自动退出需要修改哪里!谢谢版主指导!!!
发表于 2010-3-4 18:06:08 | 显示全部楼层
回复 6# kb5077
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Icon=C:\Tools\ico\wlds.ICO
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("雨人一卡通辅助工具", 400, 217, 437, 237)
GUISetFont(10, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Copyright (C) 2010.2 ", 224, 192, 172, 18)
GUICtrlSetFont(-1, 11, 800, 0, "宋体")
$Button1 = GUICtrlCreateButton("开始", 72, 72, 99, 49)
GUICtrlSetFont(-1, 16, 800, 0, "宋体")
$Button2 = GUICtrlCreateButton("退出", 232, 72, 99, 49)
GUICtrlSetFont(-1, 18, 800, 0, "宋体")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $Button2
                        Exit

                Case $Button1
                        $begin = TimerInit()
                        GUICtrlSetState($Button1, $Gui_DISABLE)
                        WinSetState("雨人一卡通辅助工具", "", @SW_MINIMIZE)
                        While 1
                                $nMsg1 = GUIGetMsg()
                                If $nMsg1 = $Button2 Or $nMsg1 = -3 Or TimerDiff($begin) >= 15000 Then Exit
                                If WinActive("音乐影视") Or WinActive("视频转换") Then
                                        Sleep(1000)
                                        WinClose("[ACTIVE]", "")
                                EndIf
                        WEnd
        EndSwitch

WEnd
发表于 2010-3-5 03:21:29 | 显示全部楼层
回复 7# afan


    学习了
发表于 2010-4-9 22:05:18 | 显示全部楼层
留下记号 如果内容改变怎么弄呢 比如flash 产生一个类是豆丁网的遮罩
发表于 2010-4-10 14:26:07 | 显示全部楼层
呵呵,学习一下。。
发表于 2010-4-11 21:14:42 | 显示全部楼层
向你楼主们学习了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-9 02:21 , Processed in 0.080312 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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