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

[AU3基础] [已解决]参考其他高手写了个程序,两段代码只是路径不同,请问怎么合并?

[复制链接]
发表于 2015-10-30 10:17:13 | 显示全部楼层 |阅读模式
本帖最后由 6vvvvvv 于 2015-10-30 18:57 编辑

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
;画出交互界面并隐藏,等待热键
$Form1_1 = GUICreate("微信二维码拍照程序", 531, 141, 695, 666)
$Input1 = GUICtrlCreateInput("", 64, 56, 425, 21)
$czbutton = GUICtrlCreateButton("充值", 64, 104, 89, 25)
$czbutton2 = GUICtrlCreateButton("拍照", 264, 104, 89, 25)
$Label1 = GUICtrlCreateLabel("请输入微信二维码", 72, 16, 100, 17)
GUISetState(@SW_HIDE)
HotKeySet("^!x", "_Echowin1")
While 1
        Sleep(500)
WEnd
;交互界面
FUNC _Echowin1()
         GUISetState(@SW_SHOW)
While 1
        $nMsg = GUIGetMsg()
        Select
    Case $nMsg = $czbutton; 按下[充值]
                 _Captureimg1()
         Case $nMsg = $czbutton2; 按下[拍照]
                 _Captureimg2()
         Case $nmsg = $GUI_EVENT_CLOSE; 关闭程序,隐藏[窗口]
          GUISetState(@SW_HIDE)
      ExitLoop
  EndSelect
WEnd
EndFunc
;[充值]截屏程序1
Func _Captureimg1()
        Dim $captureimgname
        $captureimgname = "D:\充值\"& GUICtrlRead($Input1)&"_" & @YEAR & "_" & @MON & @MDAY & "_" & @HOUR & @MIN & "_" & @SEC & ".jpg"
        Send("{PRINTSCREEN}")
        Sleep(1000)
        Run("mspaint.exe")
        _winwaitactivate("[class:MSPaintApp]", "")
        Send("{CTRLDOWN}v{CTRLUP}{ALTDOWN}{ALTUP}fa")
        Sleep(1000)
        Send($captureimgname)
        Send("{ENTER}")
        _winwaitactivate("[class:MSPaintApp]", "")
        Send("{ALTDOWN}{ALTUP}fx")
EndFunc

Func _winwaitactivate($title, $text, $timeout = 0)
        WinWait($title, $text, $timeout)
        If NOT WinActive($title, $text) Then WinActivate($title, $text)
        WinWaitActive($title, $text, $timeout)
        EndFunc
;[拍照]截屏程序2
Func _Captureimg2()
        Dim $captureimgname
        $captureimgname = "D:\拍照\" & @YEAR & "_" & @MON & @MDAY & "_" & @HOUR & @MIN & "_" & @SEC & ".jpg"
        Send("{PRINTSCREEN}")
        Sleep(1000)
        Run("mspaint.exe")
        _winwaitactivate2("[class:MSPaintApp]", "")
        Send("{CTRLDOWN}v{CTRLUP}{ALTDOWN}{ALTUP}fa")
        Sleep(1000)
        Send($captureimgname)
        Send("{ENTER}")
        _winwaitactivate2("[class:MSPaintApp]", "")
        Send("{ALTDOWN}{ALTUP}fx")
EndFunc

Func _winwaitactivate2($title, $text, $timeout = 0)
        WinWait($title, $text, $timeout)
        If NOT WinActive($title, $text) Then WinActivate($title, $text)
        WinWaitActive($title, $text, $timeout)
        EndFunc
 楼主| 发表于 2015-10-30 11:44:13 | 显示全部楼层
新手慢慢学习中
 楼主| 发表于 2015-10-30 11:46:10 | 显示全部楼层
两段代码只是路径不同,怎么合并?
发表于 2015-10-30 13:43:02 | 显示全部楼层
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1_1 = GUICreate("微信二維碼拍照程序", 531, 141, 695, 666)
$Input1 = GUICtrlCreateInput("", 64, 56, 425, 21)
$czbutton = GUICtrlCreateButton("充值", 64, 104, 89, 25)
$czbutton2 = GUICtrlCreateButton("拍照", 264, 104, 89, 25)
$Label1 = GUICtrlCreateLabel("請輸入微信二維碼", 72, 16, 100, 17)
GUISetState(@SW_HIDE)
HotKeySet("^!x", "_Echowin1")
While 1
        Sleep(500)
WEnd
FUNC _Echowin1()
         GUISetState(@SW_SHOW)
While 1
        $nMsg = GUIGetMsg()
        Select
    Case $nMsg = $czbutton
                 _Captureimg1()
         Case $nMsg = $czbutton2
                 _Captureimg2()
         Case $nmsg = $GUI_EVENT_CLOSE
          GUISetState(@SW_HIDE) 
      ExitLoop
  EndSelect
WEnd
EndFunc
Func _Captureimg1()
        Dim $captureimgname
                Dim $captureimgname1
        $captureimgname = "D:\充值"& GUICtrlRead($Input1)&"_" & @YEAR & "_" & @MON & @MDAY & "_" & @HOUR & @MIN & "_" & @SEC & ".jpg"
                $captureimgname1 = "D:\拍照" & @YEAR & "_" & @MON & @MDAY & "_" & @HOUR & @MIN & "_" & @SEC & ".jpg"
        Send("{PRINTSCREEN}")
        Sleep(1000)
        Run("mspaint.exe")
        _winwaitactivate("[class:MSPaintApp]", "")
        Send("{CTRLDOWN}v{CTRLUP}{ALTDOWN}{ALTUP}fa")
        Sleep(1000)
        Send($captureimgname)
                Send($captureimgname1)
        Send("{ENTER}")
        _winwaitactivate("[class:MSPaintApp]", "")
        Send("{ALTDOWN}{ALTUP}fx")
EndFunc
Func _winwaitactivate($title, $text, $timeout = 0)
        WinWait($title, $text, $timeout)
        If NOT WinActive($title, $text) Then WinActivate($title, $text)
        WinWaitActive($title, $text, $timeout)
EndFunc
Func _winwaitactivate2($title, $text, $timeout = 0)
        WinWait($title, $text, $timeout)
        If NOT WinActive($title, $text) Then WinActivate($title, $text)
        WinWaitActive($title, $text, $timeout)
EndFunc
 楼主| 发表于 2015-10-30 16:27:03 | 显示全部楼层
回复 4# txen548


    谢谢了
发表于 2015-10-30 18:02:30 | 显示全部楼层
是否解決了問題,如已解決,請修改標題。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-26 22:01 , Processed in 0.079214 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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