Monitor value via OCR - windows

Background:
Sometime I have the need to monitor the change of a value in a certain program.
My solution is to use a batch file to capture the part of the screen with where the value is shown with Minicap and then use Tesseract to convert the value to plain text. However this script would not work so good if I would need to monitor value change every second for several hours.
Current solution (simplified example):
minicap.exe -captureregion 800 600 850 620 -save C:\file.png -exit -escapequit
tesseract.exe C:\file.png out.txt
Question:
What I would like is some simple way to OCR a value directly from the screen to use in the batch file, perhaps buffer several values before appending them to a csv file. I would prefer to do this without the need to install python or write compiled software

(Posted on behalf of the question author, to move the solution to the answer space).
I found that I could use Capture2Text. The following command takes the on screen text and prints it to stdout:
Capture2Text_CLI.exe --screen-rect "800 600 850 620"
This way it's possible to run the command, check if the value is changed, and if so, append it to a log file together with a timestamp.

Related

How can I cut several sound files using a script?

I am new to Praat and wondering, if someone can help me to find out, how I can cut all my sound files with a script or anything.
I have like 100 sound files I need for my research. They all have a different length, some are 1 min and others are 3 min long.
I would like to have only the first 22 sec from each sound file.
Thanks in advance!
Kind regards
Olga
The first step is to construct a script that extracts the initial 22 seconds of some specific sound object that is already open. In general, the easiest way to at least start a script is to do a thing manually once, and after you've done that, in a Praat script window, copy the command history (with ctrl-h) to see what the underlying commands are. The manual approach is to look for "Extract part" under "Convert", which corresponds to the command
Extract part: 0, 22, "rectangular", 1, "no"
There is also a command to save a file as a wav file, so you would add that to the core of the script.
Then you need to add a loop that does this a number of times, to different files. You will (probably) need a file with wav file names, and some system for naming the output files, for example if you have "input1.wav", you might want to call the cut-down version "output1.wav". This implies some computation of the output file name based on the input file name, so you need to get familiar with how string manipulation works in Praat.
If you have that much sorted out, then the basic logic is
get next input file name file
compute output name
open the input file
extract from that file
save the extracted file
remove the extract
remove the original
loop until no more files
I would plan on spending a lot of time trying to understand simple things like string variables, or object selection. I left out explicitly selecting objects since it is not necessarily required, but every command works on "the selected object" and it's easy to lose track of what is selected.
Another common approach is to beg a colleague to write it for you.

Redirecting output from a bash command into a script

I'm trying to do some stuff with QR codes and a found a library called ZBar. Once installed it comes with a bash command called zbarcam which reads from a camera and continuously prints out whenever it scans and decodes a QR code (it prints out the decoded value of the QR). I want to, instead of printing the output, take the output and give it as an input to another script so I can do some things with it. TL;DR how can a continuously capture the output from zbarcam and pass it to my script as an input.
Is it from zbar?
They have an example in their manpage:
Scan for barcodes using the second video device and pipe the resulting data through a script that searches for each code in a database and does something useful with them:
zbarcam /dev/video1 | upcrpc.py
The upcrpc.py example script included in the examples/ subdirectory of the distribution will make an XMLRPC call to a popular internet UPC database and print the product description if found.

Script Command -- Extra space and return added to long input

I am creating a browser-based application for interacting with my local terminal, and I'm using the script command in the terminal (actually in a Java process) to feed input and capture output to display in the browser.
I have found that the virtual terminal inside the script process has 80 columns by default, and when a line of input exceeds that number, I see unexpected behavior. When it reaches the length limit, it adds a space, then a return, then continues with the line. For example, if I input the following:
user_name ~/my/current/directory$ ls /some/really/long/path/to/some/directory/somewhere
The following is what is actually transcribed (and forwarded to my browser app):
user_name ~/my/current/directory$ ls /some/really/long/path/to/some/directory/so ^Mmewhere
Notice the so ^Mmewhere instead of somewhere.
When I hit the up arrow after that to retrieve the last input, I get something different:
user_name ~/my/current/directory$ ls /some/really/long/path/to/some/directory/som^Mmewhere
This time, instead of the extra space character, it's duplicating the m: som^Mmewhere.
What is going on here? Is it that the script command is really intended to produce text output for a human reader, and therefore favors visual formatting over executability? Is there an alternative to script that would work better for my purpose?
Edit
I should have mentioned that I'm doing this in macOS Sierra. Not sure if that makes a difference.

GetFileTime always returns same time

I am trying to determine the LastWrite time for a file.
I am using the GetFileTime function, and when I print the the timestamp I get something in hexadecimal.
The I modify the file(text file), using the OS(open it in notepad and add something) and then I close it. In Windows explorer I see the Last Modified field changed, but when I run the program it returns the same timestamp.
Said file is on a USB stick formated to NTFS. Does it have any importance?
Any ideas?
Use GetFileAttributesEx().
Or use _stat() (example code at bottom of page).
Or actually use GetFileTime():
Retrieving the Last-Write Time.

How to get the data displayed in Softice's windows to text file

I can't copy the information in softice to disk/file. I am aware of IceExt but everytime I execute the command to dump the screen to disk(such as "!DumpScreen \??\c:\test.raw")it crashes my system entirely. When I try to copy with the mouse, the cursor only makes it possible to copy one line. I have already read through the softice manual. I just need a way to retrieve data from softice. Any help would be appreciated. I am using xp professional.
Turns out that no addons are required to accomplish this. Using the command "u cs:eip L 1000" from softice. You will then see a duplicate of the data within softice's screen displayed in the command window.
The u 'unassembles' code at the address cs:eip (the current EIP), the L specifies a length of 1000 bytes, you might need more than 1000 so adjust accordingly. Once you've done this you should exit SoftICE and select File / Save SoftICE History As from Symbol Loader, with any luck the resulting file will contain your code dump.You may have to to use F10 to step through inorder to get the data in softice's history log.
Using this method, I successfully dumped the entire code window and data window. The main drawback to this method is that the resulting text will contain alot of noise(unnecessary data). I haven't figured out how to get around this. This is a adaptation of woodmann's method.

Resources