-
Posts
19 -
Joined
-
Last visited
Everything posted by Rhazz
-
I can't activate the "File Open" window on Chrome and Edge
Rhazz replied to Rhazz's topic in AutoIt General Help and Support
Sorry mate, but I don't understand. Control+O opens the "File Open" window... but I'm asking about how to use that window on Chrome and Edge, where at the moment I can't find this window (I mean handle with AutoIt), to write the file directory and use the open button. AutoIt just doesn't find the window by its title, and so I can't use it.- 5 replies
-
- winactivate
- chrome
-
(and 3 more)
Tagged with:
-
Hi, I'm trying to upload a file with a web browser but I can't select the Open File window to select the file that I want to upload. TL;DR I can't handle the Open File window of Chrome and MS Edge. AutoIt just doesn't find it by its title (in Firefox yes, but not on Chrome and MS Edge). With another software (Selenium Webdriver in Python) I access to a web page with a common HTML5 file uploader and I click on it, but when the Open File window comes up, I want to select a file and press Enter (write the filepath that I give and press Enter key or Open button). I have the idea, and I have the script on AutoIt too... but it doesn't work on Windows Edge and Chrome, only works on Firefox and Pale Moon (who are basically the same). Here is my code: #include <MsgBoxConstants.au3> $title = "Abrir" ; My Windows is in spanish, but I guess it's "Open" in English and it's the same code WinActivate($title) If WinActive($title) Then send("C:\Users\myuser\images\my_image.jpg") Send("{ENTER}") Else MsgBox($MB_SYSTEMMODAL, "WinActive", "Window not found.") EndIf In Firefox (and Pale Moon) the Open File window comes up, the file path is written and the Enter key is pressed. It works perfect. In Chrome and Edge, I never see the Open File window on top... and I neither see "Window not found" message (seems like AutoIt finds it but doesn't send keys). Edit: before to send this post, I started thinking again and... after several tests, I discovered one thing: when you select the window, in Firefox (and Pale Moon) the cursor goes to the combobox (where I have to put the text) and it's possible to write just after clicking (or opening, what in AutoIt it is "Activate" I guess) the window but in Chrome and Edge it isn't like that, when you click the window, the cursor doesn't go to the combobox. With that "discovery", I tried to select the combobox but... I failed again. And now I have no idea how to go ahead. #include <MsgBoxConstants.au3> $title = "Abrir" WinActivate($title) If WinActive($title) Then ControlClick($title, "", 1148) ; Still it does not work send("C:\Users\myuser\images\my_image.jpg") Send("{ENTER}") Else MsgBox($MB_SYSTEMMODAL, "WinActive", "Window not found.") EndIf
- 5 replies
-
- winactivate
- chrome
-
(and 3 more)
Tagged with:
-
How to configure a GUI Progress Bar by a double "for" loop
Rhazz replied to Rhazz's topic in AutoIt GUI Help and Support
That doesn't work because I need to exclude the empty lines, but what you say will return the numbers of non-empty lines and the script will read that numbers of lines but without skip the blank lines. A good news: Finally I could set the progress bar! It works now! I used "Total Of Lines" / ("Current Line" * 100) Finally I got the solution!!!! I created another variable to set what line have to read the script. Here is my full code, I hope be helpful for somebody #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <File.au3> #include <String.au3> #include <Array.au3> Local $idGUI = GUICreate("ProgressBar", 220, 130, 100, 200) Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEButton") Local $idInput = GUICtrlCreateInput("",80,20,60,20,$ES_NUMBER) Local $idProgressBar = GUICtrlCreateProgress(10, 60, 200, 20) Local $idButton1 = GUICtrlCreateButton("Start",85,100,50) GUICtrlSetOnEvent($idButton1, "StartProgressBar") Local $aFileOpen = _WinAPI_GetOpenFileName("Open a text file", "Text Files (*.txt)") Local $idCountLines = _FileCountLines($aFileOpen[2]) Local $idInputValue, $idSomething, $aFileResult, $idStringBetween, $LineToRead, $totalNonEmptyLines For $y = 1 To $idCountLines If FileReadLine($aFileOpen[2],$y) <> "" Then $totalNonEmptyLines += 1 Next GUISetState(@SW_SHOW, $idGUI) While 1 Sleep(20000) WEnd Func StartProgressBar() If StringInStr($aFileOpen[2], ".txt") = True Then $idInputValue = Int(GUICtrlRead($idInput)) If IsFloat($totalNonEmptyLines/$idInputValue) = 1 Then $idStringBetween = _StringBetween(String($totalNonEmptyLines/$idInputValue),"", ".") $idSomething = Number($idStringBetween[0]) + 1 Else $idSomething = $totalNonEmptyLines/$idInputValue EndIf For $i = 1 To $idSomething $aFileResult = @ScriptDir & "\result-" & $i & ".txt" _FileCreate($aFileResult) FileOpen($aFileResult,2) For $a = ( ( ( $i - 1 ) * $idInputValue ) + 1 ) To ( $i * $idInputValue ) $LineToRead += 1 While FileReadLine($aFileOpen[2], $LineToRead) = "" $LineToRead += 1 If $a = $idCountLines Then ExitLoop WEnd GUICtrlSetData($idProgressBar, (($LineToRead*100)/$totalNonEmptyLines)) FileWrite($aFileResult,FileReadLine($aFileOpen[2], $LineToRead) & " - ") Next FileClose($aFileResult) Next MsgBox(0,"Done","Done") GUICtrlSetData($idProgressBar,0) Else MsgBox(0,"Hello :)","Please open a file :D") EndIf EndFunc Func CLOSEButton() Exit EndFunc -
How to configure a GUI Progress Bar by a double "for" loop
Rhazz replied to Rhazz's topic in AutoIt GUI Help and Support
I said that ContinueLoop doesn't work, I want to skip a line, not skip a loop. Sorry if I didn't explain me well. Here are another example with the code: #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <File.au3> #include <String.au3> #include <Array.au3> Local $idGUI = GUICreate("ProgressBar", 220, 130, 100, 200) Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEButton") Local $idInput = GUICtrlCreateInput("",80,20,60,20,$ES_NUMBER) Local $idProgressBar = GUICtrlCreateProgress(10, 60, 200, 20) Local $idButton1 = GUICtrlCreateButton("Start",85,100,50) GUICtrlSetOnEvent($idButton1, "StartProgressBar") Local $aFileOpen = _WinAPI_GetOpenFileName("Open a text file", "Text Files (*.txt)") Local $idCountLines = _FileCountLines($aFileOpen[2]) Local $idInputValue, $idSomething, $aFileResult, $idStringBetween GUISetState(@SW_SHOW, $idGUI) While 1 Sleep(20000) WEnd Func StartProgressBar() If StringInStr($aFileOpen[2], ".txt") = True Then $idInputValue = Int(GUICtrlRead($idInput)) If IsFloat($idCountLines/$idInputValue) = 1 Then $idStringBetween = _StringBetween(String($idCountLines/$idInputValue),"", ".") $idSomething = Number($idStringBetween[0]) + 1 Else $idSomething = $idCountLines/$idInputValue EndIf For $i = 1 To $idSomething $aFileResult = @ScriptDir & "\result-" & $i & ".txt" _FileCreate($aFileResult) FileOpen($aFileResult,2) For $a = ( ( ( $i - 1 ) * $idInputValue ) + 1 ) To ( $i * $idInputValue ) If FileReadLine($aFileOpen[2], $a) = "" Then ; ContinueLoop ; Here I have no idea how can I continue with the next $a as if the current $a, I do not skip it because the line is an element less EndIf GUICtrlSetData($idProgressBar, (100/($i*$a))) MsgBox(0,"",(100/($i*$a))) FileWrite($aFileResult,FileReadLine($aFileOpen[2], $a) & " - ") ; Here I want to set the progress bar value = current percentage (line that it is currently reading) of the 100% (total of lines in the file opened) Next FileClose($aFileResult) Next MsgBox(0,"Done","Done") Sleep(5000) GUICtrlSetData($idProgressBar,0) Else MsgBox(0,"Hello :)","Please open a file :D") EndIf EndFunc Func CLOSEButton() Exit EndFuncWith a first text file that contains: And if the user introduces "6" the result is: result-1.txt --> Line1 - Line2 - Line3 - Line4 - Line6 - (five lines, the user wants six)result-2.txt --> Line7 - Line8 - Line9 - Line10 - Line11 - Line12 - (six lines, great)I have been reading the Help File and I think that there are two options that might work: Read the text file and create a temporary file without blank lines, and use it to create the final text file.Try to use _FileReadToArrayWhat do you think about it? What is most effectively? Are there a better option? And with that code, the progress bar works wrong :s I didn't find the correct operation, I think that might it works with _FileReadToArray (the total of it would be 100% and the current row/position would be the current percentage). PS: I also think maybe using _FileReadToArray might be too much work for big text files... I'm wrong? -
How to configure a GUI Progress Bar by a double "for" loop
Rhazz replied to Rhazz's topic in AutoIt GUI Help and Support
Spanish: Veo que hablás español, así que hola! "ContinueLoop" salta la linea del primer archivo y no la agrega a la linea del segundo archivo, ejemplo: Línea 1 - Línea 2 - Línea 3 -Línea 5 - Línea 6 - Línea 7- Línea 8 -Si te fijas, saltó la línea 4 (suponiendo que está vacía). Igualmente tengo que mirarlo con detenimiento para ver qué puedo hacer, pero no he tenido tiempo. English: Hi, with ContinueLoop the script skips the empty line (of the first file) and therefore there is an element less in the line of the second file (the empty line of the first file becomes into empty space in the second file). e.g. the user wants four lines (of the 1st file) per line (of the 2nd file) and the fourth line (of the 1st file) is empty: Line 1 - Line 2 - Line 3 -Line 5 - Line 6 - Line 7 - Line 8In the first line there is an element less.Whatever, I have to try it again, these days I didn't have much time. -
Hello again, my second post in 24 hs! It's my first GUI... and my first progress bar also! Sorry if I make a newbie mistake. I want to configure a GUI Progress Bar by a double "for" loop. Here is my code with a specific annotation with what I want to do: Edit: new problem, I have no idea how can I continue with the next $a as if the current $a, I do not skip it because the line is an element less (I need help with both problems): #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <File.au3> #include <String.au3> #include <Array.au3> Local $idGUI = GUICreate("ProgressBar", 220, 130, 100, 200) Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEButton") Local $idInput = GUICtrlCreateInput("",80,20,60,20,$ES_NUMBER) Local $idProgressBar = GUICtrlCreateProgress(10, 60, 200, 20) Local $idButton1 = GUICtrlCreateButton("Start",85,100,50) GUICtrlSetOnEvent($idButton1, "StartProgressBar") Local $aFileOpen = _WinAPI_GetOpenFileName("Open a text file", "Text Files (*.txt)") Local $idCountLines = _FileCountLines($aFileOpen[2]) Local $idInputValue, $idSomething, $aFileResult, $idStringBetween GUISetState(@SW_SHOW, $idGUI) While 1 Sleep(20000) WEnd Func StartProgressBar() If StringInStr($aFileOpen[2], ".txt") = True Then $idInputValue = Int(GUICtrlRead($idInput)) If IsFloat($idCountLines/$idInputValue) = 1 Then $idStringBetween = _StringBetween(String($idCountLines/$idInputValue),"", ".") $idSomething = Number($idStringBetween[0]) + 1 Else $idSomething = $idCountLines/$idInputValue EndIf For $i = 1 To $idSomething $aFileResult = @ScriptDir & "\result-" & $i & ".txt" _FileCreate($aFileResult) FileOpen($aFileResult,2) For $a = ( ( ( $i - 1 ) * $idInputValue ) + 1 ) To ( $i * $idInputValue ) If FileReadLine($aFileOpen[2], $a) = "" Then ; Here I have no idea how can I continue with the next $a as if the current $a, I do not skip it because the line is an element less EndIf FileWrite($aFileResult,FileReadLine($aFileOpen[2], $a) & " - ") ;Here I want to set the progress bar value = current percentage (line that it is currently reading) of the 100% (total of lines in the file opened) Next FileClose($aFileResult) Next MsgBox(0,"Done","Done") GUICtrlSetData($idProgressBar,0) Else MsgBox(0,"Hello :)","Please open a file :D") EndIf EndFunc Func CLOSEButton() Exit EndFunc Thanks in advance.
-
Hello. First of all, my full code: #include <WinAPI.au3> #include <File.au3> #include <String.au3> Local $aFiles, $IntOrFloat Local $aFileToRead = _WinAPI_GetOpenFileName("Open file to read", "Text Files (*.txt)") Local $aFinalFile = _WinAPI_GetSaveFileName("How do you want to save the file?", "Text Files (*.txt)") Local $sFilenameWithoutExtension = _StringBetween($aFinalFile[2],"",".") Local $sLinesPerLine = InputBox("Lines Per Line", "How many lines per line do you want?","","") Local $sCountLines = _FileCountLines($aFileToRead[2]) If ($sCountLines/$sLinesPerLine) >= 1 Then ; When the division result is a number with decimal, there will be less words in the last file and the script won't create it , therefore I add 1 to the result to prevent a file lack. Am I wrong? For example: if user introduces 3 the operation will be "4/3=1.33" and I need two files, the first "line1,line2,line3" and the second "line4". $IntOrFloat = $sCountLines/$sLinesPerLine Else $IntOrFloat = ($sCountLines/$sLinesPerLine) + 1 EndIf For $i = 1 To $IntOrFloat MsgBox(0,"", "Creating file " & $i) $aFiles = $aFinalFile[1] & "\" & $sFilenameWithoutExtension[0] & "-" & $i & ".txt" _FileCreate($aFiles) FileOpen($aFiles,2) For $a = ( ( ( $i - 1 ) * $sLinesPerLine ) + 1 ) To ( $i * $sLinesPerLine ) FileWrite($aFinalFile[2],FileReadLine($aFileToRead[2], $a) & ",") Next FileClose($aFiles) Next MsgBox(0,"Done","Done")With it I want to read a text file with a lot of lines and I wanna split it in multiple files with multiple lines (of the first file) in each line, separated by commas. For example: the user executes the script and selects a text file to open that contains: Then, the user selects the path and name of the result files. Suppose "C:\result.txt" Finally, the user introduces the number of lines per line (lines of the initial text file to each line of the result text files). Suppose the user enters 2. So far my code works fine. But I tried to code a loop for do (continuing the example): Start first loop repetition.Create "C:\result.-1.txt", and write on it "Line 1 asdf,Line 2 asdf"End first loop repetition.Start second loop repetition.Create "C:\result.-2.txt", and write on it "Line 3 asdf,Line 4 asdf"End second loop repetition.But my code results (continuing the example) in three files created: C:\result.txt that contains "Line 1 asdf,Line 2 asdf,Line 3 asdf,Line 4 asdf,"C:\result.-1.txt that contains nothing.C:\result.-2.txt that contains nothing.Where is the error? I can't understand where is it...
-
No, I didn't forget a parenthesis. You placed in your code four opening parentheses and three closing parentheses. And yes, I have read the help file but I'm newbie on AutoIT, and I'm here to learn and improve my programing skill. I haven't understood why it's wrong to use a "for" loop in my code, sorry!
-
Hello! I have a "syntax error" but I can't understand where is it. Can you help me with this? There is two text files. I want to write three lines of the first file in each line of the second file. Then, if the first file has 600 lines, the second file should have 200 lines. I hope I have explained well what I want. #include <File.au3> Local $sFile1 $sFile1 = "File1.txt" Local $sFile2 $sFile2 = "File2.txt" Local $sThreeLinesIntoOne FileOpen($sFile1,0) FileOpen($sFile2,2) For $i In ( _FileCountLines($sFile1) / 3 ) For $a = ( ( $i - 1 ) * 3 ) + 1 ) To ( $i * 3 ) $sThreeLinesIntoOne = $sThreeLinesIntoOne & FileReadLine($sFile1, $a) Next FileWriteLine($sFile2, $sThreeLinesIntoOne) Next FileClose($sFile2) FileClose($sFile1)AutoIt returns:
-
Thanks, Both codes worked fine! Oh, sorry! I looked very quickly the link and I thought that there was not what I was looking for. I could make it work! Now I will continue with the rest of the functions that I want to introduce in the program Thank you so much guys!
-
I still don't know where I have to put the FFmpeg library files.
-
Thanks! But also I have a doubt about using FFmpeg in AutoIt. Where I have to put the FFmpeg files? In the same folder as my AutoIt script?
-
I will try your code but how can I integrate FFmpeg to AutoIt and then compile in a .exe only file. I want a final .exe without other files, and I want that the users could execute the program without installing anything. I don't know how to integrate FFmpeg (I'm very newbie, sorry) and then compile all together in a .exe file. Thanks a lot.
-
@JLogan3o13 first, thanks! My code isn't finished, but here it is: #include <Array.au3> #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> Local $nombreVideoSinExtension $nombreVideoSinExtension = InputBox("Definir nombre","Elige un nombre para el archivo final SIN EXTENSION ya que será un mp4","video-final","",-1,-1) Local $videoFinal $videoFinal = $nombreVideoSinExtension & ".mp4" Local $duracionVideoFinal $duracionVideoFinal = InputBox("Definir duración","Define la duración del video expresada en segundos","10","",-1,-1) Local $videoResolucion $videoResolucion = InputBox("Definir resolución","Define la resolución del video","1280x720","",-1,-1) Local $imagenes $imagenes = InputBox("Escoger imagen","Escribe el nombre de la imagen CON SU EXTENSION que será el fondo del video","audio.mp3","",-1,-1) Local $duracionCadaImagen $duracionCadaImagen = 5 Local $relacionDeAspecto $relacionDeAspecto = "4:3" Local $audioVideo $audioVideo = InputBox("Escoger audio","Escribe el nombre del audio CON SU EXTENSION","imagen.jpg","",-1,-1) Local $velocidadAlCodificar ;$velocidadAlCodificar[] = [ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow] Local $fpsVideoFinal $fpsVideoFinal = 20 EstablecerVelocidadAlCodificar() Func EstablecerVelocidadAlCodificar() ; Create a GUI with various controls. Local $InterfazEstablecerVelocidadAlCodificar = GUICreate("Elige la velocidad de codificación", 300, 200) ; Create a combobox control. Local $idComboBox = GUICtrlCreateCombo("", 10, 10, 185, 20) Local $idClose = GUICtrlCreateButton("Cerrar", 210, 170, 85, 25) ; Add additional items to the combobox. GUICtrlSetData($idComboBox, "ultrafast|superfast|veryfast|faster|fast|medium|slow|slower|veryslow", "fast") ; Display the GUI. GUISetState(@SW_SHOW, $InterfazEstablecerVelocidadAlCodificar) Local $sComboRead = "" ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idClose ExitLoop Case $idComboBox $sComboRead = GUICtrlRead($idComboBox) MsgBox($MB_SYSTEMMODAL, "", "Elegiste " & $sComboRead & " como velocidad de codificación", 0, $InterfazEstablecerVelocidadAlCodificar) $velocidadAlCodificar = $sComboRead EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($InterfazEstablecerVelocidadAlCodificar) EndFuncAnd the FFmpeg code with AutoIt variables: ffmpeg -loop 1 -framerate 1/$duracionCadaImagen -i $imagenes -i $audioVideo -c:v libx264 -s $videoResolucion -t $duracionVideoFinal -aspect $relacionDeAspecto -c:a libvo_aacenc -ac 2 -ab 128k -r $fpsVideoFinal -preset $velocidadAlCodificar $videoFinalI want to create a program to generate a video from a combination of images+audio+text (code for insert text isn't written yet). Remember, I didn't finished the code, it have some errors or missing elements.
-
Hello people. First of all, my English may contain errors, because I'm not a English speaker. If someone wants to correct my writing, I will accept it with pleasure. I'm learning AutoIt from scratch since two weeks ago. So I am still a newbie. Sorry if my question is repeated or very basic, but I couldn't find the answer on Google or in this forum. Yesterday, I've learned about FFmpeg and I developed a small code that is what I need. The problem is that I don't know how I can use FFmpeg in AutoIt. I already have the interface coded in AutoIt and, on the other hand, the code of the function what I need coded using FFmpeg. The two codes are separated and I want to join them. Thanks, regards.