找回密码
 加入
搜索
查看: 2093|回复: 4

GUI控件按钮默认按下怎么写

  [复制链接]
发表于 2009-12-17 16:33:17 | 显示全部楼层 |阅读模式
本帖最后由 qq3911909 于 2009-12-17 16:40 编辑
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiButton.au3>
#NoTrayIcon
#Region ### START Koda GUI section ### Form=D:\AU3\VNC\Form1.kxf
$Form1 = GUICreate("盛锐电脑网络科技-----专用远程维护工具", 338, 190, 465, 356)
$Group1 = GUICtrlCreateGroup("盛锐电脑网络科技服务热线:020-34271932  13728065057", 8, 72, 313, 49)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("连接盛锐电脑", 16, 128, 123, 41)
$Button2 = GUICtrlCreateButton("联接东信恒通电脑", 168, 128, 115, 41)
$Pic1 = GUICtrlCreatePic("D:\AU3\VNC\123.bmp", 8, 8, 321, 57, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

RegWrite ( "HKEY_CURRENT_USER\Software\ORL" )

RegWrite ( "HKEY_CURRENT_USER\Software\ORL\VNCHooks" )

RegWrite ( "HKEY_CURRENT_USER\Software\ORL\VNCHooks\Application_Prefs" )

RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "SocketConnect", "REG_DWORD", 0x00000000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "HTTPConnect", "REG_DWORD", 0x00000000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "AutoPortSelect", "REG_DWORD", 0x00000001 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "InputsEnabled", "REG_DWORD", 0x00000001 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "LocalInputsDisabled", "REG_DWORD", 0x00000000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "IdleTimeout", "REG_DWORD", 0x00000000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "LockSetting", "REG_DWORD", 0x00000000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "RemoveWallpaper", "REG_DWORD", 0x00000001 )
;RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "Password", "REG_BINARY", 0000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "PollUnderCursor", "REG_DWORD", 0x00000000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "PollForeground", "REG_DWORD", 0x00000001 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "PollFullScreen", "REG_DWORD", 0x00000000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "OnlyPollConsole", "REG_DWORD", 0x00000001 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "OnlyPollOnEvent", "REG_DWORD", 0x00000000 )

$ipini = "ip.ini"
If Not FileExists($ipini) Then
 $ipini = @ScriptDir & "\ip.ini"
  If Not FileExists($ipini) Then
   $ipini = @WorkingDir & "\ip.ini"
  EndIf
EndIf

If Not FileExists($ipini) Then
 IniWrite("ip.ini", "Setting", "盛锐电脑","192.168.1.250")
 IniWrite("ip.ini", "Setting", "东信恒通","192.168.1.210")
EndIf

#cs
If ProcessExists ("444568.exe") Then
        ShellExecute ("444568.exe","-kill","","",@SW_MINIMIZE)        
Else
        ShellExecute ("444568.exe","-run","","",@SW_MINIMIZE)
EndIf
#ce


While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        ProcessClose("444568.exe")
                        Exit

                Case $Button1
                        $ip = IniRead ("ip.ini","Setting","盛锐电脑","192.168.1.250")
                        ;ShellExecute ("444568.exe","-connect ","","",@SW_MINIMIZE)
                        ;#cs
                        If ProcessExists ("444568.exe") Then
                                ProcessClose ( "444568.exe")
                                ;ShellExecute ("444568.exe","-kill","","",@SW_MINIMIZE)        
                        EndIf
                        ;#ce
                        Sleep (2000)
                    ShellExecute ("444568.exe","","","",@SW_MINIMIZE)
                        Sleep (2000)
                        ShellExecute ("444568.exe ","-connect "&$ip,"","",@SW_MINIMIZE)
                Case $Button2
                        $ip = IniRead ("ip.ini","Setting","东信恒通","192.168.1.210")
                        ;ShellExecute ("444568.exe","-connect ","","",@SW_MINIMIZE)
                        ;#cs
                        If ProcessExists ("444568.exe") Then
                                ProcessClose ( "444568.exe")
                                ;ShellExecute ("444568.exe","-kill","","",@SW_MINIMIZE)        
                        EndIf
                        ;#ce
                        Sleep (2000)
                    ShellExecute ("444568.exe","","","",@SW_MINIMIZE)
                        Sleep (2000)
                        ShellExecute ("444568.exe ","-connect "&$ip,"","",@SW_MINIMIZE)
                Case Else
        EndSwitch
WEnd

#cs 
        Sleep (5000)
WinWaitActive("盛锐电脑网络科技-----专用远程维护工具")
_GUICtrlButton_Click($Button1)
这个工具我想他执行后,,用户在5秒内没有按下任何一个按钮,程序默认帮它按下一个按钮...
还有就是帮我优化下代码...刚刚学AU3,,,代码写的很乱....我想学习下高手是怎么写代码...

