Automate Save As

General discussions about Inkscape.
elecman
Posts: 27
Joined: Mon Feb 09, 2015 1:39 pm

Automate Save As

Postby elecman » Thu Feb 12, 2015 11:11 am

Is there any way to automate this with a hotkey (using a script extension):

File-Save As->Microsoft XAML->Save->Silverlight compatible = true->Ok->Overwrite = yes, don't ask.

Perhaps some code to get me started? That would be awesome.

hulf2012
Posts: 716
Joined: Sat Nov 24, 2012 12:37 pm

Re: Automate Save As

Postby hulf2012 » Fri Feb 13, 2015 3:27 am

Hello,
It seems it's a hard question!!

I confess that I don't have enough information about that. but I 'm afraid it's not possible right now.

You could however, found usefull this information:
http://tavmjong.free.fr/INKSCAPE/MANUAL ... dLine.html

There are also options for keyboard shortcuts
http://tavmjong.free.fr/INKSCAPE/MANUAL ... -Shortcuts

I remember vaguely some one talked about a third party program which can record clicks on buttons and other stuff similar. I don't know even how to search it in google... record mouse clicks perhaps?
... well, one that seems intersting doing that search:
http://sourceforge.net/projects/minimousemacro/

:| At the end... better call the developers!
If you have problems:
1.- Post a sample (or samples) of your file please.
2.- Please check here:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.html
3.- If you manage to solve your problem, please post here your solution.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Automate Save As

Postby ragstian » Fri Feb 13, 2015 3:45 am

Hi.

If you are on windows you can use the python sendkeys to "automate" nearly all programs.
I have used this to prevent computers going to sleep when company policy have prevented changing the time for the screensaver to "kick in"
by sending a keypress to notepad every five minutes.
Last edited by ragstian on Sat Feb 28, 2015 3:23 am, edited 1 time in total.
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

Janne
Posts: 228
Joined: Wed Oct 29, 2014 4:15 am

Re: Automate Save As

Postby Janne » Fri Feb 13, 2015 5:45 am

I apologize for my curiosity but if someone would spend 2 words on explaining this I would be grateful :)

We are in an Inkscape forum and I presume that we are talking about overwriting a file with Autosave - but I'm sure it's not that simple reading the replies.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Automate Save As

Postby ragstian » Fri Feb 13, 2015 6:09 am

Hi

Janne, when you have the autosave turned on Inkscape will save your work every X minutes,
I have set mine to autosave every 10 minutes.
This has saved my butt more than one time as if I do a serious mistake I can grab the autosaved version and never lose more than 10 minutes work.

Another thing to be aware of is that Inkscape saves your work (most of the times) when crashing as well, normally you would think that when Inkscape crashes your work will be gone but it's saved with a "timestamp" in the filename like this; inkscape-autosave-0-2015_02_12_13_12_15-001.svg
Last edited by ragstian on Sat Feb 28, 2015 3:23 am, edited 1 time in total.
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

Janne
Posts: 228
Joined: Wed Oct 29, 2014 4:15 am

Re: Automate Save As

Postby Janne » Fri Feb 13, 2015 10:16 am

Hi Ragnar, yes, I think that you taught me about Autosave a couple of months ago and it comes in very handy.

It was this sentense ( plus the replies ) that made me curious:
"File-Save As->Microsoft XAML->Save->Silverlight compatible = true->Ok->Overwrite = yes, don't ask."

Thank you for your information on saved files on crash - I think that I have a couple of them :D

User avatar
Maestral
Posts: 982
Joined: Sat Aug 27, 2011 7:10 am

Re: Automate Save As

Postby Maestral » Fri Feb 13, 2015 11:18 am

@ elecman
AutoIT (Win) might help on automating it.

@hulf2012
That mini is a very nice mouse ,)

@ Janne
When saving file in MS XAML format, additional pop-up related with Silverlight shows up, so the Save As procedure is extended for that extra step (in comparison with Save as .svg where user is asked just for the destination and file name). Additional replies were related to automating all of those steps.
:tool_zoom: <<< click! - but, those with a cheaper tickets should go this way >>> :!:

elecman
Posts: 27
Joined: Mon Feb 09, 2015 1:39 pm

Re: Automate Save As

Postby elecman » Fri Feb 13, 2015 1:53 pm

I don't think Auto Save will work, because I work with an SVG file, but need to export it to XAML. If I work with the XAML file, the auto save will work, but I will use all inkscape specific data (guides etc). Besides, I want to save on demand, and with Auto Save, I have to wait for the next save, which defeats the purpose.

