Hi there,
since I realized MortScript finally got to some use here, too, and I'm currently building an updated site, I wanted to gather some scripts which I could offer as examples on my page. Of course with a link to any origin you want - that way the author gets the credits, and I don't need to keep up with the latest update all the time...
Since I lost track of all the threads and scripts, I'd be nice if you could send me the interesting topics (a reply might be useful for others, too, but PM or contact formular or forum on mort.sto-helit.de is fine, too...).
TIA,
Mort
The 'clicky' thing:
Code:
if question "Please set the Camera app to photo mode before executing this script. Additionally, please remember to disable <<Reviev After Capture>> option in Camera before running this script! Run the script?","Important note"
setbacklight 1,1
Input limit, 1, "Total images to capture","MultiCapture"
if equals "",%limit%
set limit,10
endif
set total,0
Input delayer, 1, "Capture interval (seconds)","MultiCapture"
set delayer,%delayer%*1000
if equals %delayer%,0
set delayer,1000
endif
%czas%=%delayer%*%limit%/1000
%czas_m%=%czas%/60
%czas%="Total capture time: "&%czas%&" seconds, this is "&%czas_m%&" minutes."
message %czas%,"MultiCapture"
if question "Lock the touchscreen?","Touchscreen lock"
run tpdisable.exe
endif
run camera.exe
WaitForActive "Camera",10
setbacklight 0,0
while wndActive "Camera"
SendCR "Camera"
sleep %delayer%
%total%=%total%+1
if equals %total%,%limit%
Close "Camera"
endif
endwhile
run tpenable.exe
%total%="Images captured: " & %total%
message %total%,"Done"
endif
It does some pictures at regular interval, locking screen (using TPEnable/TPDisable).
The other script:
Code:
if wndActive "Camera"
regReadDword HKCU,"Software","tplock",lok
if equals %lok%,1
run "\windows\tpenable.exe"
regWriteDword HKCU,"Software","tplock",0
message "Screen unlocked.","Device lock"
else
run "\windows\tpdisable.exe"
regWriteDword HKCU,"Software","tplock",1
endif
else
run "\windows\alttab.exe"
endif
I have it bound to 'Record' button on my BA. If the camera is active, it locks the touchscreen (TPEnable/Disable again). If not - it executes SPBPocketPlus's AltTab.
MortScript rulez
I have one more, but a buggy one - it updates the Camera image capture dir to dd_mm_yyy. Will post it later on today...
Code:
if not regKeyExists HKCU,"Software\IA Style\IA CameraWizard(Pocket PC)\2.21\Strings","xImage folder"
regReadString HKCU,"Software\IA Style\IA CameraWizard(Pocket PC)\2.21\Strings","Image folder",pth
%msg%="This is the first time you use this script. The current image store path is: "&%pth%
message %msg%
if question "Run the Camera to change this value?"
runwait "camera.exe"
endif
regReadString HKCU,"Software\IA Style\IA CameraWizard(Pocket PC)\2.21\Strings","Image folder",pth
RegWriteString HKCU,"Software\IA Style\IA CameraWizard(Pocket PC)\2.21\Strings","xImage folder",%pth%
if question "Update the capture dir now?"
regReadString HKCU,"Software\IA Style\IA CameraWizard(Pocket PC)\2.21\Strings","Image folder",pth
else
exit
endif
endif
GetTime dat, "Y_m_d"
regReadString HKCU,"Software\IA Style\IA CameraWizard(Pocket PC)\2.21\Strings","xImage folder",pth
%dat%=%pth%&"\"&%dat%
MkDir %dat%
RegWriteString HKCU,"Software\IA Style\IA CameraWizard(Pocket PC)\2.21\Strings","Image folder",%dat%
%dat%="Image capture folder updated to "&%dat%
SleepMessage 5,%dat%,"Capture folder updated",1
Here is a short & sweet script I wrote that asks you if you'd like to rotate your screen before running TomTom then rotates it back when TomTom exits. This is useful because when driving, TomTom looks better in landscape mode, but there are times when just walking around and stuff it's better in portrait mode.
No credit needed really because of it's simplicity.
Edit: Sorry, I deleted the file off my server a while back when I was doing some spring cleaning... I don't have a copy of it any where.
Really it was just a couple mortscript commands. Anyone who spends 5 minutes and reads the mortscript documentation can figure it out.
BTW, I LOVE mortscript. It's very handy and I see it becoming more useful as the needs arise.
BT Sync
Hi,
I couldn't live without it. The following script connects Bluetooth through ActiveSync and Syncs. The connection will remain active until the script is started again, or the connection is closed manually.
Code:
If NOT wndExists "Connected to MEDIACENTER"
RegReadDWord HKLM, System\State\Hardware, Bluetooth, Bluetooth
If Expression %Bluetooth% <= 8
Set BluetoothWas, "Off"
Run "\Windows\ToggleBTH.exe"
Sleep 3000
EndIf
Run "\Windows\rnaapp.exe", -n -m -e"MEDIACENTER"
WaitFor "Connected to MEDIACENTER", 15
Run "\Windows\udp2tcp.exe"
Run "\Windows\rapiclnt.exe", -dppp_peer
Run "\Windows\repllog.exe", /remote /sched /h
Sleep 1000
RegWriteDWord HKLM, System\State\Hardware, Cradled, 1
While wndExists "Connected to MEDIACENTER"
Sleep 1000
EndWhile
Run "\Program Files\MortScript\TKill.exe", UDP to TCP proxy
Run "\Program Files\MortScript\TKill.exe", Remote API Client
Run "\Program Files\MortScript\TKill.exe", ActiveSync
If equals %BluetoothWas%, "Off"
Run "\Windows\ToggleBTH.exe"
EndIf
Else
Run "\Program Files\MortScript\TKill.exe", Connected to MEDIACENTER
EndIf
Needless to say you need to replace MEDIACENTER with the name of your own BT Connection.
ToggleBTH turns on the BlueTooth radio if it wasn't already on, and turns it off again is the connection is dropped.
TKill really kills the various processes when done; killing them with MortScript's internal commands didn't seem stable.
Cheers,
Cacti
GPRS Sync
Code:
# Witch operator are we on?
RegReadString HKLM, System\State\Phone, Current Operator Name, Operator
If Equals %Operator%, "Orange"
Set Orange, "On"
EndIf
# Orange Active? Switch to T-Mobile.
If Equals %Operator%, "Orange"
Run "\Windows\STK.exe"
SendUp STK Service
SendUp STK Service
SendDown STK Service
SendCR STK Service
Sleep 500
Minimize STK Service
EndIf
# Is T-Mobile Active?
RegReadString HKLM, System\State\Phone, Current Operator Name, Operator
While Not Equals %Operator%, "T-Mobile NL"
Sleep 1000
RegReadString HKLM, System\State\Phone, Current Operator Name, Operator
EndWhile
# GPRS Notificatie opslaan en daar uitzetten
RegReadDWord HKCU, ControlPanel\Notifications\{8ddf46e7-56ed-4750-9e58-afc6ce486d03}, Options, GPRSConnectNotification
RegWriteDWord HKCU, ControlPanel\Notifications\{8ddf46e7-56ed-4750-9e58-afc6ce486d03}, Options, 0
#Activesync
If wndExists "ActivSync"
Set ActiveSync, "On"
EndIf
Run "\Windows\repllog.exe", /h /sched /remote
Sleep 500
MouseClick ActiveSync 20, 310
Sleep 500
Minimize ActiveSync
RegReadDWord HKCU, Software\Microsoft\ActiveSync\Partners\{4FF3ACFA-3E07-42E1-83D9-4F04714CDC0B}, LastSyncSuccess, LastSyncSuccess
RegReadDWord HKCU, Software\Microsoft\ActiveSync\Partners\{4FF3ACFA-3E07-42E1-83D9-4F04714CDC0B}, LastSyncSuccess, NewSyncSuccess
While Equals %NewSyncSuccess%, %LastSyncSuccess%
Sleep 1000
RegReadDWord HKCU, Software\Microsoft\ActiveSync\Partners\{4FF3ACFA-3E07-42E1-83D9-4F04714CDC0B}, LastSyncSuccess, NewSyncSuccess
EndWhile
RegWriteDWord HKCU, ControlPanel\Notifications\{8ddf46e7-56ed-4750-9e58-afc6ce486d03}, Options, %GPRSConnectNotification%
If not Equals %ActiveSync%, "On"
Run "\Program Files\MortScript\TKill.exe", ActiveSync
EndIf
If Equals %Orange%, "On"
Run "\Windows\STK.exe"
SendUp STK Service
SendUp STK Service
SendCR STK Service
Sleep 1000
Minimize STK Service
Minimize STK Service
EndIf
This script ActiveSyncs over GPRS. I use a Dual SIM, (Orange & T-Mobile) and only the T-Mobile subscription have GPRS. So the script first determines if T-Mobile is active. If not is switches SIM. After that it just starts ActiveSync and syncs the {4FF3ACFA-3E07-42E1-83D9-4F04714CDC0B} partnership. After it finishes is swichtes SIMs again; I'm mainly on the Orange SIM.
I use the same methode before starting TomTom so my traffic information can be downloaded while driving.
If someone is interested I also have a script that (allong with some other little proggies) starts TomTom automaticly when I connect the power connector, but only if my carkit is connected.
MortScript makes me very lazy
Cheers,
Cacti
Code:
RegWriteString HKLM,Drivers\active\73,Name,COM6:
if question "Enable BT/GPS before running OziExplorer?","OziExplorer"
run "\program files\vijay555\vjvolubilis\vjvolubilis.exe", -blueon
runwait "\storage card2\oziexplorer\oziexplorerce.exe"
run "\program files\vijay555\vjvolubilis\vjvolubilis.exe", -blueoff
else
if question "Run OziExplorer anyway?","OziExplorer"
run "\storage card2\oziexplorer\oziexplorerce.exe"
endif
endif
Yay, does anyone use OziExplorerCE? I sometimes do
The script above utilizes vijay's VJVolubilis (great app, imho) to enable Bluetooth. It also adds 'fake' COM port in order to allow proper OziExplorerCE GPS configuration.
this is a very informative and useful thread.
i use mortscript on my T-Mobile SDA smartphone.
Alarm Script (reminder):
Cleanup Recently Used Programs
This script removes the list of recently used programs in the Start Menu.
Code:
if question ("Do you want to cleanup the Recent Programs from your Start Menu?","oldSAP's Cleanup")
x=0
While NOT (x = 12)
RegWriteString ("HKCU","Software\Microsoft\Shell\TaskSwitch",%x%,"")
x=x+1
EndWhile
if question ("You need to restart your device to see the effect. Restart Now?","oldSAP's Cleenup")
Reset
EndIf
EndIf
Copy/Paste
Copy and Paste script
Code:
num=Input ( "1=Copy All 2=Copy Word(s) 3=Copy Line 4=Paste ", "oldSAP Copy/Paste",1 )
if equals %num%, "1"
SendCtrlKey A
SendCtrlKey C
Else
if equals %num%, "2"
x=Input("How many words do you want to copy?","no. of words",1)
Repeat %x%
SendRight( "", 1, 1 )
EndRepeat
SendCtrlKey C
Else
if equals %num%, "3"
SendEnd( "", 0, 1 )
SendCtrlKey C
Else
if equals %num%, "4"
SendCtrlKey V
Else
EndIf
Wow, you sure give me some work for the weekend...
Very interesting collection, thank you!
I have a collection of scripts at this link.
http://discussion.treocentral.com/showthread.php?t=132525
Yay, I see LEDUp in use
(gotta switch to MortScript 4, 3.5 seems to be a bit old... )
here is a very basic script, I use it for apps that I want to stay alive until I close the app, eg GPS software, in particular Destinator.
Note, for some reason the volume part doesnt seem to work as it should.
Code:
#Basic script to set no timeouts and full brightness while using Destinator
#Read registry settings
#volume is not working for some reason
#Volume = RegRead ("HKCU", "ControlPanel\Volume\","Volume")
BattSuspendTimeout = RegRead ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","BattSuspendTimeout")
ACSuspendTimeout = RegRead ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","ACSuspendTimeout")
BatteryTimeout = RegRead ("HKCU", "ControlPanel\Backlight", "BatteryTimeout")
ACTimeout = RegRead ("HKCU", "ControlPanel\Backlight", "ACTimeout")
Brightness = RegRead ("HKCU", "ControlPanel\Backlight", "Brightness")
ACBrightness = RegRead ("HKCU", "ControlPanel\Backlight", "ACBrightness")
#Set registry settings
#RegWriteDword ("HKCU", "ControlPanel\Volume\","Volume", 2576980377)
RegWriteDword ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","BattSuspendTimeout",0)
RegWriteDword ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","ACSuspendTimeout",0)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "BatteryTimeout", 0)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "ACTimeout", 0)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "Brightness", 10)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "ACBrightness", 10)
#Change application to run here
RunWait ("\DestinatorApps\Destinator\DestiRobot.exe")
#Set registry settings back to normal use mode
#RegWriteDword ("HKCU", "ControlPanel\Volume\","Volume", Volume)
RegWriteDword ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","BattSuspendTimeout",BattSuspendTimeout)
RegWriteDword ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","ACSuspendTimeout",ACSuspendTimeout)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "BatteryTimeout", BatteryTimeout)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "ACTimeout", ACTimeout)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "Brightness", Brightness)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "ACBrightness", ACBrightness)
Great to see such a collection of genius in just ONE post!
It is probably a good idea to inform our captive audience that a majority of these scripts will work only with Mort's 4.0 RC3 version (or at least not the 3.1 version) so if you are having some problems launching these wonderful scripts download the Release Candidtate:
h++p://www.sto-helit.de/downloads/pocketpc/MortScript-4.0RC3.zip
(hope you don't mind me posting the link Mort)...
"Live long and Script!"
There's RC5 around at the "site to come": http://mort.sto-helit.de (see http://www.sto-helit.de for why there are two sites... ). It's mostly bugfixes. In RC4 I added the possibility to access COM ports, but I still have to update the manual... On that site, you'll also soon be able to find the scripts posted here...
There's also a new beta of MortButtons and the MortButton skins are migrated. But there's still a lot to do, esp. regarding MortPlayer...
Mort,
I noticed their is RC7 now, what has changed since RC4.. Is there a changelog we can view?
Need some help with the BT sound.
I got the bellow mortscript (posted by senergy) on my phone. And when I click on it it runs. But when I try to listen to sound over bluetooth it still goes directly to voicecommand regardless if I click yes or no. Am I doing something wrong? (using mortscript version 4)
EDIT:
Figured out the problem and removed bad script (Was using another cut and paste, this one did work!)
Orginaly posted by senergy
#basic mortscript to enable bt sound
#question
Switch (question ( "Do you want BT sound?", "Question", "YesNo"))
case (1)
RegWriteDword ("HKLM","Software\OEM\VoiceCommand","LaunchApEnable",0)
RegWriteDword ("HKLM","Software\OEM\VoiceCommand","VoiceCmdDuration",86400)
case (0)
RegWriteDword ("HKLM","Software\OEM\VoiceCommand","LaunchApEnable",1)
RegWriteDword ("HKLM","Software\OEM\VoiceCommand","VoiceCmdDuration",30)
endSwitch
Mortscript Press Button
Can someone please help me with this script, it should (amongst others) press Warning Message key in Navigon Mobile Navigator 6 but it doesn't always.
Probably because startuptime varies? I'm not sure about remaining script either......
# Position of MN6 Button to press
Set Position_X, "170"
Set Position_Y, "290"
# Set Bluetooth On
run "\Program Files\vijay555\VJVolubilis\VJVolubilis.exe", -blueon
# Start Navigon including FlitsNav
Run "\My Documents\POIWarner\FlitsNav.exe"
WaitForActive "Mobile Navigator 6", 60000
GetColorAt %Position_X%, %Position_Y%, colorStart
# Waiting time in milliseconds
Sleep 35000
Set true, "1"
While equals %true%, "1"
Sleep 1000
GetColorAt %Position_X%, %Position_Y%, color
If not equals %color%, %colorStart%
If wndActive "Mobile Navigator 6"
Sleep 1000
MouseClick "Mobile Navigator 6", %Position_X%, %Position_Y%
EndIf
Set true, "0"
EndIf
EndWhile
# Kills FlitsNav and Bluetooth after exit MN6
Runwait ("\SDMMC\MN6\MN6.exe")
run "\Program Files\vijay555\VJTaskKiller\VJTaskKiller.exe", FlitsNav
run "\Program Files\vijay555\VJVolubilis\VJVolubilis.exe", -blueoff
MortScript
Here`s some of my stuff, unfortunately mostly still on the "old" syntax.
I´ve started to rebuff some of the scripts (new syntax, mostly new concepts) but ran out of time during the last month.
I try to create "modules" for recurring tasks, to be called from within other scripts or, if appliccable, to be capable run standalone as well. Most of the module expect variables to be set, hence must be called using callscript.
Here is a newer one to display status messages and a kind of countdown. Once kicked off it runs on its own, refreshes (if required, i.e. if the status display needs to change) every second displaying the content of the registry value "info" until the registry value "DoShow" toggles. During the process a given startvalue (approximated duration) is decreased like a countdown and restartet if necessary.
This one is started with run, to have it operate totally independent, hence content is communicated via registry values.
Code:
# Modul zum Zeigen von Status / Info messages
# uebergeben per Reg. Werten
#
# HGH 11-26/06
#
errorlevel warn
#
if ( \
NOT \
( \
RegValueExists \
("HKCU", "Software\Mistrix\ShowStat","DoShow") \
AND \
RegValueExists \
("HKCU", "Software\Mistrix\ShowStat","RefCycle") \
AND \
RegValueExists \
("HKCU", "Software\Mistrix\ShowStat","Info") \
AND \
RegValueExists \
("HKCU","Software\Mistrix\ShowStat","InfoHeader") \
AND \
RegValueExists \
("HKCU", "Software\Mistrix\ShowStat", "OKAllow") \
) \
)
message ( \
"RegWerte nicht gefunden", \
SystemPath("ScriptName") \
& SystemPath("ScriptExt") \
)
exit
EndIf
#
# "Gesamtzeit" aus Reg lesen
GCycle = RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"RefCycle")
#
TStampStart = TimeStamp ()
#
while (RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow") = 1)
InfAlt = RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"Info")
If (TimeStamp () - TStampStart > GCycle )
TStampStart = TimeStamp ()
EndIf
ShowCycle = GCycle - TimeStamp () + TStampStart
Sleepmessage \
( \
ShowCycle , \
InfAlt, \
RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"InfoHeader"), \
1, \
RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow") <> 1 OR InfAlt ne RegRead \
("HKCU", "Software\Mistrix\ShowStat", \
"Info") \
)
#
# ggf. (OKAllow=1) warten,
# bis sich ein Status geaendert hat
while ( \
RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow") = 1 AND InfAlt eq RegRead \
("HKCU", "Software\Mistrix\ShowStat", \
"Info") AND RegRead ("HKCU", \
"Software\Mistrix\ShowStat", \
"OKAllow") = 1 \
)
sleep (1000)
EndWhile
#
EndWhile
#
exit
Next is an example, how to use it. There could be any
code instead of the sleeps,
just reload "Info" whenever you want to have your
status display updated...
Code:
# TestRahmen fuer Status / Info messages
# mittels ShowStat.mscr
#
# HGH 11-26/06
#
errorlevel warn
#
# Setzen der Reg. Werte - set the registry values
# Stausmeldungen aktiv - activate status display
RegWriteDword ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow", 1)
# Darf der User Message wegcklicken? -
# may the user cancel status display
RegWriteDword ("HKCU", "Software\Mistrix\ShowStat", \
"OKAllow", 1)
# "Gesamtzeit" - approximated total time
RegWriteDword ("HKCU", "Software\Mistrix\ShowStat", \
"RefCycle", 30)
# InfoHeader - title
RegWriteString ("HKCU", "Software\Mistrix\ShowStat", \
"InfoHeader", "TestStati" )
# InfoText - status text
RegWriteString ("HKCU", "Software\Mistrix\ShowStat", \
"Info", "Status1" )
#
# Starten der Show Info Routine - status modul start
run ( SystemPath("ScriptPath") \ "ShowStat.mscr")
#
sleep (8000)
#
# neuer Infotext - new status content
RegWriteString ("HKCU", "Software\Mistrix\ShowStat", \
"Info", "Status2" )
#
sleep (12000)
#
# neuer Infotext - new status content
RegWriteString ("HKCU", "Software\Mistrix\ShowStat", \
"Info", "Status3" )
#
sleep (5000)
#
# Statusmeldungen inaktiv - status display off
RegWriteDword ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow", 0)
#
exit
basically what the title says. I've written some code tht should detect the .net version and if it is not 3.5 or newer then show a message box and then exit the program but it's giving me a nullreferrence exception becuase of the way it checks for the version number. I'll post it below and bold the line that gives the error.
Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NetCFKey [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"software\Microsoft\.netcompactframework\"[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NetCFPath [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] RegistryKey = Registry.LocalMachine.OpenSubKey(NetCFKey)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NetCFValueNames() [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = NetCFPath.GetValueNames[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] valuename [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NetCFValueNames[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NetCFValue [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] RegistryKey = NetCFPath.OpenSubKey(valuename)[/SIZE]
[B][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] value [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = NetCFValue.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"3.5.9085.00"[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B])[/B][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] value [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Is[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"0"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MsgBoxQ [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]".Net Compact Framework 3.5 or greater is not installed."[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Caption [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Error"[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Buttons [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MessageBoxButtons = MessageBoxButtons.OK[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MsgBoxIcon [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MessageBoxIcon = MessageBoxIcon.Exclamation[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OKBox [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] DialogResult[/SIZE]
[SIZE=2]OKBox = MessageBox.Show(MsgBoxQ, Caption, Buttons,_[/SIZE]
[SIZE=2] MsgBoxIcon, MessageBoxDefaultButton.Button1)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OKBox = Windows.Forms.DialogResult.OK [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]Application.Exit()[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] value [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Is[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"1"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]
[/COLOR][/SIZE]
My first thought was to use a wildcard so the keyname would look like this:
"3.5.*"
but after doing a little googling i'm not sure it will work. So Does anybody have any ideas on how to improve it?
Thanks guys.
AFAIK each WinCE/WinMo device has a file ceconfig.h in <root>\Windows. Why not simply read this file to get out the .NET CF version installed. if any? In one of my private projects to be run on a WinCE 5.0 based device I realised this with MortScript (Basic alike synthax) as following (excerpt):
Code:
#Read CeConfig.h (CE license level)
Local(windows_ceconfig_file,file,line,cnt,netcf20,netcf35)
netcf20=0
netcf35=0
windows_ceconfig_file="\Windows\ceconfig.h"
cnt=0
If(FileExists(windows_ceconfig_file))
file=""&ReadFile(windows_ceconfig_file,FileSize(windows_ceconfig_file,MB))
If(Length(file))
file=Split(file,"^NL^")
ForEach line in Array(file)
cnt+=1
If((NOT netcf20)||(NOT netcf35))
If(Find(line,"NETCFV2_MODULES_DOTNETV2"))
netcf20=1
ElseIf(Find(line,"NETCFV35_MODULES_DOTNETV35"))
netcf35=1
EndIf
EndIf
#stop further searching
If(netcf20||netcf35)
Break
EndIf
Sleep 100
EndForEach
EndIf
Clear(file)
Clear(line)
EndIf
Clear(windows_ceconfig_file)
If(NOT cnt)
#Error processing goes here
EndIf
Clear(cnt)
Please apologize this contribution! Should only be a demonstration it could be done another way.
jwoegerbauer said:
AFAIK each WinCE/WinMo device has a file ceconfig.h in <root>\Windows. Why not simply read this file to get out the .NET CF version installed. if any? In one of my private projects to be run on a WinCE 5.0 based device I realised this with MortScript (Basic alike synthax) as following (excerpt):
Code:
#Read CeConfig.h (CE license level)
Local(windows_ceconfig_file,file,line,cnt,netcf20,netcf35)
netcf20=0
netcf35=0
windows_ceconfig_file="\Windows\ceconfig.h"
cnt=0
If(FileExists(windows_ceconfig_file))
file=""&ReadFile(windows_ceconfig_file,FileSize(windows_ceconfig_file,MB))
If(Length(file))
file=Split(file,"^NL^")
ForEach line in Array(file)
cnt+=1
If((NOT netcf20)||(NOT netcf35))
If(Find(line,"NETCFV2_MODULES_DOTNETV2"))
netcf20=1
ElseIf(Find(line,"NETCFV35_MODULES_DOTNETV35"))
netcf35=1
EndIf
EndIf
#stop further searching
If(netcf20||netcf35)
Break
EndIf
Sleep 100
EndForEach
EndIf
Clear(file)
Clear(line)
EndIf
Clear(windows_ceconfig_file)
If(NOT cnt)
#Error processing goes here
EndIf
Clear(cnt)
Please apologize this contribution! Should only be a demonstration it could be done another way.
Click to expand...
Click to collapse
I'll check this method out. Thanks a lot.
The reason i did it the way i did was because every device has a registry value in HKLM\software\microsoft\.netcompactframework that is named the same as the build number and MS recommends checking for those values.
Something else to think about :-
If your application is already written in .NET CF 3.5, it is probably going to throw an error anyway if version 3.5 is not present on the device.
This will happen as the program is loaded, before your VB validating code even gets a chance to run.
stephj said:
Something else to think about :-
If your application is already written in .NET CF 3.5, it is probably going to throw an error anyway if version 3.5 is not present on the device.
This will happen as the program is loaded, before your VB validating code even gets a chance to run.
Click to expand...
Click to collapse
Ironically, the reason i'm developing this code is because i had 2 users try and run the program on a rom that didn't have .net 3.5 and it thusly crashed.
So i guess i wasting my time?
It is looking that way.
Incidentally, to find out which version(s) of .NET CF are on your device, just run cgacutil.exe in the \Windows subdirectory of your device.
It pops up a message box with the version(s) installed, as per attached image.