Thank Melba23 to reminder me. Here is the code for the first question. There are Chinese words in the code, I doubt whether friends could understand me...
It's a simple application. I mean to get text from some textboxes in a window automaticlly. Then write the data into a text file, and an opening notepad as well.
When I run it in the SCiTE(ACN) 2.29, it goes well. After compiling to exe, it runs with no effection...
WinWait("通用测量","开始测量")
Local $var_file = "C:\record.txt"
Local $file_id = FileOpen ($var_file,1)
If $file_id=-1 Then
MsgBox (0, "", "文件有错误,必须退出脚本!")
Exit
EndIf
Run("notepad.exe")
WinWaitActive("无标题 - 记事本") ;"untitled - notepad"
ControlSend("无标题 - 记事本", "", "Edit1", "年-月-日 时:分:秒" & @TAB & "CO" & @TAB & "CO2" & @TAB & "HC" & @TAB & "NO" & @TAB & "O2" _
& @TAB & "λ" & @TAB & "油温" & @TAB & "转速{ENTER}")
FileWriteLine($file_id, "年-月-日 时:分:秒" & @TAB & "CO" & @TAB & "CO2" & @TAB & "HC" & @TAB & "NO" _
& @TAB & "O2" & @TAB & "λ" & @TAB & "油温" & @TAB & "转速")
;code up write the data title like date, oxygen, etc.
Local $var_time = ""
Local $var_data = ""
While WinExists("通用测量", "开始测量")
$var_time = @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
$var_data = ControlGetText("通用测量", "开始测量", "Edit2") & @TAB & ControlGetText("通用测量", "开始测量", "Edit3") _
& @TAB & ControlGetText("通用测量", "开始测量", "Edit4") & @TAB & ControlGetText("通用测量", "开始测量", "Edit5") _
& @TAB & ControlGetText("通用测量", "开始测量", "Edit6") & @TAB & ControlGetText("通用测量", "开始测量", "Edit7") _
& @TAB & ControlGetText("通用测量", "开始测量", "Edit8") & @TAB & ControlGetText("通用测量", "开始测量", "Edit9")
ControlSend("无标题 - 记事本", "", "Edit1", $var_time & @TAB & $var_data & "{ENTER}")
FileWriteLine($file_id, $var_time & @TAB & $var_data)
Sleep(560)
WEnd
FileClose($file_id)
MsgBox(0, "", "五气上位机测量窗体已经关闭,退出脚本!")