Read content of cursor location in terminal/Shell - shell

I'm working on a unique project using terminal/Shell but I've hit a little bit of a roadblock I haven't been able to work around.
I want to be able to read the content of the location of the cursor.
For example, if the cursor is currently located on line 2, column 5 which contains an E, I want to be able to read that E and create a variable with it.

Can you explain what your project entails? It might help if we knew what you're trying to accomplish.
No tools exist to do this in the shell, as far as I know. To actually read a remote screen would require this as a feature of the remote terminal (or emulator).
Neither do any compiled language support this. All applications that appear to do this fake it by keeping an internal copy of what they assume is displayed on the screen.
Lookup the curses* library for more information. This toolkit allows a programmer to address the screen as a random accessible grid, and hides all of the updates to the actual terminal screen.
See also: ncurses

Related

What is the underlying library/program to programs like less or top

Programs like less, top, htop, git-log, man and also editors like vi, vim or nano all open in this well known sort of "window" in the terminal, that is different from the typical prompt you normally work with.
Example:
When using cat it simply prints out the results onto stdout and shows you the prompt again.
On the other hand, when using top it goes into this separate "window" to display the information and even update it dynamically. Obviously it isn't a window as we understand it today, it just seems to be a visual trick where they overwrite the entire terminal screen repeatedly. Still, I think the analogy fits.
I was wondering, what is the underlying library or program that is used here? What is the proper name for such a "window"?
I do know about libraries like ncurses, which do similar stuff to what I am talking about, but I cant find any reference that for example top is using this library specifically. Also it looks quite differently from screenshots I have seen - might just be configuration.

Can the last opened file location be directly altered?

As I understand it, when a file open dialog box (such as GetOpenFileName) is used, Windows will automatically remember where the last file was that was opened by the program, and Windows remembers these locations separately for each program. Is there a way to directly alter this, in order to cause the file picking dialog for program X to start in C:\Example\Directory?
I'm attempting to automate a program which has been programmed to work only through a GUI, and I don't have any access to the internals of this program (such as being able to alter how it calls the file picker). Instead, I'm using a mouse macro (via AutoHotkey). If I can be completely sure that the file picker will start in a particular place, I should be able to automate the rest with mouse clicks.
If you had access to the source code, I'd suggest you just change the lpstrInitialDir property of the OPENFILENAME passed to GetOpenFileName().
Outside of that, you'll want to change the registry keys for the MRUs:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32
What might make more sense, and might fix the issue you're having, is also changing the Working Directory so that the default location isn't "My Documents", if you're experiencing that.
Depending on the operating system, the results vary:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646839%28v=vs.85%29.aspx

GUI frontend for R script

We have a set of R scripts, which process some data and produce some results. We want to make these scripts available to basic users, which are not used to commandline of R - we want to provide them some nice GUI, which would allow to:
import/export data from MS Excel/Access easily (also supporting Copy/Paste if possible)
allow user to change settings/parameters of the process
should be running in MS Windows.
Is there any simple, scripting environment which would allow to develop such nice GUI for our R scripts as fast as possible? Need not necessarily be in R language.
There is the RExcel tool that incorporates R as an Excel plugin so the main interface is Excel with R doing the computations in the background. You could set up a sheet so that the user enters their data, then highlights a box and then chooses a menu item or clicks a button and the results are placed in another cell (or set of cells). Note however, that RExcel and the comunication program it user are not free.
Another option is to create your own gui function in R, then have that gui run automatically when you start R (see ?STARTUP) and set this up on the users machine. I have done this for clients before that did not know anything about R, they just double clicked on the icon on the desktop (windows), minimized the main R window when it opened, interacted with the gui that I had programmed to run (I used tcltk, but there are others) and saw the output provided.
You can get data copied from Excel by having the user select the data and click on copy, then in your program run newdata <- read.delim('clipboard') and the data will be in the data frame called 'newdata', you can use write.table(outdata, file='clipboard', delim='\t') to put the data from data frame 'outdata' onto the clipboard and the user can then paste it into Excel (or other programs).
There is also the Rcmdr package which provides a general GUI for R (basic tools) but also has a mechanism where you can create your own menus and dialog boxes for use with the GUI.
You didn't say it had to be a desktop program. So Jeroen Ooms' hilarious openCPU project might be worth a look. He basically calls it statistical computing in the cloud. The guys has been really active recently (now that I checked the website again, I realized it's new again).
Also, his earlier work stockplot or ggplot demo is very interesting. Especially a brief look at stockplot gives you an impression quickly of his approach.
Afaik, RApache is used and the nice frontend GUI is created with EXTJS .
I think the documentation can explain the approach much better than I do.
I think R on a webserver – particularly for intranet use is a good solution (depending on the size of your company), because:
it's platform independent, clients can use their favorite browsers
local development and deployment of script and even whole R pakacges is easy
Reporting / Publishing is big strength of R and can be facilitated using a web based architecture (see packages like knitr or sweave
In this question I just come around R shiny:
http://www.rstudio.com/shiny/

Want to resize other applications running in Windows

I'm looking for the cleanest way to get all open windows and have access to moving/resizing them. I'd like to be able to get their current locations and move them where I'd like.
I want access to all windows, not just top level ones.
Thanks
One way to get the list of processes running is shown on this tutorial: Win32 APIs for Process Retrieval. Another way is through EnumDesktopWindows.
If at this point you have access to the window's handle then you can move it with SetWindowPos(). But if you only have access to it's title, then you'll need to use FindWindow() first and obtain a handle to that window.
Here is an example that shows how to do several different operations on a specific window, including how to move it to another location.

Creating quick GUI front ends

I wanted to have a GUI front-end for a script that accepts numerous command-line options, most of them are UNIX paths. So I thought rather than typing them in (even with auto-completion) every time, I'd create a GUI front end which contains text boxes with buttons beside them, which when clicked will invoke the file browser dialogue. Later, I thought I'd extend this to other scripts which would sure require a different set of GUI elements. This made me think if there's any existing app that would let me create a GUI dialog, after parsing some kind of description of the items that I want that window should contain.
I know of programs like Zenity, but I think it's doesn't give me what I want. For example, if I were to use it for the first script, it'll end up flashing sequence of windows in succession rather than getting everything done from a single window.
So, basically I'm looking at some corss-platform program that lets me create a window from a text description, probably XML or the like. Please suggest.
Thanks
Jeenu
Mozilla's XUL is a cross platform application framework - . You could write an app as a Firefox plugin or a standalone XUL application.
mono and monodevelop could work for this. Or even something super simple like shoes.

Resources