Hi, everyone
I'm trying to create an empty file with notepad, paste in it some information that I copied from excel and then save the file. I made an autohotkey script to create and fill the txt file.
But now I want to save the txt file with a name that alredy exists in the folder. Can someone, please, tell me how to do that with autohotkey?
Thank you in advance.
Save a txt file with a specific name Topic is solved
Re: Save a txt file with a specific name Topic is solved
See below. There are different ways to click the buttons, and the way I chose seems more reliable than at least the one alternative shown. You can improve reliability by putting in checking loops that retry it if it doesn't work at first. Also, the Sleep command may or may not be necessary, but it can help when it is proving not to be 100% reliable. Could add one for the second window if needed.
Code: Select all
FileFullPath := "F:\misc\MyFile.txt"
WinMenuSelectItem, Untitled - Notepad ahk_exe notepad.exe,, File, Save
WinWait, Save As ahk_exe notepad.exe
ControlSetText, Edit1, %FileFullPath%, Save As ahk_exe notepad.exe
Sleep, 500
ControlFocus, Button2, Save As ahk_exe notepad.exe
Send, {Space}
; ControlClick, Button2, Save As ahk_exe notepad.exe ; not as reliable as above
WinWait, Confirm Save As ahk_exe notepad.exe
ControlFocus, Button1, Confirm Save As ahk_exe notepad.exe
Send, {Space}
Re: Save a txt file with a specific name
Thank you very much, boiler, for your help. You saved my day.
Here is the result of this part of my script I adapted because of my language.
I use portuguese language (PT.pt)
Thank you again.
Here is the result of this part of my script I adapted because of my language.
I use portuguese language (PT.pt)
Code: Select all
vPathNotepad := "C:\WINDOWS\system32\notepad.exe"
vPath := A_ScriptDir "\Untitled.txt"
FileAppend,, % "*" vPath, UTF-16
Run, "%vPathNotepad%" "%vPath%"
WinWait, ahk_class Notepad
WinActivate
WinMenuSelectItem, Untitled - Bloco de notas,, Ficheiro, Guardar como
WinWait, Guardar como ahk_exe notepad.exe
sleep 100
Control, Choose, 2, ComboBox2, Guardar como ahk_exe notepad.exe
sleep 100
ControlFocus, Edit1, Guardar como ahk_exe notepad.exe
sleep 100
SendInput BAO_Final.fdf
Sleep, 100
send, {TAB}
sleep 100
ControlFocus, Button2, Guardar como ahk_exe notepad.exe
sleep 100
Send, {Enter}
WinWait, Confirmar Guardar Como ahk_exe notepad.exe
ControlFocus, Button1, Confirmar Guardar Como ahk_exe notepad.exe
sleep 100
Send, {Enter}
WinWait, BAO em branco - Excel, ; that's a workbook where I the data I need to put in the pdf form
IfWinNotActive, BAO em branco - Excel, , WinActivate, BAO em branco - Excel,
WinWaitActive, BAO em branco - Excel,
StatusBarWait , Pronto
Xl := ComObjActive("Excel.Application")
Nif:= Xl.Range("A2").Value
StringLeft, Nif, Nif, (StrLen(Nif)-7)
Sleep 100
Clipboard =
Xl.Range("K1:K388").Select
Xl.Range("K1:K388").Copy
ClipWait
WinWait, BAO_Final.fdf - Bloco de notas
WinActivate, BAO_Final.fdf - Bloco de notas
sleep 100
ControlFocus, Edit1, BAO_Final.fdf - Bloco de notas ahk_exe notepad.exe
SendInput, %Clipboard%
sleep 500
WinMenuSelectItem, BAO_Final.fdf - Bloco de notas,, Ficheiro, Guardar
sleep 100
WinMenuSelectItem, BAO_Final.fdf - Bloco de notas,, Ficheiro, Sair
sleep 100
PDFtkEXE := A_ScriptDir "\pdftk.exe" ;that's a very nice tool to work with pdf documents
PDFform := "BAO_em_Branco.pdf"
FDFfile := "BAO_em_Branco.fdf"
FDFtemp := "BAO_Final.fdf"
PDFtemp := "BAO_em_Branco1.pdf"
Sleep, 200
RunWait, %PDFtkEXE% "%PDFform%" fill_form "%FDFtemp%" output "%PDFtemp%",,Hide ;This line doesn't work and I don't know yet why...
Sleep 100
ExitApp
Who is online
Users browsing this forum: inseption86, mikeyww and 392 guests