Notepad file name *.properties attribute change dynamically

Asked by Anup K on 2019-11-15

I have file name listoffileslocation.txt (content will change every day)
Content:
C:\POC\1.txt
C:\POC\2.txt

I have another file name application.properties(its holding application related information)
Content:
extn=.tiff
inputfilelocation= C:\POC\test.txt
size=5kb

Problem :
Need to modify the inputlocation with C:\POC\1.txt, C:\POC\2.txt sequentially and save the application.properties and then run my application specific batch script.How can I would be able to modify particular attribute named inputfilelocation and run application(say run.bat) uisng SikuliX

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
Anup K
Solved:
2019-11-18
Last query:
2019-11-18
Last reply:
2019-11-18
Anup K (anupk) said : #1

Please let me know. Thanks in advance!!

Mike (maestro+++) said : #2

Sikulix's special claim to fame is it scripts visual interfaces. So you need to choose visual interfaces. So the first thing is to run through the process manually. From that, you can decide how to automate the process.

In your case you might use Wordpad to open listoffileslocation.txt. You may be able to locate the list of files by location ie it may appear at a predictable offset from some invariant feature of the Wordpad window. Then you open a second Wordpad window and open application.properties. Highlight the file name and cut and paste in the relevant item from the list file. Save it. Close it and then open a console window that allows you to run run.bat, and call it. Observe the console until you detect it has completed and then progress to the next file in the list, and repeat until you have reached the end of the list of files.

Anup K (anupk) said : #3

Thanks Mike for clarifying it.
I need additional information regarding Sikulix to solve the below problem :
1)How to identify properies named "inpitfilelocation"
2) identify the location of value after "="
3)cut/paste command in sikulix

After that I can take care of save and other operaion.
Need example to

Anup K (anupk) said : #4

Solve the steps in Sikulix. ( Sorry for the new message) . By mistake I posted previous one.

Thanks for your understanding.

RaiMan (raimund-hocke) said : #5

Normally you use Python/Jython for scripting yopur workflows.

Since I guess, that the mentioned files are accessible text files, you can simply use file i/O (open/read/write/close), to work with the files and finally run the .bat file (which in turn could be created by the script before).

So no need, to do it visually.

Mike (maestro+++) said : #6

To add to Raiman's point, if you don't specifically want to use surface automation (as with Sikulix) there are many API or Windows based libraries you can use to automate things. "Automate the Boring Stuff with Python" is a popular book, and indeed has a chapter on pyautogui which does a lot of what Sikulix does.

Anup K (anupk) said : #7

Thanks for your input.

Yeah Mike and RaiMan I can do automation in different way. But idea was to explore on the Surface automation using SikuliX for below problem as I mentioned in previous thread. That will definitely help on other opportunity.

1)How to identify properties named "inputfilelocation"
2)Identify the location of value after "="
3)Cut/paste command in SikuliX

If you can answer it that would be helpful. Please let us know for any concern.

RaiMan (raimund-hocke) said : #8

Again and finally:
use the standard File-I/O methods to access/modify text files.
Effort: about 10-20 lines of code, 1 hour development and testing
solution is 100% reliable and portable in every environment

Why:
It does not make sense to solve this with surface automation, because it is rather complex and not 100% reliable (using OCR for cases, where there are other means to get the text directly).
For your case, I guess the effort: about 30 - 50 lines of code, 3+ hours for development and testing.
... and is not 100% reliable and is not portable in other environments, that have different pixel setups.

Anup K (anupk) said : #9

Thanks RaiMan. Closing the issue.