I am using Ruby 1.9.1p430 (2010-08-16 revision 28998) on MS Ws7 with MS Office 2010
I have launched a copy of Word from Ruby using WIN32OLE:
wd = WIN32OLE.new('Word.Application')
All works fine, I can manipulate my document as required.
However, the Word window is in the background and I would like to bring it to the foreground so that the user sees the window and can interact with it as necessary.
I have done some reading but cannot find a way to do this using Ruby.
Any help or pointers in the right direction greatly appreciated.
You are using
wd.visible = true
And it is still in the background?
Good luck :-)
Unfortunately, that sort of thing is both os specific, and not in the standard libs, so it is going to be tough. First thing is dig through the WIN32OLE docs a bit http://ruby-doc.org/stdlib/libdoc/win32ole/rdoc/index.html, but I don't think it will be there.
after that, I would poke around github a bit (although I wouldn't hold out too much hope).
After that, I would look at http://www.autoitscript.com/autoit3/index.shtml (or something like it), and see if I could use that or integrate with it somehow.
finally, I would look at how http://win32utils.rubyforge.org/ handles api wrapping, figure out the win32 api call you need, and then write a c extension wrapper for it.
Related
I'm trying to write my first Shell extension and - as every blog post out there - I am too struggling with the lack of up-to-date documentation...
Namely I am trying to grab all key strokes from the keyboard, and - looking at code online and old mailing list messages - it seems that until recently the correct way of doing was:
const Shell = imports.gi.Shell;
global.set_stage_input_mode(Shell.StageInputMode.FULLSCREEN);
global.stage.connect('key-press-event', myCallbackHere);
However this doesn't seem to work. Both the function set_stage_input_mode and the property StageInputMode seem to have gone, at least on my Fedora 24 running GTK 3.20.6.
What is the correct, current way to have my extension grabbing all keystrokes performed by the user?
I don't think there is a correct way to do this at the moment. You could hack something together that is either X specific or Wayland specific or maybe you could patch Gnome Shell to provide this information.
For Wayland you could start at https://github.com/MaartenBaert/wayland-keylogger and for X you could start by looking at reusing the key detection from autokey (https://github.com/autokey/autokey/blob/master/src/lib/interface.py).
I can guess this is not the answer you were hoping for, because on IRC you wrote that you want to write a replacement for autokey. For getting input from an external program you can use GLib.spawn_async_with_pipes (https://people.gnome.org/~gcampagna/docs/GLib-2.0/GLib.spawn_async_with_pipes.html).
I wrote some time ago some Shell extension code to poll xinput test and log roughly what's happening (think any alphanumeric key vs left ctrl vs return key). You can look at that code here: https://gist.github.com/daniellandau/7679741bf8bbc5c345591593ca05e9f6. It's not robust enough for doing any kind of macro expansion so I'd recommend reusing the detection code from autokey.
In general the docs at https://people.gnome.org/~gcampagna/docs are the place to find API references for libraries usable from Gnome Shell extensions. I hope you get ahead with your project. Starting out writing extensions is frustrating but eventually very fun once you get the hang of it.
Is there a quick and easy way to make a ruby/Tk script run in a browser? I wrote a handy-dandy little ruby/tk script to do stuff. A friend saw it and said that his friends would love to use it, but they are extremely non-technical and cannot handle installing ruby (even though I showed him how simple it is). What he wants is for me to give him a link that someone can click on a browser and magically make the tool run.
I've looked around and get the impression that it cannot be done. 'it just does not work that way'. But I have not seen a clear 'NO' . I see things on how to get ruby to run in a browser, but not the Tk part. I also looked at rubyscript2exe but get the impression that it was abandoned.
No, you can't directly run Ruby in the browser like that.
There are websites such as RubyFiddle which let you run short snippets. What they're actually doing is executing the code remotely then displaying the result.
Because this code is actually being executed remotely, there's no way of running something interactive (like a TK UI) with it. There are some services which give you a hosted Ruby environment with working Terminal, but even these aren't going to work with a TK UI.
This section of Ruby Gems https://www.ruby-toolbox.com/categories/packaging_to_executables has a good list of all the tools available to package Ruby apps for distribution though, so you might be able to send them a simple installer to allow them to use it locally?
I've had a lot of success doing this with https://github.com/larsch/ocra/ which is actively maintained.
What do you guys use if you want to make a quick and dirty Windows GUI as a utility helper for your coding? I had been using AHK but since I do a lot of work in C# I wondered if it were more convenience.
Basically I'm looking for the simplest way to pop a window with some fields and do a little text processing in a Windows desktop environment.
Python and tkinter, or tcl/tk is what I use.
I like to use Linqpad for code prototyping and small tests. Even though its meant for more database stuff, I'm sure you could punch out a GUI really fast in there and save it for future testing. It has a lot of support for C#, but also quite a few other languages. Not sure if this is what you're looking for, but that's what I would use.
We wish to provide people to be able to add some logic to their accounts(say, given a few arguments, how to compute a particular result). So, essentially, this would be tantamount to writing simple business rules with support for conditionals and expressions. However, the challenge is to provide them a simple online editor where they can create the logic (preferably) by completely visual means (drag/drop Expr-tree nodes maybe -- kinda like Y! pipes).
Does anybody know of a scripting/macro/domain-specific language that lets people do this? The challenge is the visual editor, since we don't wish to invest in developing the UI to do the editing. The basic requirements would be:
1. Embedded into another language, or run securely (no reboot -n or <JUNK-DANGEROUS-COMMAND> >> ~/.bashrc)
2. Easily accessible to users without coding background (no need of any advanced features)
3. Preferably have a simple GUI based editor to create the logic programs accessible to non-developers (kinda like spreadsheets)
4. Some ability to generate compile-time warnings (invalid code) would be good (Type safety?)
5. Ability to embed some data before execution which is available to the interpreter (Eg., name, birthday, amount)
Anybody tried doing something like this and got any ideas? I looked at Lua, Io, Python, Ruby and a host of others, but the challenge essentially is that I don't think non-programmers will be able to understand the code all that much. Something that could be added via "meta-programming" to say a Ruby would be good as well, if an editor could be easily developed!
As a matter fact, Microsoft is developing Oslo, which is right up your alley.
Chris Sells has been writing a lot about it recently.
It is designed to be a way to author DSLs and also to visually author these models with a graphical tool called Quadrant. Sounds very very similar to what you are looking for.
Open source wise, Ruby I think can be close, as you can see if you look at _whytheluckystiff's Try Ruby or Hackety.
I don't think you'll find anything that isn't too generic, especially regarding the GUI editor. There's no generic tools as far as I know that will be able to automatically interface with your program and be able to query data from it and interpret the script into commands in your software -- if there is I'd like to have a copy. Not being flippant, but you will have to do some (probably alot) of work to get this working. It will probably result in you writing a custom DSL.
I would take a look at PowerShell. You could surface all the activities a user would like to script in a very readable way.
There is some talk of using PowerShell to create a DSL on the PowerShell team blog and Bruce Payette, the technical lead, talks about this in his book Windows PowerShell in Action from Manning.
At the other end of the scale is to write something simple as a HyperText Application (HTA) -- assuming Windows of course -- along the lines of my Clive tool. The article on the blog doesn't mention the HTA version, but essentially I could enter VBScript-ish code into one textarea and interpret it on the spot, output going into another text area on the form.
With HTAs giving you all the form control of HTML, plus the DOM, you could come up with something interesting fairly quickly.
I am looking for some free light-weight GUI alternative for IRB console on windows. What I whould like to see:
Area to write a script (so I can edit, run, edit...)
Command line to play with current variables
Output window to see results
Intellisence
Breakpoints/debugging is a plus
Actually, some thing similar to powershell_ise.exe whould be great.
(source: microsoft.co.il)
P.S. I am not looking for IDE (NetBeans, Aptana, etc.)
How does SciTE fail? Kinda curious because it feels like what you are looking for if you are working from a file. Ctrl-F5 executes, etc.
Have a look at e-texteditor.
It isn't a full IDE, but it allows you to execute Ruby code, and either put the input inline, after a #=> comment, or into a new window.
You get some of what you want, not so much the debugger and console. But the run-inline thing helps out a bit there.
It is based on TextMate, which is just fantastic. But OS X only. Oh, and it costs money.