Jump to content
The simFlight Network Forums

Screenshot Lua Script


spokes2112

Recommended Posts

This Lua file invokes the Print Screen button passing the clipboard to  IrfanView.exe and, by using IrfanView's powerful command line options, processes the pasted file to an output .jpg modified as wanted.  

--[[ NOTES

- USE WITH [AUTO] IN .INI TO START WITH FS
- ASSIGN IN FSUIPC AS "LuaSet <Saved Name>" WITH A PARAMETER OF 1 

- HTTP://WWW.IRFANVIEW.COM/ - SEE "I_OPTIONS.TXT" OR "I_VIEW32.CHM|OVERVIEW|COMMAND LINE OPTIONS" FOR COMMAND LINE DESCRIPTIONS.
- EXAMPLE OF "SS_$U(%d%b%y_%H%M%S).jpg" IN OPTIONS = "SS_20Oct15_112307.jpg"
- !!! IMPORTANT !!! - CHANGE "IV_Path" AND "IV_Options" TO OWN INSTALLATION AND REQUIRED OPTIONS
- COMMAND OPTION "/convert=" WILL AUTOMATICALLY SHUT DOWN IRFRANVIEW AFTER PROCESSING  

- BECAUSE PRINT SCREEN IS INVOKED IN LUA, OWNED BY FS, IT CAPTURES ONLY THE ACTIVE MAIN WINDOW, IE FS.
- !!! NOW MODIFIED FOR BETTER BEHAVIOUR

- SEE COMMENTS IN "TRIGGERS SECTION" BELOW FOR OTHER ASSIGNEMENT OPTIONS

END NOTES ]]

sound.path("C:/Windows/Media")
local flagged = 0

-- !!! IMPORTANT !!! - CHANGE THE FOLLOWING 2 LINES TO SUIT !!! 
local IV_Path = "E:/IrfanView/i_view32.exe"
-- !!! IMPORTANT !!! - USE DOUBLE BACKSLAHES FOR OUTPUT PATH
local IV_Options = "/clippaste /crop=(1443,62,1357,684) /sharpen=20 /jpgq=100 /convert=D:\\My Pictures\\FS_SCREENSHOTS\\PP_OUTPUT\\SS_$U(%d%b%y_%H%M%S).jpg"

-- /crop=(13,62,1357,684)
-- /crop=(1443,62,1357,684)
 
-- PRESS PRINT SCREEN KEY, RUN IRFRANVIEW (SELF STOPPING), PASTE CLIPBOARD, OPTIONS PROCESSING, CREATE JPG & RETURN FOCUS TO FS
function PrtScn(x, y, move, flags)
	flagged = ipc.testflag(1)	
	if flags == 16 or flags == 32 or flags == 64 or flagged then
		ext.focus(0)
		-- REGAIN OWNERSHIP OF FS - FSX ONLY!!!
		x, y, xr, yr, xp, yp = mouse.getpos()
		mouse.move(66, 0, 2)
		mouse.click(0)
		mouse.move(xr, yr, 1)
		-- END FSX ONLY
		ipc.clearflag(1)
		ipc.control(1070, 300)		
		-- WAIT FOR "PRTSCN" TO PROCESS, ADJUST HIGHER IF NOT PICKING UP FS WINDOW 		
		ipc.sleep(100)  		
		handle, error = ext.shell(IV_Path, IV_Options)
		if handle ~= 0 and error == 0 then
			sound.play("Windows Default", 0, 100, -1) 
		end
		ext.focus(0)
		
	end	
end 

-- TRIGGERS SECTION

-- SETFLAG TRIGGER, FOR JOY OR KEYS THROUGH FSUIPC ASSIGNMENTS
event.flag(1, "PrtScn")

-- MOUSEWHEEL CLICK - FSUIPC V4 ONLY! DISABLED FOR FSUIPC MOUSE LOOK FUNCTION USE
-- event.mousemiddletrap("PrtScn")

-- MOUSEWHEEL LEFT / RIGHT - FSUIPC V4 ONLY! DOES NOT WORK WITH MY MOUSE, USED KEYSEND MACRO IN MOUSE SOFTWARE
-- event.mousehoriz("PrtScn")
  • Upvote 1
Link to comment
Share on other sites

The first code was slightly bugged when using two monitors. For instance on the second monitor you had a 2D GPS window opened and just got done making that window active by clicking on it (clicking GPS buttons) when a screen shot was made it would capture the second monitor. The new modified code brings the mouse over to the main window (middle right top) and performs a mouse click. It then returns the mouse to the same position it originated from. The above code is modified to include the new coding. 

 

Relevant Section -

		-- REGAIN OWNERSHIP OF FS - FSX ONLY!!!		x, y, xr, yr, xp, yp = mouse.getpos()		mouse.move(66, 0, 2)		mouse.click(0)		mouse.move(xr, yr, 1)		-- END FSX ONLY
  • Upvote 1
Link to comment
Share on other sites

  • 1 month later...

Hi Roman,

Thank you for sharing your marvellous lua script, and for introducing me to IrfanView. I have used your script in combination with Input Director macros to create (composite) panoramic screenshots of my networked FSX system comprising 7+1+7+3=18 screens. I have sent you a PM with links.

Regards

Chakko.

  • Upvote 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.