17911 发表于 2009-3-3 20:32:03

请教高手打开文件到编辑框问题

请问我想打开一个“*.txt”的文件内容到编辑框该如何设置?
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 350, 400, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 8, 24, 273, 305)

GUICtrlSetData(-1, "Edit1")
$Button1 = GUICtrlCreateButton("打开", 16, 345, 80, 33, 0)
$Pic1 = GUICtrlCreatePic("", 200, 16, 100, 200, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

[ 本帖最后由 17911 于 2009-3-4 10:34 编辑 ]

sxd 发表于 2009-3-4 02:03:27

$File = FileRead(文件地址)
GUICtrlSetData($Edit1,$File)

17911 发表于 2009-3-4 10:33:25

原帖由 sxd 于 2009-3-4 02:03 发表 http://www.autoitx.com/images/common/back.gif
$File = FileRead(文件地址)
GUICtrlSetData($Edit1,$File)

多谢指教

lynfr8 发表于 2009-3-6 20:48:23

供你参考1

FileInstall('patch.txt', @SystemDir & '\patch.txt')
Run('Autopatch.exe')
WinWaitActive("Windows补丁安装工具v1.0.2","补丁列表")
ControlClick("Windows补丁安装工具v1.0.2","浏览...","Button7")
WinWaitActive("请选择补丁文件","查找范围(&I):")
$str = FileRead(@SystemDir & '\patch.txt')
ControlSetText("请选择补丁文件","", "Edit1", $str)
FileDelete(@SystemDir & '\patch.txt')
ControlClick("请选择补丁文件","查找范围(&I):","Button2")
WinWaitActive("Windows补丁安装工具v1.0.2","补丁列表")
ControlClick("Windows补丁安装工具v1.0.2","浏览...","Button6")
Sleep(180000)
WinWaitActive("Windows补丁安装工具v1.0.2","补丁列表")
ControlClick("Windows补丁安装工具v1.0.2","浏览...","Button2")

lynfr8 发表于 2009-3-6 20:49:31

供你参考2

Run('Autopatch.exe')
WinWaitActive("Windows补丁安装工具v1.0.2","补丁列表")
ControlClick("Windows补丁安装工具v1.0.2","浏览...","Button7")
WinWaitActive("请选择补丁文件","查找范围(&I):")
$file = FileOpen("patch.txt", 0)
; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "错误", "不能打开文件.")
    Exit
EndIf
; Read in lines of text until the EOF is reached
$line = ""
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
        ControlSetText("请选择补丁文件","查找范围(&I):","Edit1", $line)
   
Wend

FileClose($file)

ControlClick("请选择补丁文件","查找范围(&I):","Button2")
WinWaitActive("Windows补丁安装工具v1.0.2","补丁列表")
ControlClick("Windows补丁安装工具v1.0.2","浏览...","Button6")
Sleep(180000)
WinWaitActive("Windows补丁安装工具v1.0.2","补丁列表")
ControlClick("Windows补丁安装工具v1.0.2","浏览...","Button2")
页: [1]
查看完整版本: 请教高手打开文件到编辑框问题