File Type Save-As-GUI - Program Specific

Post your working scripts, libraries and tools for AHK v1.1 and older
jakejake
Posts: 18
Joined: 12 Feb 2017, 12:26
Contact:

File Type Save-As-GUI - Program Specific

13 Oct 2017, 15:52

Enter a comma separated value with window title, filetype, and key to focus on it. Pressing the hotkey brings up a gui to click a filetype for that program, which opens save as window with that filetype selected.

Program works on programs which default to last saved filetype, and can work with various types of saving such as "save as" or "file export".

This code could probably be written better, but I have found the script very useful as I need to save out many types of files with various programs. Maybe you will find it useful!

Code: Select all

SetTitleMatchMode, 2 
CoordMode, Mouse, Screen

GroupAdd, SLDWRKSGroup, SOLIDWORKS
GroupAdd, SLDWRKSGroup, SolidWorks

SaveOpts= ;format: matching window title, control name, file type focus key, special save hotkey - if not standard, like file > export
(
ahk_class illustrator,.pdf,{a 2}, 
ahk_class illustrator,.dxf,a,!fe
.SLDPRT,.step,s,
.SLDPRT,.dxf,d,
.SLDPRT,.stl,{s 3},
.SLDASM,.sldprt,p,
.psd,ImgForWeb,,!^+s
ahk_exe OUTLOOK.EXE,Text,t,
)
arr := []
MenuItemNumber := 0

#s::
Loop, Parse, SaveOpts, `n
{
	VarLineTitle := RegExReplace(A_LoopField, ",.*") ;read each new line containing a save option
	IfWinActive, %VarLineTitle%
	{
		
		MenuItemNumber++
		Loop, Parse, A_LoopField, `, ;split into array: matching window title = arr[MenuItemNumber, 1], control name = arr[MenuItemNumber, 2], file type focus key = arr[MenuItemNumber, 3], special save hotkey = arr[MenuItemNumber, 4]
		{
			arr[MenuItemNumber, A_Index] := A_LoopField
		}
		if !arr[MenuItemNumber, 4]
			arr[MenuItemNumber, 4] := "!fa"
		Gui, Add, Button, v%MenuItemNumber% gSaveMenu, % arr[MenuItemNumber, 2]
	}
	else
		Continue
}
if MenuItemNumber = 0
	ExitApp
Gui, Show
return

GuiClose:
	ExitApp
	
SaveMenu:
	Gui, Cancel
	Send, % arr[A_GuiControl, 4] ;ifspecaction empty
	MouseGetPos, StartX, StartY
	MouseMove, 0,0 ;move mouse out of the way
	WinWaitActive, ahk_class #32770 ;wait until save dialog window
	
	Send, {Tab}
	Send, {Down}{Up 15} ;move to the top of menu in case program defaults to last saved type
	Send, % arr[A_GuiControl, 3] ;MenuFocus
	Send, +{Tab}
	MouseMove, StartX, StartY

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 100 guests