You are here

[Closed] NSIS help: get screen size/screen refresh rate, add to parameters

5 posts / 0 new
Last post
Bennieboj
Bennieboj's picture
Offline
Last seen: 5 years 4 months ago
Joined: 2010-09-16 07:28
[Closed] NSIS help: get screen size/screen refresh rate, add to parameters

Hi everybody,

I'd like to give 3 parameters to a exe: screen height, screen width and screen refresh rate (Hertz).
E.g.: -params 1280,1024,60.
I don't think there is a portableapps variable for it, so I searched for a NSIS solution.
For screen height and width I found this: http://nsis.sourceforge.net/Get_User%27s_screen_resolution .
But I couldn't find anything usefull for the screen refresh rate.

Anyway, I'd like to give the first two a go, I'll hardcode the framerate for a while.
Can somebody help me to add these to the CommandLineArguments value in launcher.ini?
I've searched the forums and checked the launcher manual, but I couldn't find something to change/add a value.
This is the line I currently have in launcher.ini.
CommandLineArguments=' -Vidmode 1280,1024,60'

Do I have to delete the line and set it completely in Custom.nsh? If so, what NSIS call do I use?
Or replace "-Vidmode 1280,1024,60" with "-Vidmode AAAA,BBBB,CCCC" and replace these letters by the right values before the exe starts and reverse the change when the exe is finished?

This is all I thought about, can someone give me a hint?
Thanks in advance!

Gord Caswell
Gord Caswell's picture
Offline
Last seen: 1 month 2 weeks ago
DeveloperModerator
Joined: 2008-07-24 18:46
Environment variables

I would suggest using that function in Custom.nsh, and then set environment variables for the results.

You would then include those variables in your command line arguments, something like -Vidmode %ScreenHeight%,%ScreenWidth%, 60

Bennieboj
Bennieboj's picture
Offline
Last seen: 5 years 4 months ago
Joined: 2010-09-16 07:28
Thanks a lot!

Ok, it worked, here's the code if anyone is interested:

${SegmentInit}
	System::Call 'user32::GetSystemMetrics(i 0) i .r0'
	System::Call 'user32::GetSystemMetrics(i 1) i .r1'
	
	
	
	System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("ScreenHeight", $0).r2'
	StrCmp $2 0 error1
	  Goto done1
	error1:
	  MessageBox MB_OK "Can't set environment variable for ScreenHeight"
	done1:
	
	
	System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("ScreenWidth", $1).r3'
	StrCmp $3 0 error2
	  Goto done2
	error2:
	  MessageBox MB_OK "Can't set environment variable for ScreenWidth"
	done2:
!macroend

I'm not sure if the location of the code (Init) is ok, but hey, it works!

Yes, I set the working directory!

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 5 months ago
Joined: 2007-04-15 21:08
Simpler version

That code can be simplified considerably.

${SegmentFile}

${SegmentInit}
    System::Call user32::GetSystemMetrics(i0)i.r0
    System::Call user32::GetSystemMetrics(i1)i.r1

    ${SetEnvironmentVariable} ScreenHeight $0
    ${SetEnvironmentVariable} ScreenWidth  $1
!macroend

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

Bennieboj
Bennieboj's picture
Offline
Last seen: 5 years 4 months ago
Joined: 2010-09-16 07:28
Thanks for optimising

Thanks, I'm not that into the NSIS syntax.
Hopefully that'll change soon Biggrin

Yes, I set the working directory!

Log in or register to post comments