Search the Community
Showing results for tags 'open file'.
-
Need to check if file is ready to open.
AutoitMike posted a topic in AutoIt General Help and Support
A process of mine opens a HML file, modifies it and then saves, closes it. I then need to run an.exe that opens this file right after this.. However, nothing that I find on this forum works that supposedly tests to see if the fie is still open, ready to be used by another process. Right now, I just Sleep(2000) . I would like something cleaner than this. This function, for example, returns False when nothing has it opened or if I open the file with notepad or any other editor. I am running on a win7 laptop, if that has any bearing. $File="C:\Utilities\test\report.hr5" MsgBox(0,"", _FileInUse($File)) Exit Func _FileInUse($sFilePath) ; By Nessie. Modified by guinness. Local Const $hFileOpen = _WinAPI_CreateFile($sFilePath, $CREATE_ALWAYS, $FILE_SHARE_WRITE) If $hFileOpen Then _WinAPI_CloseHandle($hFileOpen) Return False EndIf Local $fReturn = False If _WinAPI_GetLastError() = 32 Then $fReturn = True Return $fReturn EndFunc -
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: