Creating shortcuts which "wrap" a program with WVGAFIX3

Search This thread

ugumba

Senior Member
May 18, 2007
427
57
Oslo
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:
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:
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:
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:
Mortscript.exe yourscript.mscr argument1 argument2 ...

My patched version (attached) executes
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:
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:
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.
 

Attachments

  • runmscr.zip
    2.2 KB · Views: 95
Last edited:

CowMix

Senior Member
Apr 23, 2009
288
8
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

Senior Member
Nov 22, 2007
386
101
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:
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 :D

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.
 
Last edited:

ugumba

Senior Member
May 18, 2007
427
57
Oslo
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 :p)

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.

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:
Run(arg1)
Sleep(1000)
Show("Start")

A different take:

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

Senior Member
May 18, 2007
427
57
Oslo
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 :D.

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 :p.

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.

But of course, your automagic solution for toggling wvgafix is much better than doing everything by hand :D

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.

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

Senior Member
Nov 22, 2007
386
101
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

Senior Member
Jul 21, 2007
277
47
Nintendo Switch
Samsung Galaxy S23
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
 

mr_deimos

Senior Member
Nov 22, 2007
386
101
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://xdaforums.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

Senior Member
Jul 15, 2007
197
14
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:
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:
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:
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:
Mortscript.exe yourscript.mscr argument1 argument2 ...

My patched version (attached) executes
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:
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:
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
 

ugumba

Senior Member
May 18, 2007
427
57
Oslo
Clearly, getting this setup on your device is left as an exercise for the reader! :) I basically did this for myself, but wanted to share something I found useful, and explain how I got there. Maybe if there's enough interest, I'll try making a CAB.

I'll try to clarify a bit, though:

1. You need Mortscript installed (I use 4.2 which comes with SASHIMI)
2. You need WVGAFIX3 installed.
3. You need 2 scripts copied from my first post, named RunVGA.mscr and ToggleVGAfix.mscr. If you already have a folder for your personal scripts collection (I use \Storage Card\bin), I suggest you put them there.
4. You need my version of runmscr.exe, attached to my first post, copied to your scripts folder as RunVGA.exe and ToggleVGAfix.exe.
5. You need a file explorer capable of handling alternate associations, so that you can register the two executables as "handlers" for the .lnk extension. On my device, Resco Explorer is indispensable.
6. Finally (the hard part) you need to loosely follow and understand the instructions in the first post, and adjust them to your situation when needed. The important part is after the ToggleVGAfix code (2 paragraphs).

Except for editing ToggleVGAfix.mscr according to your scripts folder, you should never have to edit a file, understand the .lnk format or really understand Mortscript. (All my talk around the Shift shortcut is just me being long winded and feeling I have to explain everything. See how this "little" post turned out? :))

If this seems mystical or unclear, I suggest reading the Mortscript manual - you'll be happy you did. Also, Barbudor's page on the original runmscr might shed some light on my rants.
 

vijay555

Retired Moderator
Jun 4, 2005
5,789
68
Witch Space
www.vijay555.com
Hey, sorry for jumping on after the horse has bolted, I've been dead for a while, but it's better now...

There's another version of SipSwitch out, called VJSipSwitch (I think).
Don't use the old one, because although functional, I wrote it when I didn't know how to code, akin to a thousand monkeys = Shakespeare.

V