AutoIt的记事本 [英] Autoit and notepad
问题描述
我有一个应用程序,其中我得到一个另存为对话框,对话框。有时,如果一个文件具有相同名称的存在,那么另一个对话框进来,具有相同名称的另存为。以下是code,这是我写的,但预期它不工作。
I have an application, wherein I get a "Save As" dialog-box. At times, if a file exists with the same name, then another dialog box comes in, with the same name "Save As". The following is the code, which I wrote but it doesn't work as expected.
WinWait("Save As")
WinWaitActive("Save As")
ControlClick("Save As", "Save", "[CLASS:Button; TEXT:&Save; INSTANCE:2]")
ControlSetText("Save As","","CLASS:Button; INSTANCE:2]",$file_name)
SendKeepActive("Save As")
Send("{ENTER}")
sleep(4000)
WinWaitActive("Save As","",3)
If WinExists("Save As", "No") Then
Send("{ENTER}")
Endif
If WinExists("Exit OmniPeek") Then
Send("{ENTER}")
Else
sleep(2000)
WinClose($closing_file)
Endif
我们的想法是,以检查是否第二个另存为对话框出现,如果不进来,然后在写现有文件。然而,这似乎并没有与我写的AutoIt脚本中工作。
The idea is to check if the second "Save As" dialog box comes and if does come in, then over-write the existing file. This however, doesn't seem to be working with the autoit script that I wrote.
有人可以帮我这个脚本?通过使用记事本以及可以重新创建的问题。只要有一个名称的abc.txt的文件,并尝试保存一个文件具有相同名称
你会得到另一个对话框名称为另存为。
Can someone help me with this script? You can re-create the issue by using Notepad as well. Just have a file with a name abc.txt and try to save a file with the same name You will get another dialog box with the name "Save As".
推荐答案
试试这个:
Example()
Func Example()
; Run Notepad
Run("notepad.exe")
; Wait 10 seconds for the Notepad window to appear.
Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)
; Keep the Notepad window active when using the Send function.
SendKeepActive("[CLASS:Notepad]")
; Simulate entering a string of text. If you try to change to a different window other than Notepad, then the Notepad window will
; be brought to focus again.
For $i = 1 To 10
Sleep(5)
Send("notepad - ")
Next
; Disable the Notepad window being active when using the Send function.
SendKeepActive("")
; Close the Notepad window using the handle returned by WinWait.
WinClose($hWnd)
Send("{ENTER}") ; <<< SAVE
; Now a screen will pop up and ask to save the changes, the classname of the window is called
; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file"
WinWaitActive("[CLASS:#32770]", '', 2)
Sleep(50)
Send('newName.txt')
Sleep(1000)
Send("{TAB}{ENTER}")
EndFunc ;==>Example
这篇关于AutoIt的记事本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!