New recent document tool script. I ran into a snag

General Moho topics.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

New recent document tool script. I ran into a snag

Post by heyvern »

It was driving me crazy that AS doesn't have a recent document list. Some quick tests... on the Mac... showed this would be fairly simple. The test works. I store each document loaded into a list (5 at the moment) and those files are stored in the tool preference. You open AS, select the tool and a menu with the last 5 documents is there. Select one and it opens.

However... Windows is a whole other story. No matter what I do I can't target the currently open instance of AS to open a previous document. It ALWAYS opens in a new dang instance. Even double clicking a file on the hard drive will open a new instance. Very annoying.

I have to use "os" commands to open a file because AS does not have an "Open File" command via a script. These os commands for windows are the same as using the "command prompt" to find and open files or launch applications. I've searched and searched and can't find any way to target a running application instance.

If any of you are Windows "experts" or even programmers that have knowledge of how to workaround this issue I would be happy to hear it. Maybe there could be a simple application created in "basic" or something that can target an instance of AS like the Mac does?

So... this tool script as it is will work fine on Mac and probably on Linux (same command line commands but I don't know about "instancing" on linux) but doesn't do well on Windows.

All help or suggestions will be appreciated.

p.s Back to the consolidation script... ;)

-vern
User avatar
DK
Posts: 2896
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Post by DK »

I just posted your question on a prgrammers forum Hopefully we might get a reply.

Cheers
D.K
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Post by chucky »

This would be great to see hey, Vern, I have found using v-aviles scene selector does help, it is soo cool , you don't get a full list but at least the last folder you opened is immediately available.
I wonder does anyone else know the phenomena of anme files opening AS when selected but not the file itself, just the StartupFile ?
This only started for me with 5.6, I thought it could be because I still had moho and it was a registry issue, but it happens also on the brand new tablet which only ever saw ASPRO 5.6.
I hope this is within the threads realm, I don't mean to can't change the subject .
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Haven't seen that issue Chucky. You mean double clicking a file opens AS but then the startup file loads instead of the file clicked? I got rid of the start up file ages ago. Pain in the arse.

----

Couple of hopeful options for this script issue. Both would have to come from Mike though.

One would be simple... an "Open FIle..." command in the scripting interface.

The second would be doing something or other in the application that is needed to make AS only run one instance. Ran across that a lot in my search. Apparently applications must have the "single instance" in the program... can't be done with the OS unless you jump through hoops... which I wouldn't want to make people do for this tool. It's kind of technical and involves third party stuff.

-vern
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Post by chucky »

yeah that's exactly what I mean Vern, strangely enough scene selector actually opens the file properly to AS, I guess I'' keep using that instead of through AS itself.
On your issue maybe v-aviles could add a recent docs list to scene selector?
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

chucky wrote:yeah that's exactly what I mean Vern, strangely enough scene selector actually opens the file properly to AS
So... if you have scene selector and AS open, it doesn't launch a new instance of AS when loading a new file? This may be what I need to do for my script. If I can target a "custom" very simple "stub" application similar to scene selector it could be used to open a file in AS.

That is what I've discovered. Applications built by programmers using whatever scene selector was built with can do a LOT MORE than I can using lua within AS.

I am guessing that a future upgrade to AS will have a recent documents list built in. That seems like... a no brainer "do this first" kind of feature to me. My efforts may be wasted but it would be nice to have. I plan to use what I've got for the mac version anyway.

-vern
User avatar
synthsin75
Posts: 10276
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

No, Scene Selector does open a new instance. Chuck just meant that it always opens the proper file instead of the startup file.

I haven't run into that problem either Chucky. If it happens with a certain file consistently, you might let one of us see it it does that on our system.

:wink:
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Yeah... I think I'm stuck. Unless Mike "changes" how AS works it aways opens a new instance. The only other work-a-rounds I've found require editing of the registry... ICKY YUCK! ;) Plus the second instance does not have the changes to tool preferences while the other one is open. So the recent document tool list is incorrect in the second instance. Quitting and reopening updates that list though.

Now... uh... I could "close" the current AS instance using the script... then open a new instance... but that stinks for me because of the resetting of windows with my multiple monitor set up. I use a gizmo that resets the window positions but it's still a pain.

What do you think? Quit the current instance then open a new one? I can even have it wait to "reopen" in case a save is required in the first AS instance.

