Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,738,819 Members 41,617 Now Online
XDA Developers Android and Mobile Development Forum

Creating shortcuts which "wrap" a program with WVGAFIX3

Tip us?
 
ugumba
Old
(Last edited by ugumba; 26th June 2009 at 10:42 PM.) Reason: added Sleep suggested by mr_deimos
#1  
Senior Member - OP
Thanks Meter 49
Posts: 391
Join Date: May 2007
Location: Oslo
Default Creating shortcuts which "wrap" a program with WVGAFIX3

For some time, I've been using WVGAFIX3 on my Blackstone to run older games supporting only 320x240 (QVGA) or 640x480 (VGA) resolutions.

As excellent as WVGAFIX3 is, running WVGAFIX3 "by hand" has always been annoying, especially if I forget it the first time, and copying and editing the typical Mortscript for each new game is a hassle:

Code:
Select Code
RunWait("\Windows\WVGAFIX3APP.exe", "-640")
Sleep(500)  # pause suggested by mr_deimos, to allow the dust to settle
RunWait("\path\to\game.EXE)
Run("\Windows\WVGAFIX3APP.exe", "-800")
These scripts have to be stored somewhere, and icons can't be assigned to them, so they're not a good alternative to the plain shortcut.

My next step was to generalize the script (called RunVGA.mscr):

Code:
Select Code
RunWait("\Windows\WVGAFIX3APP.exe", "-640")
Sleep(500)
RunWait(arg1)
Run("\Windows\WVGAFIX3APP.exe", "-800")
Now, arg1 can be given at the command line in the shortcut - this example is Shift.lnk (for this free, excellent little time waster):

Code:
Select Code
132#"\Windows\Mortscript.exe" "\bin\RunVGA.mscr" arg1="\Program Files\Shift\Shift.exe" ?\Program Files\Shift\Shift.exe,
(The Shift game can really mess up the Blacstone's display if WVGAFIX3 is not used - I've had to soft reset a couple of times when I forgot!)

This shortcut will look like the original, as the icon is preserved (by repeating the EXE path between "?" and ",", and providing no icon ID after ",", thus using the default ID). When launched, RunVGA script above will do its thing.

Now, the next improvement would be to simplify the shortcut (at the cost of launching an extra process). I have modified RunMscr.exe found here. When renamed to yourscript.exe, the original executes
Code:
Select Code
Mortscript.exe yourscript.mscr argument1 argument2 ...
My patched version (attached) executes
Code:
Select Code
Mortscript.exe yourscript.mscr arg1=argument1 arg2=argument2 ...
Notice that RunMscr.exe implicitly names the arguments, something which should have been done by Mortscript a long time ago, in my opinion. Thus, I can copy RunMscr.exe to RunVGA.exe, and modify the shortcut above to
Code:
Select Code
132#"\bin\RunVGA.exe" "\Program Files\Shift\Shift.exe" ?\Program Files\Shift\Shift.exe,
(Notice that I keep all scripts and manually copied executables in \bin - adjust accordingly in the scripts provided!)

Having RunVGA.exe with my method of passing arguments, means that you can also launch an executable in VGA mode directly from Resco Explorer by using tap and hold, "Open With...", and browsing to RunVGA.exe.

Now, I was pretty happy with this, but wanted a lazy man's solution for creating these shortcuts (and reverting to the original). The following describes how to toggle a shortcut between its original version and its RunVGA version, again using "Open with..." in Resco Explorer.

First create ToggleVGAfix.mscr:

Code:
Select Code
line=ReadLine(arg1)
Split(line,"#",1,length,shortcut)
Split(shortcut,"?",1,shortcut,icon)

If (Find(shortcut, "RunVGA") = 0)
	# This is a normal shortcut, convert to RunVGA shortcut
	If (icon eq "")
		icon = shortcut
		# Strip quotes from icon string
		While (CharAt(icon, Length(icon)) eq """")
			icon = SubStr(icon, 1, Length(icon)-1)
		EndWhile
		While (CharAt(icon,0) eq """")
			icon = SubStr(icon, 2)
		EndWhile
		icon = icon & ","
	EndIf
	line = length & "#" & """\bin\RunVGA.exe"" " & shortcut & " ?" & icon
Else
	# This is a RunVGA shortcut, revert to original
	Split(shortcut,"RunVGA.exe"" ",1,dummy,target)
	line = length & "#" & target
EndIf

# Uncommment if you want to keep the original
#Rename(arg1, arg1 & ".bak", TRUE)
WriteFile(arg1, line)
Next, copy RunMscr.exe to ToggleVGAfix.exe (next to the ToggleVGAfix.mscr script above).
In Resco Explorer, navigate to a shortcut you want to test this on, tap and hold, select Open With, and browse to ToggleVGAfix.exe. Then try launching the shortcut itself - if all goes well, the program will run in VGA mode, and revert back to WVGA when ended.

With all this behind us, we've accomplished this: The next time you install a QVGA/VGA game, navigate to the \Windows\Start Menu\Programs\Games (according to your locale) folder, tap and hold the shortcut, select ToggleVGAfix, and you should be good to go from your normal Games menu.

A small caveat: I've noticed that WVGAFIX3 occasionally doesn't kick into effect in time for the "wrapped" exe. I may look into this if it proves to be enough of a problem. Edit: added a Sleep which fixed this problem for mr_deimos.
Attached Files
File Type: zip runmscr.zip - [Click for QR Code] (2.2 KB, 83 views)
 
CowMix
Old
#2  
Senior Member
Thanks Meter 4
Posts: 282
Join Date: Apr 2009
great job! I wish wvga worked on wm 6.5 so I could use this with wvga

this can be useful with other programs tho too, do you think i can use this to disable windows mobile's setting temporarily while certain programs are running? I'm having a problem with an music player going into sleep mode while I'm playing a song but I don't want to disable windows mobile sleep completely cause it saves so much battery life.

also is it possible to use this to run a program automatically in the background by ridirecting to the today screen right after running the program?
 
mr_deimos
Old
(Last edited by mr_deimos; 24th June 2009 at 10:50 PM.)
#3  
mr_deimos's Avatar
Senior Member
Thanks Meter 90
Posts: 386
Join Date: Nov 2007

 
DONATE TO ME
Nice job. Believe me or not, but i made a script identical to the first one you posted a week ago - just for launching Shift on my wvag toshiba g900 :P But i just put the shortcut to mscr file in the start menu - you actually can change it's icon so it was good enough for me.
My shortcut is:
Code:
Select Code
104#"\Storage Card\Program Files\Games\Shift\Shift.mscr"?\Storage Card\Program Files\Games\Shift\Shift.exe,0
But of course, your automagic solution for toggling wvgafix is much better than doing everything by hand

Just a little note - you might want to add a Sleep(500) or even Sleep(1000) before running the app itself. Just using the RunWait to launch wvgafix usually works, but today when i launched shift with script without Sleep() the game actually started before wvgafix finished resizing the screen. So all i got was a black screen. I could close shift by tapping in the top-right corner of the screen, but taskbar remained hidden and i had to soft-reset to get it back. It happened twice in a row. It's seems to be the same problem you're facing. In my case it was probably caused by the fact that my pda is running underclocked a bit (when i was first testing the script it was running at full speed). After putting in the additional 1-second sleep everything works like a charm And the difference in startup time isn't really noticeable.
 
ugumba
Old
#4  
Senior Member - OP
Thanks Meter 49
Posts: 391
Join Date: May 2007
Location: Oslo
Quote:
Originally Posted by CowMix View Post
great job! I wish wvga worked on wm 6.5 so I could use this with wvga
Yes, this is one of the reasons I'm postponing 6.5. (The other, of course, is that kwbr has not yet released a Topix based on 6.5 )

Quote:
this can be useful with other programs tho too, do you think i can use this to disable windows mobile's setting temporarily while certain programs are running? I'm having a problem with an music player going into sleep mode while I'm playing a song but I don't want to disable windows mobile sleep completely cause it saves so much battery life.
Unless your player has the option to disable sleep, modifying my script(s) will probably work fine. Simply replace the Run statements for WVGAFIX3 with whatever executables or registry changes you want to happen. For registry changes, you may want the safeguard of resetting the "standard" values at startup, in case your phone resets or turns off while your player (and the script) is running.

Quote:
also is it possible to use this to run a program automatically in the background by ridirecting to the today screen right after running the program?
Probably! Replace the code in the first script with something like this (untested):

Code:
Select Code
Run(arg1)
Sleep(1000)
Show("Start")
A different take:

Code:
Select Code
Run(arg1)
title = "Title of window to hide"
WaitFor(title, 30)
Minimize(title)
This will need more work to use with my shortcuts, as this script also needs the title of the window to hide. The benefit is that Windows will show the previously active window instead of Today, which is usually what you want.
 
ugumba
Old
#5  
Senior Member - OP
Thanks Meter 49
Posts: 391
Join Date: May 2007
Location: Oslo
Quote:
Originally Posted by mr_deimos View Post
Nice job. Believe me or not, but i made a script identical to the first one you posted a week ago - just for launching Shift on my wvag toshiba g900 :P
I think many of us have done a similar job with Shift .

Quote:
But i just put the shortcut to mscr file in the start menu - you actually can change it's icon so it was good enough for me.
That works - I would have preferred to put the mscr directly into the Start menu (to avoid having to stash them somewhere else). In this case the icon is determined by the mscr extension, which looks dull, to say the least .

Code:
Select Code
104#"\Storage Card\Program Files\Games\Shift\Shift.mscr"?\Storage Card\Program Files\Games\Shift\Shift.exe,0
Is 0 the icon ID, or just the "default" icon? I simply tried with nothing after the comma, and it seemed to pick up the default icon in each EXE/DLL.

Quote:
But of course, your automagic solution for toggling wvgafix is much better than doing everything by hand
Thanks - it's something I've been meaning to figure our for at least 6 months, since I learned that WVGAFIX3 takes command line parameters.

Quote:
Just a little note - you might want to add a Sleep(500) or even Sleep(1000) before running the app itself. ...
Thanks - added!
 
mr_deimos
Old
#6  
mr_deimos's Avatar
Senior Member
Thanks Meter 90
Posts: 386
Join Date: Nov 2007

 
DONATE TO ME
Quote:
Originally Posted by ugumba View Post
Is 0 the icon ID, or just the "default" icon? I simply tried with nothing after the comma, and it seemed to pick up the default icon in each EXE/DLL.
It seems the default icon ID - the one displayed by the OS. I didn't even know you can just omit this parameter So probably both ways will give the same results.
 
Revin
Old
#7  
Senior Member
Thanks Meter 22
Posts: 195
Join Date: Jul 2007
Great thing! I tried and it works! But I have another problem. I am using Fingerkeyboard and when I switch the resolution to VGA it is still showing me error that this resolution is not supported (there is download for each resolution and it is not possible to have WWGA and VGA installed).

So my question is - it is possible to change software keyboard by Mortscript? And then, when application ends change it back?

Thank you
 
Revin
Old
#8  
Senior Member
Thanks Meter 22
Posts: 195
Join Date: Jul 2007
I found the solution, I am switching the keyboards with this tool from Vijay555: http://forum.xda-developers.com/showthread.php?t=242503
Great thing, so now I don't have to remember to change keyboard, change screen...
 
mr_deimos
Old
#9  
mr_deimos's Avatar
Senior Member
Thanks Meter 90
Posts: 386
Join Date: Nov 2007

 
DONATE TO ME
Quote:
Originally Posted by ugumba View Post
For some time, I've been using WVGAFIX3 on my
In Resco Explorer, navigate to a shortcut you want to test this on, tap and hold, select Open With, and browse to ToggleVGAfix.exe.
It seems that you don't need the non-freeware resco explorer for that - the file explorer extension from here:
http://forum.xda-developers.com/showthread.php?t=421723
also provides this functionality. You would just need to make sure that the shortcut to ToggleVGAFix.exe is in the start menu (the file explorer extension can't browse for program to open file with).
 
Rizzen
Old
#10  
Senior Member
Thanks Meter 10
Posts: 168
Join Date: Jul 2007
Quote:
Originally Posted by ugumba View Post
For some time, I've been using WVGAFIX3 on my Blackstone to run older games supporting only 320x240 (QVGA) or 640x480 (VGA) resolutions.

As excellent as WVGAFIX3 is, running WVGAFIX3 "by hand" has always been annoying, especially if I forget it the first time, and copying and editing the typical Mortscript for each new game is a hassle:

Code:
Select Code
RunWait("\Windows\WVGAFIX3APP.exe", "-640")
Sleep(500)  # pause suggested by mr_deimos, to allow the dust to settle
RunWait("\path\to\game.EXE)
Run("\Windows\WVGAFIX3APP.exe", "-800")
These scripts have to be stored somewhere, and icons can't be assigned to them, so they're not a good alternative to the plain shortcut.

My next step was to generalize the script (called RunVGA.mscr):

Code:
Select Code
RunWait("\Windows\WVGAFIX3APP.exe", "-640")
Sleep(500)
RunWait(arg1)
Run("\Windows\WVGAFIX3APP.exe", "-800")
Now, arg1 can be given at the command line in the shortcut - this example is Shift.lnk (for this free, excellent little time waster):

Code:
Select Code
132#"\Windows\Mortscript.exe" "\bin\RunVGA.mscr" arg1="\Program Files\Shift\Shift.exe" ?\Program Files\Shift\Shift.exe,
(The Shift game can really mess up the Blacstone's display if WVGAFIX3 is not used - I've had to soft reset a couple of times when I forgot!)

This shortcut will look like the original, as the icon is preserved (by repeating the EXE path between "?" and ",", and providing no icon ID after ",", thus using the default ID). When launched, RunVGA script above will do its thing.

Now, the next improvement would be to simplify the shortcut (at the cost of launching an extra process). I have modified RunMscr.exe found here. When renamed to yourscript.exe, the original executes
Code:
Select Code
Mortscript.exe yourscript.mscr argument1 argument2 ...
My patched version (attached) executes
Code:
Select Code
Mortscript.exe yourscript.mscr arg1=argument1 arg2=argument2 ...
Notice that RunMscr.exe implicitly names the arguments, something which should have been done by Mortscript a long time ago, in my opinion. Thus, I can copy RunMscr.exe to RunVGA.exe, and modify the shortcut above to
Code:
Select Code
132#"\bin\RunVGA.exe" "\Program Files\Shift\Shift.exe" ?\Program Files\Shift\Shift.exe,
(Notice that I keep all scripts and manually copied executables in \bin - adjust accordingly in the scripts provided!)

Having RunVGA.exe with my method of passing arguments, means that you can also launch an executable in VGA mode directly from Resco Explorer by using tap and hold, "Open With...", and browsing to RunVGA.exe.

Now, I was pretty happy with this, but wanted a lazy man's solution for creating these shortcuts (and reverting to the original). The following describes how to toggle a shortcut between its original version and its RunVGA version, again using "Open with..." in Resco Explorer.

First create ToggleVGAfix.mscr:

Code:
Select Code
line=ReadLine(arg1)
Split(line,"#",1,length,shortcut)
Split(shortcut,"?",1,shortcut,icon)

If (Find(shortcut, "RunVGA") = 0)
	# This is a normal shortcut, convert to RunVGA shortcut
	If (icon eq "")
		icon = shortcut
		# Strip quotes from icon string
		While (CharAt(icon, Length(icon)) eq """")
			icon = SubStr(icon, 1, Length(icon)-1)
		EndWhile
		While (CharAt(icon,0) eq """")
			icon = SubStr(icon, 2)
		EndWhile
		icon = icon & ","
	EndIf
	line = length & "#" & """\bin\RunVGA.exe"" " & shortcut & " ?" & icon
Else
	# This is a RunVGA shortcut, revert to original
	Split(shortcut,"RunVGA.exe"" ",1,dummy,target)
	line = length & "#" & target
EndIf

# Uncommment if you want to keep the original
#Rename(arg1, arg1 & ".bak", TRUE)
WriteFile(arg1, line)
Next, copy RunMscr.exe to ToggleVGAfix.exe (next to the ToggleVGAfix.mscr script above).
In Resco Explorer, navigate to a shortcut you want to test this on, tap and hold, select Open With, and browse to ToggleVGAfix.exe. Then try launching the shortcut itself - if all goes well, the program will run in VGA mode, and revert back to WVGA when ended.

With all this behind us, we've accomplished this: The next time you install a QVGA/VGA game, navigate to the \Windows\Start Menu\Programs\Games (according to your locale) folder, tap and hold the shortcut, select ToggleVGAfix, and you should be good to go from your normal Games menu.

A small caveat: I've noticed that WVGAFIX3 occasionally doesn't kick into effect in time for the "wrapped" exe. I may look into this if it proves to be enough of a problem. Edit: added a Sleep which fixed this problem for mr_deimos.
Hi, sounds really great. but i have problems to understand...
which files do i need and where i have to place them?
do i need for every game a own file?

greetings

Tags
blackstone, mortscript, shortcut, wvgafix3
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


TRENDING IN THEMER...