谢谢
发表于 2009-12-17 17:09:57 | 显示全部楼层
sleep(5000)
send(这里放按键)
发表于 2009-12-18 09:24:45 | 显示全部楼层
弄一个时钟
发表于 2009-12-18 11:50:33 | 显示全部楼层
类似的问题我以前遇到过,我是这样解决的。
申明一个数组,数组中包含所有控件
再用AdlibRegister ( "函数" [, 时间] )为某控件定时(比如5秒后执行某控件下的相应函数)
如果数组中的任何一个控件在5秒以内按下,则AdlibUnRegister( "函数" ),这样就形成了5秒后自动执行。

说这么多不知道能明白不?就当抛砖引玉吧!希望能看到更好的回复吧!
发表于 2009-12-18 11:52:07 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiButton.au3>
#NoTrayIcon
#Region ### START Koda GUI section ### Form=D:\AU3\VNC\Form1.kxf
$Form1 = GUICreate("盛锐电脑网络科技-----专用远程维护工具", 338, 190, 465, 356)
$Group1 = GUICtrlCreateGroup("盛锐电脑网络科技服务热线:020-34271932  13728065057", 8, 72, 313, 49)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("连接盛锐电脑", 16, 128, 123, 41)
$Button2 = GUICtrlCreateButton("联接东信恒通电脑", 168, 128, 115, 41)
$Pic1 = GUICtrlCreatePic("D:\AU3\VNC\123.bmp", 8, 8, 321, 57, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$timer=TimerInit()
RegWrite ( "HKEY_CURRENT_USER\Software\ORL" )

RegWrite ( "HKEY_CURRENT_USER\Software\ORL\VNCHooks" )

RegWrite ( "HKEY_CURRENT_USER\Software\ORL\VNCHooks\Application_Prefs" )

RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "SocketConnect", "REG_DWORD", 0x00000000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "HTTPConnect", "REG_DWORD", 0x00000000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "AutoPortSelect", "REG_DWORD", 0x00000001 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "InputsEnabled", "REG_DWORD", 0x00000001 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "LocalInputsDisabled", "REG_DWORD", 0x00000000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "IdleTimeout", "REG_DWORD", 0x00000000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "LockSetting", "REG_DWORD", 0x00000000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "RemoveWallpaper", "REG_DWORD", 0x00000001 )
;RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "Password", "REG_BINARY", 0000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "PollUnderCursor", "REG_DWORD", 0x00000000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "PollForeground", "REG_DWORD", 0x00000001 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "PollFullScreen", "REG_DWORD", 0x00000000 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "OnlyPollConsole", "REG_DWORD", 0x00000001 )
RegWrite ( "HKEY_CURRENT_USER\Software\ORL\WinVNC3", "OnlyPollOnEvent", "REG_DWORD", 0x00000000 )

$ipini = "ip.ini"
If Not FileExists($ipini) Then
$ipini = @ScriptDir & "\ip.ini"
  If Not FileExists($ipini) Then
   $ipini = @WorkingDir & "\ip.ini"
  EndIf
EndIf

If Not FileExists($ipini) Then
IniWrite("ip.ini", "Setting", "盛锐电脑","192.168.1.250")
IniWrite("ip.ini", "Setting", "东信恒通","192.168.1.210")
EndIf

#cs
If ProcessExists ("444568.exe") Then
        ShellExecute ("444568.exe","-kill","","",@SW_MINIMIZE)        
Else
        ShellExecute ("444568.exe","-run","","",@SW_MINIMIZE)
EndIf
#ce


While 1
        $nMsg = GUIGetMsg()
                if TimerDiff($timer)>=5000 then button1()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        ProcessClose("444568.exe")
                        Exit

                Case $Button1
                                        button1()
                Case $Button2
                        $ip = IniRead ("ip.ini","Setting","东信恒通","192.168.1.210")
                        ;ShellExecute ("444568.exe","-connect ","","",@SW_MINIMIZE)
                        ;#cs
                        If ProcessExists ("444568.exe") Then
                                ProcessClose ( "444568.exe")
                                ;ShellExecute ("444568.exe","-kill","","",@SW_MINIMIZE)        
                        EndIf
                        ;#ce
                        Sleep (2000)
                    ShellExecute ("444568.exe","","","",@SW_MINIMIZE)
                        Sleep (2000)
                        ShellExecute ("444568.exe ","-connect "&$ip,"","",@SW_MINIMIZE)
                Case Else
        EndSwitch
WEnd

Func button1()
                                $ip = IniRead ("ip.ini","Setting","盛锐电脑","192.168.1.250")
                        ;ShellExecute ("444568.exe","-connect ","","",@SW_MINIMIZE)
                        ;#cs
                        If ProcessExists ("444568.exe") Then
                                ProcessClose ( "444568.exe")
                                ;ShellExecute ("444568.exe","-kill","","",@SW_MINIMIZE)        
                        EndIf
                        ;#ce
                        Sleep (2000)
                    ShellExecute ("444568.exe","","","",@SW_MINIMIZE)
                        Sleep (2000)
                        ShellExecute ("444568.exe ","-connect "&$ip,"","",@SW_MINIMIZE)
EndFunc
                                        
#cs 
        Sleep (5000)
WinWaitActive("盛锐电脑网络科技-----专用远程维护工具")
_GUICtrlButton_Click($Button1)
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-16 14:57 , Processed in 0.074586 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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