找回密码
 加入
搜索
查看: 2240|回复: 7

[AU3基础] 帮忙看一下循环哪里出问题了[已解决]

  [复制链接]
发表于 2011-12-15 14:01:29 | 显示全部楼层 |阅读模式
本帖最后由 oceanwind 于 2011-12-15 15:23 编辑

想作一个实时监控 当@MSEC=20时各往已打开的记本里写东西
外加两个按钮 停止与开始监控

谢谢先

#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=C:\WINDOWS\system32\SHELL32.dll
#AutoIt3Wrapper_outfile=timesuper.exe
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('TrayMenuMode', 1) ;单击不暂停
Dim $s
Opt("WinTitleMatchMode", 2)
Opt("SendKeyDelay", 200)
GUICreate("颜色显示", 300, 160)
$jkbutton = GUICtrlCreateButton("开始监控", 30, 100, 60)
$tzbutton = GUICtrlCreateButton("停止监控", 120, 100, 60)
$sj=@HOUR&@MIN
$tj=0
GUISetState(@SW_SHOW)
While 1
         $msg = GUIGetMsg()
              If  $Msg = -3 then
               Exit
                  endif          
                  if $Msg = $jkbutton then
                           $tj=1
          endif                          
                While 1
                                        $msg1 = GUIGetMsg()
                                        Select
                                               case $Msg1 = $tzbutton        
                                                             ExitLoop       
                                                         Case $Msg1 = -3
                                                                 exit
                    EndSelect                                                  
                                        While @MSEC=20 And $tj=1                         
                                                  ;$var = PixelGetColor( 1323 , 916 )                                                        
                                                  If  WinActive("无标题 - 记事本", "")=0 Then       
                                                          WinActivate("无标题 - 记事本", "")
                                                  EndIf
                                                  Sleep(50)
                                                  $zc = ControlGetText("无标题 - 记事本", "", "Edit1")
                                                  ControlSetText ( "无标题 - 记事本", "", "Edit1", $zc&"---"&@HOUR&":"&@MIN&":"&@MSEC  )                       
                                        WEnd       
                WEnd
WEnd
发表于 2011-12-15 14:24:35 | 显示全部楼层
要学学语法了
三个while根本没必要,一个while就行了
还有if也没必要,用case多好啊
一分钟写一次就全是看到的时间了,呵

如果是要写时间的话dos命令AT很不错的

评分

参与人数 1金钱 +10 收起 理由
oceanwind + 10

查看全部评分

 楼主| 发表于 2011-12-15 14:38:36 | 显示全部楼层
要学学语法了
三个while根本没必要,一个while就行了
还有if也没必要,用case多好啊
一分钟写一次就全是 ...
seniors 发表于 2011-12-15 14:24

能指点一下吗....
 楼主| 发表于 2011-12-15 15:16:34 | 显示全部楼层
要一个WHILE 能行吗?
又改了下
还是没有预期的在@MSEC=20的写入动作.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('TrayMenuMode', 1) ;单击不暂停
Dim $s
Opt("WinTitleMatchMode", 2)
Opt("SendKeyDelay", 200)
GUICreate("颜色显示", 300, 160)
$jkbutton = GUICtrlCreateButton("开始监控", 30, 100, 60)
$tzbutton = GUICtrlCreateButton("停止监控", 120, 100, 60)
$tj=0
GUISetState(@SW_SHOW)
While 1
        $msg = GUIGetMsg()
        Select
                   case $Msg = -3
                                Exit                    
                   case $Msg = $jkbutton
                                $tj=1
                   case $Msg = $tzbutton        
                                $tj=0       
        EndSelect                          
        While @MSEC=20 And $tj=1
                   ;$var = PixelGetColor( 1323 , 916 )                                                        
                   If  WinActive("无标题 - 记事本", "")=0 Then       
                           WinActivate("无标题 - 记事本", "")
                   EndIf
                   Sleep(50)
                   $zc = ControlGetText("无标题 - 记事本", "", "Edit1")
                   ControlSetText ( "无标题 - 记事本", "", "Edit1", $zc&"---"&@HOUR&":"&@MIN&":"&@MSEC  )                       
        WEnd       
WEnd
发表于 2011-12-15 15:16:58 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('TrayMenuMode', 1) ;单击不暂停
Dim $s
Opt("WinTitleMatchMode", 2)
Opt("SendKeyDelay", 200)
GUICreate("颜色显示", 300, 160)
$jkbutton = GUICtrlCreateButton("开始监控", 30, 100, 60)
$tzbutton = GUICtrlCreateButton("停止监控", 120, 100, 60)
$sj = @HOUR & @MIN
$tj = 0
GUISetState(@SW_SHOW)
While 1
        $msg1 = GUIGetMsg()
        Switch $msg1
                Case -3
                        Exit
                Case $tzbutton
                        $tj = 0
                        
                Case $jkbutton
                        $tj = 1
        EndSwitch
        While @SEC == 20 And $tj == 1
                ;$var = PixelGetColor( 1323 , 916 )
                If WinActive("无标题 - 记事本", "") = 0 Then
                        WinActivate("无标题 - 记事本", "")
                EndIf
                Sleep(50)
                $zc = ControlGetText("无标题 - 记事本", "", "Edit1")
                ControlSetText("无标题 - 记事本", "", "Edit1", $zc & "---" & @HOUR & ":" & @MIN & ":" & @SEC)
        WEnd
WEnd

评分

参与人数 1金钱 +10 收起 理由
oceanwind + 10 谢谢 有了

查看全部评分

 楼主| 发表于 2011-12-15 15:23:03 | 显示全部楼层
seniors 发表于 2011-12-15 15:16


谢谢 楼上的朋友
非常OK
发表于 2011-12-15 15:25:40 | 显示全部楼层
和你注册时间差不多,你要多学学基本的语法
 楼主| 发表于 2011-12-15 15:29:58 | 显示全部楼层
和你注册时间差不多,你要多学学基本的语法
seniors 发表于 2011-12-15 15:25

是啊 书到用时方恨少
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-1 05:27 , Processed in 0.109995 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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