-vern
User avatar
synthsin75
Posts: 10276
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

What do you think? Quit the current instance then open a new one?
That's sounds like a fine workaround, Vern.

Once you open the new instance couldn't you have the script run the Panel Arranger found in this thread:viewtopic.php?t=11321&highlight=windows ... 22c31dc2d1? Wouldn't that solve the multiple monitor problem?

:wink:
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Yes that would work. The os.execute can send any number of commands to the command prompt. It has lots of options for running a series of applications.

So if you use the panel arranger like I do then it would close the current instance, wait for save if needed, close AS, open the selected file, and run the arranger (need a text box for the tool layout to type in the name of the setting for panel arranger to run I think).

It should still be fairly quick but the darn startup of AS will slow it down. I will play around with this.

There was one tiny glimmer of hope. Drag and drop an AS file into the current instance of AS works great. The file opens in AS in the same instance as if you opened it from the application. However for the life of me I couldn't find anyway to "simulate" the drag and drop process using the command prompt in windows. There doesn't seem to be any options to do this.

There was yet another option using the tasklist and checking for how many instances of AS are running but this requires Windows Professional (XP anyway) so I ruled out using that. Couldn't figure out how it would work anyway.

-vern
User avatar
synthsin75
Posts: 10276
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

AutoHotKey can make windows macro exes. I haven't looked at it since I've started getting my head around scripting, but you may be able to make a macro that can be executed from the prompt that will accomplish the drag and drop.

So far I haven't looked into AutoHotKey, since it only works for windows, but since you only need it for windows, it just might do the trick. Granted it'd take learning it. From what I remember, it's fairly easy to use.

:wink:

p.s. Or better yet, use AutoHotKey to do ctrl+O within AS. But I don't know how you'd then select the file automatically.
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

:) the AutoHotKey forum looks the same as this one! Found that there are people trying to simulate "drag and drop" as well with limited success. If AutoHotkey can accept input through the command prompt that should be very simple to send the path to it to use for the "open" command.

Why can't windows be more like mac? Gates stole most of Apple's ideas anyway... might as well add a few more of those features. ;)

Just kidding! No flames please!

-vern
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Post by chucky »

Hey Vern you might want to add multi cereals wicked layout utilities and the scene selector to the scripts list you made. I know they aren't actually scripts but they have made my life much easier, I love them both ... I too have mutimonitor, 3 if I'm feeling greedy.
I have a question Vern regarding that, does your layer setting palette open between the 2 screens?
It was driving me nutty so I changed the graphics card setting to make the window open on the middle monitor , but that buggerises the way all my apps open, with all their windows layered on top of each other.
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Yes AS opens with palettes split between two monitors. That gizmo I'm using works pretty well to fix this issue. I just wish it worked "automagically". ;) And yes, other palettes pop up split across the monitor. The lua console for one which is very annoying as I use it a lot. I have a similar problem with jEdit. The find window loads really small and on the wrong monitor.

As I've been playing with the command prompt, I'm thinking of creating a "batch" file to load AS and then run the window arranger at the same time. I could just double click this or run it from the command prompt to launch AS.

This the 21st century! We can put robots on Mars, fix broken telescopes in orbit, safely drink recycled urine on a space station... and yet... Windows still doesn't have better support for multiple monitors built in? ;)

And where are the dang flying cars we are all suppose to have by now? And why isn't there an official "Earth Uniform" that everyone wears? When the aliens arrive they won't be able to tell us from the other aliens.

I would gladly drink the pee water as long as Microsoft has nothing to do with it's purification. ;)

------

Good point about those other tools. Maybe there should be just ONE other sticky for those. Or it could be a second post in the scripts sticky. I will give it some thought.

-vern
User avatar
DK
Posts: 2896
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Post by DK »

Hi Vern.
I managed a response from that programmers forum.
Lua, eh? Well, I'm assuming your friend doesn't have access to the source code for this application, since that's normally where this sort of thing is done: you get a handle to the running instance of the application (or null if it's not already running), then decide whether you want to launch a new instance or use the existing handle. Since a new instance is always getting launched, it's a fair bet that the application doesn't have code to handle this in its initialization section.

Any chance of using SendKeys to pass something like control-O and then the path to the file?
Cheers
D.K
Post Reply