I use the XAML file in a game engine (Unity, using NoesisGUI), so my workflow is: Edit in Inkscape->Try in game->Rinse, repeat.

I will have a look AutoIT.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Automate Save As

Postby brynn » Fri Feb 13, 2015 5:17 pm

Janne, he's talking about writing a script that will do this Save As automatically, from a keystroke. I don't understand anything about doing that, which is why I haven't replied. I think of script writing as a more advanced computer skill. At least it's a skill I don't have!

elecman
Posts: 27
Joined: Mon Feb 09, 2015 1:39 pm

Re: Automate Save As

Postby elecman » Fri Feb 13, 2015 8:50 pm

Thanks for the AutoIt hint. I made a script which does exactly what I want. This is such a time saver!

Code: Select all

;Set an option so that we can always find the window, regardless of the file name in use.
AutoItSetOption ("WinTitleMatchMode", 2)

;Get a handle to the main window.
Local $hWndMain = WinGetHandle(" - Inkscape", "");

;If we can't find the main window, bail out.
If @error Then
   Exit
   
;The main window is found, continue
Else
   ;Focus the main window in case it isn't.
   WinActivate($hWndMain)
   
   ;"Save a Copy" keyboard shortcut.
   Send("{SHIFTDOWN}{CTRLDOWN}{ALTDOWN}s")
   Send("{SHIFTUP}{CTRLUP}{ALTUP}")
   
   ;Wait for the save window to show up.
   Local $hWndSave = WinWait("[CLASS:#32770]")
   
   ;Focus the save window in case it isn't.
   WinActivate($hWndSave)
   
   ;Click on the "Save as Type" selection box.
   ControlClick($hWndSave, "","[CLASS:ComboBox; INSTANCE:3]")
   
   ;Select the xaml option in the selection box, and press Enter.
   ControlCommand($hWndSave, "", "[CLASS:ComboBox; INSTANCE:3]", "SelectString", "Microsoft XAML (*.xaml)")
   Send("{ENTER}")
   
   ;Shortcut key for "Save".
   Send("{ALTDOWN}s")
   Send("{ALTUP}")
   
   ;A popup box will appear which asks if you want the output to be compatible with Silverlight.
   ;You have to tick the box manually once, without using this script. After that, the setting is remembered.
   Local $hWndSilverlight = WinWait("XAML Output", "")
   WinActivate($hWndSilverlight)
   
   ;Shortcut key for "OK" on the Silverlight message box.
   Send("{ALTDOWN}o")
   Send("{ALTUP}")
   
   ;If the file already exists, overwrite the it by pressing Enter.
   Local $hWndOverwrite = WinGetHandle("");
   If @error Then
      Exit
   Else
      WinActivate($hWndOverwrite)
      Send("{ENTER}")
   EndIf
EndIf
Last edited by elecman on Sat Feb 14, 2015 8:40 pm, edited 1 time in total.

User avatar
Maestral
Posts: 982
Joined: Sat Aug 27, 2011 7:10 am

Re: Automate Save As

Postby Maestral » Fri Feb 13, 2015 9:07 pm

You`re welcome! Keep it rocking ,)
:tool_zoom: <<< click! - but, those with a cheaper tickets should go this way >>> :!:

Janne
Posts: 228
Joined: Wed Oct 29, 2014 4:15 am

Re: Automate Save As

Postby Janne » Sat Feb 14, 2015 1:51 am

brynn wrote:Janne, he's talking about writing a script that will do this Save As automatically, from a keystroke. I don't understand anything about doing that, which is why I haven't replied.


My not-so-clever question gave me valuable information about saving on crashes. :)

And thank you, Maestral, for your explanation. :)

User avatar
Maestral
Posts: 982
Joined: Sat Aug 27, 2011 7:10 am

Re: Automate Save As

Postby Maestral » Sat Feb 14, 2015 2:39 am

:tool_zoom: <<< click! - but, those with a cheaper tickets should go this way >>> :!:

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Automate Save As

Postby Lazur » Sat Feb 14, 2015 3:02 am

Off topic:
I for one don't use autosave.

Have been working with large svg-s lately -6,8 MB without any embedded images, and another one mostly made from raster parts in 175 MB-, the worse experience was when inkscape crashed while saving, resulting in a corrupted svg with most of the work lost.

Janne
Posts: 228
Joined: Wed Oct 29, 2014 4:15 am

Re: Automate Save As

Postby Janne » Sat Feb 14, 2015 6:20 am

You guys make me laugh - by the way also this is OFF TOPIC :D


Return to “General Discussions”