Jump to content

Problem with open txt file


Recommended Posts

Hi,

i have a tool (txt in xml converter) which contains a OpenFiel dialog Button. If a click on this Button, i should choose a txt.file on my PC, when i choosed it the OpenDialog will disappear and another OpenFile Dialog will appear to select another file. i would to do this steps with AutoIt.

It is not working properly. When the first OpenFile Dialog appear, i put the link of txt.file (C:\ABC\test.txt) with ClipPut(...) then i sent ENTER (Send("{Enter}")). After this Step the second OpenFile dialog does not appear. What is wrong?

manualy wihtout AutoIt it is working when i put C:\ABC\test.txt then i put ENTER with the keyboard the second OpenFile Dialog will appear.

thanks and Regards

Link to comment
Share on other sites

This is my code:

$LogFileName = test.txt
$ScriptPath=C:ABC
$LogFilePath= $ScriptPath & $LogFileName ;C:ABCtest.txt
$temp = FileOpen("temp.txt", 1)
   FileWrite($temp, $LogFilePath)
$readLine=FileReadLine ("temp.txt", 1)
run($ReportingPath) ; to call my tool
WinWaitActive("ATS SystemTester","...",$Timeout) ; to open the first OpenFile Dialog
ControlClick("ATS SystemTester","...", "...") ; to open the first OpenFile Dialog
   ClipPut($readline)
  Send("^v")   ; this will put the path C:ABCtest.txt in the field

After the last step Send("^v"), the second OpenFile Dialog should appear. Also if i delete Send("^v") from my code and run the script, then i put manualy with the keyboard Enter, than works and the second OpenFile Dialog appears.

Edited by marshallprank
Link to comment
Share on other sites

my tool working. And run($ReportingPath) works. If i do the same steps but wihout Send("^v") and when script ends than i put manualy with the keyboard Enter, than works and the second OpenFile Dialog appears. See the Code:

$LogFileName = test.txt
$ScriptPath=C:ABC
$LogFilePath= $ScriptPath & $LogFileName ;C:ABCtest.txt
$temp = FileOpen("temp.txt", 1)
   FileWrite($temp, $LogFilePath)
$readLine=FileReadLine ("temp.txt", 1)
run($ReportingPath) ; to call my tool
WinWaitActive("ATS SystemTester","...",$Timeout) ; to open the first OpenFile Dialog
ControlClick("ATS SystemTester","...", "...") ; to open the first OpenFile Dialog
   ClipPut($readline)
Link to comment
Share on other sites

If this is your actual code, you need quotes around the strings in the $ScriptPath and $LogFilePath variable assignments otherwise they're not going to work. Also, why do you use FileOpen and then read the line from the file using the relative file name? You might want to use some consolewrites to see if the variables contain what you think they contain as a check to see if you're reading the correct information from the file.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Here is the actual code:

$LogFilePath= $ScriptPath & $LogFileName ; this is on the Console: C:ABCtest.txt

ClipPut($LogFilePath)

run($ReportingPath)
  
WinWaitActive("xx","...",$Timeout)
ControlClick("xx","...", "...")

WinWaitActive("Select file","",$Timeout)
ControlClick("Select file","", "")

Send("^v")
Sleep(3000)
Send("{Enter}")
Link to comment
Share on other sites

That can't be your actual code, half of what you posted previously is missing. Including all the points I made about the quotes around your strings. So, where is your ACTUAL code.

Also, does your controlclick work at all the way you have it written? Because you're clicking on a blank controlID. If you don't post the actual code you're using I can't help and I'm out of here.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Here the code:

#include <file.au3>
#include <Process.au3>

$Timeout=IniRead(@ScriptDir & "Config.ini", "TimeOut", "Timeout","NotFound") ;
$ReportingPath=IniRead(@ScriptDir & "Config.ini", "ReportingPath", "ATSSystemTester","NotFound")
$ScriptPath=IniRead(@ScriptDir & "Config.ini", "ScriptPath", "Script","NotFound")
$LogFileName = "test.txt"
$LogFilePath= $ScriptPath & $LogFileName

ClipPut($LogFilePath)
run($ReportingPath)
  
WinWaitActive("ATS SystemTester","...",$Timeout)
ControlClick("ATS SystemTester","...", "...")
 
Send("^v")
Sleep(3000)
Send("{Enter}")
Sleep(2000)

till the step Send("{Enter}") works. After Send("{Enter}") the second OpenFile Dialog does'nt appear.

Link to comment
Share on other sites

Here the code:

till the step Send("{Enter}") works. After Send("{Enter}") the second OpenFile Dialog does'nt appear.

Where is the second OpenFile dialog activated? If the ControlClick activates the dialog box, you only have one in the script, so how is this box supposed to open, and what are you trying to put into it?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I'd guess the problem lies in the parts of whatever script you're using that you're not posting. Obviously we're NEVER going to be able to help you because you refuse to post a reproducer script that demonstrates the problem. I've asked you to post the script you're using to accomplish what you want, and every time you post something it usually shows very little relation to what you posted before, and the parts of the script that aren't working aren't posted at all.

Do you really want help getting this fixed, or are you just jerking our chain to see how far you can take this? If you can't or won't post the parts of the script that don't work, and the parts of the script that do work, then you are on your own. Good luck, the ball is in your court for the last time as far as I'm concerned.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Are you saying that your tool program automatically pops up another file open dialog after entering the first filename followed by an enter? If so the problem is with the tool, not the autoit script.

Try putting EXIT on the line immediately after Send("{Enter}"). Or try making the script click on an OK button or whatever is there instead of sending an ENTER to the dialog... ENTER invokes the default action in a window but perhaps that's not what you want?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...