DonationCoder.com Forum

DonationCoder.com Software => Mouser's Zone => Find And Run Robot => Topic started by: alias on August 06, 2009, 09:28 AM

Title: Can FARR be used to switch between open windows?
Post by: alias on August 06, 2009, 09:28 AM
I was wondering if FARR can be used to duplicate the functionality of the iSwitchW AutoHotKey script - i.e. a text-based task switcher.  Ideally, I'd love to have FARR show open windows first in the list of hits, so I could run the program if it wasn't open.

For example, if I have Outlook open, and type "out" into FARR, it would show the open window as the #1 choice, followed by the shortcuts, etc. it's found.  Or if I had Outlook open, as well as an explorer window for a folder named "Lookout" (which is what Outlook should've been named, imo, with 3 exclamation marks after it...) FARR would show the open Outlook and Lookout windows first, followed by the shortcuts, etc.

This would let FARR function as a very fast task switcher AND launcher, simultaneously...

Thanks for listening, and apologies offered if it can already do this (I did look in the help files and at the features list, but didn't find anything)...
Title: Re: Can FARR be used to switch between open windows?
Post by: mouser on August 06, 2009, 10:07 AM
Yes it can, if you use the FARRAltTab plugin from DC member vitalyb:
https://www.donationcoder.com/forum/index.php?topic=10988
Title: Re: Can FARR be used to switch between open windows?
Post by: alias on August 06, 2009, 12:40 PM
Almost perfect, thanks!  If only it could display the shortcuts to open an application if it's not already running...

But, still, much better than having to use a bunch of different utilities - thanks!
Title: Re: Can FARR be used to switch between open windows?
Post by: CatamountJack on August 06, 2009, 01:36 PM
I think the first part of this is an interesting suggestion...   I use the FARRAltTab plug-in already, but it would be a great addition if FARR would seamlessly open the application if it isn't already open.

Maybe another way of putting it...   when the user types "out" to bring up Outlook, FARR searches all open windows to see if the program is already running first and, if so, brings it to the foreground - otherwise, it will open a new instance.  I could see that being useful all the time.
Title: Re: Can FARR be used to switch between open windows?
Post by: alias on August 06, 2009, 02:17 PM
Yeah, I frequently have a dozen or more apps open, and I don't always remember if I've already opened an app, especially early in the day, so having a single way to bring it foremost, if it's running, or run it, if it's not, would be VERY nice... 

Another reason: some apps misbehave if you run multiple instances (or there's never a valid reason for running more than one instance), so I'd even like the ability to have FARR check for an instance of the app already running and give me the option of switching to it, rather than opening another...
Title: Re: Can FARR be used to switch between open windows?
Post by: mouser on August 06, 2009, 02:21 PM
that would actually be a fun plugin for someone to write -- a plugin that intercepts launch commands, and if it finds the exe already running, checks its lists of which programs should get second instances, and which programs should just be switched to.

if anyone feels like writing such a plugin, it is possible to do.
Title: Re: Can FARR be used to switch between open windows?
Post by: alias on August 26, 2009, 07:53 AM
I'm just replying to this topic again because I'm wondering if others would find this useful.  Obviously, Mouser, nobody has replied to your statement that this would be "fun" to write, so does "fun" translate to "difficult" in your vocabulary, or is it likely that I'm just wanting something that nobody else does?
Title: Re: Can FARR be used to switch between open windows?
Post by: mouser on August 26, 2009, 07:56 AM
i think it's just a matter of waiting a little bit until a coder gets in the mood to do a plugin and then stumbles on this.
Title: Re: Can FARR be used to switch between open windows?
Post by: skajfes on August 26, 2009, 05:12 PM
Could FARRAltTab be modified that it displays open windows AND normal FARR search results at the same time? I figure that it would be enough to provide the solution to mchalkley's original post.

On the more general note, is it possible to combine the results of two or more plugins and/or aliases? For example, one plugin displays open windows, the other displays firefox tabs, and at the bottom is  an alias with common apps.
Title: Re: Can FARR be used to switch between open windows?
Post by: alias on August 26, 2009, 09:40 PM
I posted a message on the Executor forum asking whether it has the ability to switch to an open app instead of launching a second instance, and I got a response that you just check a box "Only one instance running in More keyword options of your keyword".  So it seems it has this capability natively, but I'll have to test it to see if it works properly.
Title: Re: Can FARR be used to switch between open windows?
Post by: alias on August 28, 2009, 09:23 AM
Oh well, it was worth a try, but Executor's "switch if open" feature fails often enough that it's not really useful.  It seems to be close, in the sense that it never opens a second instance if you've checked that option for that keyword (alias), but it usually fails to switch to that app, which I found strange, since it seems that the most difficult part is the part that works.
Title: Re: Can FARR be used to switch between open windows?
Post by: mouser on August 28, 2009, 09:29 AM
fret not.
this is really going to be something that a plugin writer will be able to do for FARR, and enjoy coding.  it will be fun to make the first plugin that intercepts launch commands and takes them over, and it will be easy to make it so users can specify programs that should or should not be allowed to run multiple copies.
Title: Re: Can FARR be used to switch between open windows?
Post by: skajfes on August 28, 2009, 01:47 PM
I've modified the FARRAltTAb plugin (to be exact - I just took the part where open windows are enumerated) and intercepted the Trigger command, that was the easy part. The logic of switching to open windows is already there from the FarrAltTab plugin, and if a window is not open, just let the execution proceed as normal.
 
I am not sure what to use as comparison for determining if a window is open or not. Window caption seems a bit too unreliable (although i'd have to test that, maybe it will be reliable enough). The other thing that came to mind was to check the exe file, but the path i get from FARR is the shortcut (.lnk file), and not the exe.

Title: Re: Can FARR be used to switch between open windows?
Post by: mouser on August 28, 2009, 01:55 PM
i can add a function to farr that your plugin can call which will resolve a shortcut and return the exe name.
in fact i think i already did, let me look it up.
Title: Re: Can FARR be used to switch between open windows?
Post by: mouser on August 28, 2009, 01:56 PM
yep, it's already there.

call
FARR.get_strvalue("resolvelnk:thepathtothelnkfile")
and farr will return the path to the exe
Title: Re: Can FARR be used to switch between open windows?
Post by: alias on August 28, 2009, 03:02 PM
I think Window Caption is where some other program's attempts to do this fall flat.  Right now, for example, my Firefox Window caption is "Can FARR be used to switch between open windows? - DonationCoder.com - Vimperator", which doesn't exactly provide too much of an indication that it's Firefox.  One problem, though, is that programs can have multiple windows - Outlook is a good example - so how do you pick which one?  It would be handy to be able to set up, along with the program list, a search string in the Windows caption to use to pick which window to make active.  That way, even if there are several Outlook messages open, as well as a Calendar window and an Inbox window, you could switch to the "Inbox" window.  This would also come in handy for activating "Documents" vs. "Downloads" Windows Explorer windows...
Title: Re: Can FARR be used to switch between open windows?
Post by: skajfes on August 28, 2009, 03:50 PM
yep, it's already there.

call
FARR.get_strvalue("resolvelnk:thepathtothelnkfile")
and farr will return the path to the exe
I had to modify vitalyb c# SDK a bit for this to work though. But any excuse for digging into c++ is good enough :)
Title: Re: Can FARR be used to switch between open windows?
Post by: skajfes on August 28, 2009, 04:16 PM
Anyway, this seems to work on occasion, I tested it for the entire duration of 15 seconds, and about two or tree test cases :)

So let us think about options a bit:
- there should be a list of apps that should have only one instance
- or a list of apps to let have multiple instances
- some options about comparing (using path and caption or anything) that could help determining what instance to switch to (if more are running)
Title: Re: Can FARR be used to switch between open windows?
Post by: alias on August 28, 2009, 04:24 PM
Executor's approach, though flawed in its execution, is very neat in its UI implementation:  there's a simple check box "Don't allow multiple instances", associated with the alias.  But that would require a change to FARR itself, I guess...
Title: Re: Can FARR be used to switch between open windows?
Post by: mouser on August 28, 2009, 04:26 PM
do you really need to worry about captions? i think simply comparing full lowercased path names would be sufficient.

if you want to give users the MOST flexibility i think the options would look something like this:

By default: Launch multiple instances | Switch to running application if found

List of programs to always allow multiple instances:
[SIMPLE TEXT BOX, EACH PATH ON ITS OWN LINE]

List of progams to always switch to if found running:
[SIMPLE TEXT BOX, EACH PATH ON ITS OWN LINE]

-----

even this might be overkill, and one could assume that people who install this will almost always want to switch to running process, so just do that by default and have a list of paths of programs to allow multiple instances.

-----

you might also allow substring matching against paths, so i could specify
firefox.exe
in my list of programs to install multiple copies.
Title: Re: Can FARR be used to switch between open windows?
Post by: skajfes on August 28, 2009, 04:41 PM
List of progams to always switch to if found running:
[SIMPLE TEXT BOX, EACH PATH ON ITS OWN LINE]

In fact, my original idea was just this. Compare executable files and that's about it. User must specify a list of single instance apps.
Title: Re: Can FARR be used to switch between open windows?
Post by: alias on August 28, 2009, 04:44 PM
I'm certainly in favor of the simplest approach that gets the job done.  So what would happen if there are multiple windows open, as with the examples I gave earlier?
Title: Re: Can FARR be used to switch between open windows?
Post by: skajfes on August 28, 2009, 05:03 PM
I'm certainly in favor of the simplest approach that gets the job done.  So what would happen if there are multiple windows open, as with the examples I gave earlier?
Windows explorer automatically activates a window if there's a same folder already open, so that is of no concern.
For now the plugin will activate the first window it finds that has the same path to the executable as the executed file. Outlook is a special case as it runs all of it's windows (main program, new message, etc) as the same process. Unless there are multiple outlook instances running.

I am thinking about maybe adding an option for a "preferred keyword" in the window title. So, first the plugin searches by executable file name, then if it finds more that one result, checks the resulting widows captions for preferred keywords. If no keywords are matched or multiple windows has the same keyword the first result is launched (as there is no way to distinguish windows further)
Title: Re: Can FARR be used to switch between open windows?
Post by: alias on August 28, 2009, 05:27 PM
Awesome!  I'm really looking forward to getting rid of a couple other programs!
Title: Re: Can FARR be used to switch between open windows?
Post by: skajfes on August 28, 2009, 06:28 PM
Well I must inform you that this plugin is coming along nicely. There could be a release in a couple of days if i get some more time. This is already cutting into my beauty sleep :D
Title: Re: Can FARR be used to switch between open windows?
Post by: mouser on August 28, 2009, 06:45 PM
awesome  :up:
Title: Re: Can FARR be used to switch between open windows?
Post by: alias on August 28, 2009, 09:52 PM
That soon?  Even awesome-er!  I remember the days of coding for hours after I should've been asleep, because I couldn't stop...  I cut my programming teeth on mainframes in the early 80's, coding in Algol, Cobol, & machine language.  One of the mainframes was still programmed from punched cards.  Then, it was on to PL/I, Pascal, C, C++, Perl, & Python, but I haven't done any serious coding in 10 years or so.  At any rate, I know what's involved - so, thanks!!!
Title: Re: Can FARR be used to switch between open windows?
Post by: skajfes on August 30, 2009, 07:13 AM
Mouser, I need your help. I have a shortcut that links to Gmail. It was created with Chrome's create application shortcut feature. This is in fact a link to chrome.exe, with an argument. Shrotcut's path looks like this:
"C:\Documents and Settings\skajfes\Local Settings\Application Data\Google\Chrome\Application\chrome.exe" --app=https://mail.google.com/mail
When I call FARR's resolvelnk command on that shortcut I get only the exe, without the argument. Is it possible in some way to get the argument? Or do you maybe have another idea on how to distinguish this link from from Chrome that is already running?

Another thing. Microsoft Office. The people at microsoft have great ideas as always, so the Microsoft Office Word.lnk in start menu resolves as c:\windows\installer\{90120000-0030-0000-0000-0000000ff1ce}\wordicon.exe so there's no way of distinguishing office windows.

I am thinking about adding an option to allow users to specify a list of links with mappings that would resolve both of these problems. For example, user would specify that Gmail.lnk should be matched by chrome.exe app and Gmail in caption. Microsoft Office Word.lnk should be matched by winword.exe etc...
Title: Re: Can FARR be used to switch between open windows?
Post by: mouser on August 30, 2009, 10:09 AM
i can add a command to get arguments, that's not a problem.  i'll do that today.  i'll actually add 2 functions, one to resolve the link with arguments, and one to get arguments separately.

as for launching the windows office application link.. that may be harder, let me see what i can figure out.
(ps. this is what drives me crazy about microsoft -- why do they insist on constantly pulling these bullshit gimicks that make things more difficult).