5,597,762 Members 36,103 Now Online
XDA Developers Android and Mobile Development Forum

MortScripts to toggle settings

Tip us?
 
RoryB
Old
(Last edited by RoryB; 27th June 2011 at 08:55 PM.)
#1  
RoryB's Avatar
Recognized Developer - OP
Thanks Meter 652
Posts: 2,716
Join Date: Sep 2008
Location: Lexington

 
DONATE TO ME
Default MortScripts to toggle settings

This thread is dedicated to MortScripts that we use to change settings. Most of these can be stand alone scripts, but I got started creating this thread based on CHTS needing WMLongLife to change from Automatic to GSM radio profile. I found that WMLL seemed to eat up battery life in my old Fuze. I tried a script or two from the MortScript examples thread, but they did not work for me. I'll be posting various scripts that I use during my profile changes in CHTS, but I will in such a way that if you do not use CHTS you can still use the scripts.

Another purpose of this thread is to make these scripts available to those who for one reason or another the default programs in CHTS do not work and perhaps the script will. An example is sound profile changing to Automatic was not available so I added a script to do it for me. The feature had been turned off since it did not work in all phones. In a coming version I believe it will be back. The beta test works in my Fuze.

The hope of this thread is to help those that use CHTS to get some of the features that may not work on their phone through MortScripts instead. Also, as a place to share these "TOGGLE" switch scripts for others to be able to use outside CHTS.

I am trying to write scripts that do not use programs outside windows mobile. The hope is that they can be used in as many phones and ROMs as possible. An example is the first form of my Band_Changer used a program in CHTS and I reworked it to not require that program.


Radio toggle between Automatic (2G & 3G) and GSM (2G only): Post #2

Switch Sound Profile: Post #3

Auto time zone toggle: Post #5 and Post #8

Toggle Backlight: Post #14

Toggle Screen Rotation: Post #15

Toggle between Active Sync and Mass Storage: Post #16

Toggle Voice Command: Post #17
AT&T Samsung Galaxy S III
Read About Me to see what I am working on & following like CHTS, Reminder and AppTask widgets, and CHT basic function tweaks. Also, Fixed CHT restarting when you have no tasks.
Mortscript | iniEditor | regEditor| MortScripts to toggle settings
Samsung Infuse 4G drowned. If you have one check out Scott's CM10 or CM10PA Firmware
ATT Fuze (HTC RAPH110) with Energy ROM: Energy.RAPHAEL.29022.Sense2.5.Cookie.2.0.Jul.06
HTC Wizard|See about me for my ROM collection and other work
The Following 3 Users Say Thank You to RoryB For This Useful Post: [ Click to Expand ]
 
RoryB
Old
(Last edited by RoryB; 27th June 2011 at 06:58 PM.) Reason: Modified Band_Changer.mscr due to connection error messages again
#2  
RoryB's Avatar
Recognized Developer - OP
Thanks Meter 652
Posts: 2,716
Join Date: Sep 2008
Location: Lexington

 
DONATE TO ME
Default Radio toggle between Automatic (2G & 3G) and GSM (2G only)

This script calls the main script with the argument required based on your current profile to switch the profile to the other.

Code:
# Band_Toggle.mscr
opmode = RegRead( "HKLM","Software\OEM\UMTS","OpMode")
opmode = RegRead( "HKLM","Software\OEM\PhoneSetting\NetworkType","ItemName" & OpMode + 1)

If(opmode eq "Auto")
	key = "g"
Else
	key = "a"
EndIf
       CallScript("\storage card\scripts\Band_Changer.mscr", key)
  #    CallScript("\windows\Band_Changer.mscr", key)
I test the script in my storage card, but when I use it for CHTS I would have it in \windows folder.

This is the main script:

Code:
# Band_Changer.mscr

If(NOT FileExists("\Windows\CMBandSwitching.exe"))
	Message("You must have CMBandSwitching.exe installed in windows folder.^NL^^NL^Script will exit now.", "ERROR")
	Exit
EndIf

key = argv[1]
key = (key eq "a")?"Auto":"GSM"
opmode = RegRead( "HKLM","Software\OEM\UMTS","OpMode")
opmode = RegRead( "HKLM","Software\OEM\PhoneSetting\NetworkType","ItemName" & OpMode + 1)
network1 = RegRead( "HKLM","Software\OEM\PhoneSetting\NetworkType","ItemName1" )
network2 = RegRead( "HKLM","Software\OEM\PhoneSetting\NetworkType","ItemName2" )
network3 = RegRead( "HKLM","Software\OEM\PhoneSetting\NetworkType","ItemName3" )

If(key ne OpMode)
	If(key eq network1)
		key = 1
	ElseIf(key eq network2)
		key = 2
	ElseIf(key eq network3)
		key = 3
	Else
	EndIf
	Call("switcher")
EndIf

Sub switcher
	Global(key)

	SendSpecial(126) # Data disconnect
	i=0
	ForEach xvariable in regSubkeys("HKLM", "Comm\ConnMgr\Providers\{7C4B7A38-5FF7-4bc1-80F6-5DA7870BB1AA}\Connections")
		i+=1
		enable[i] = RegRead("HKLM", "Comm\ConnMgr\Providers\{7C4B7A38-5FF7-4bc1-80F6-5DA7870BB1AA}\Connections" \ xvariable, "Enabled")
	EndForEach
	Sleep(500)
	ForEach xvariable in regSubkeys("HKLM", "Comm\ConnMgr\Providers\{7C4B7A38-5FF7-4bc1-80F6-5DA7870BB1AA}\Connections")
		RegWriteDWord("HKLM", "Comm\ConnMgr\Providers\{7C4B7A38-5FF7-4bc1-80F6-5DA7870BB1AA}\Connections" \ xvariable, "Enabled", 0)
	EndForEach
	Sleep(500)

	Run("\Windows\CMBandSwitching.exe")
	If(ScreenHeight() eq 640)
		Y1 = 160 # 1st button which is Auto on my Fuze 163
		Y2 = 245 # 2nd button which is GSM on my Fuze 244
		Y3 = 315 # 3rd button which is WCDMA on my Fuze 314
		Y4 = 610 # Done button on my Fuze 608
		X4 = 135 # Done button on my Fuze 134
		Y5 = 460 # Done button on my Fuze 460
		X5 = 125 # Done button on my Fuze 125
	ElseIf(ScreenHeight() eq 800)
		Y1 = 150 # 1st button which is Auto on HD2 150
		Y2 = 200 # 2nd button which is GSM on HD2 200
		Y3 = 305 # 3rd button which is WCDMA on HD2 305
		Y4 = 750 # Done button on HD2 750
		X4 = 110 # Done button on HD2 110
		Y5 = 480 # Done button on HD2 480
		X5 = 110 # Done button on HD2 110
	EndIf
	While(NOT WndActive("Band"))
		Sleep(50)
	EndWhile
	If(key eq 1)
		MouseClick("Band", ScreenWidth()*0.25, Y1) # 1st button 
	ElseIf(key eq 2)
		MouseClick("Band", ScreenWidth()*0.25, Y2) # 2nd button 
	Else
		MouseClick("Band", ScreenWidth()*0.25, Y3) # 3rd button 
	EndIf
	Sleep(150)
		SendSpecial(112) # Done

	Sleep(500)
	i=0
	ForEach xvariable in regSubkeys("HKLM", "Comm\ConnMgr\Providers\{7C4B7A38-5FF7-4bc1-80F6-5DA7870BB1AA}\Connections")
		i+=1
		RegWriteDWord("HKLM", "Comm\ConnMgr\Providers\{7C4B7A38-5FF7-4bc1-80F6-5DA7870BB1AA}\Connections" \ xvariable, "Enabled", enable[i])
	EndForEach

	Sleep(20000)
	If(NOT Connected())
		Connect("The Internet")
	EndIf

EndSub
If you do not have a 480 x 640 or 480 x 800 phone or if this does not work for you please try this script to get me the points I need to improve this script.
Code:
# PickPoints.mscr

Run("\Windows\CMBandSwitching.exe")
WaitForActive("Band", 10)
Sleep(300)

SleepMessage( 2, "Select center of first (top) Network Type choice after this screen closes." )
Sleep(300)
aMouse = ScreenshotClick()
sMSGOutput1 = "^NL^First:^NL^X1 = " & aMouse[1] &"^NL^Y1 = " & aMouse[2]

SleepMessage( 2, "Select center of second (middle) Network Type choice after this screen closes." )
Sleep(300)
aMouse = ScreenshotClick()
sMSGOutput2 = "^NL^Second:^NL^X2 = " & aMouse[1] &"^NL^Y2 = " & aMouse[2]

SleepMessage( 2, "Select center of third (bottom) Network Type choice after this screen closes." )
Sleep(300)
aMouse = ScreenshotClick()
sMSGOutput3 = "^NL^Third:^NL^X3 = " & aMouse[1] &"^NL^Y3 = " & aMouse[2]

Sleep(300)
MouseClick("Band", aMouse[1], aMouse[2])
Sleep(300)

SleepMessage( 2, "Select center of Done button after this screen closes." )
Sleep(300)
aMouse = ScreenshotClick()
sMSGOutput4 = "^NL^Done:^NL^X4 = " & aMouse[1] &"^NL^Y4 = " & aMouse[2]

Sleep(300)
MouseClick("Band", aMouse[1], aMouse[2])
Sleep(1500)

SleepMessage( 2, "Select center of OK button after this screen closes." )
Sleep(300)
aMouse = ScreenshotClick()
sMSGOutput5 = "^NL^OK:^NL^X5 = " & aMouse[1] &"^NL^Y5 = " & aMouse[2]

SleepMessage( 2, "Select center of Cancel button after this screen closes." )
Sleep(3000)

WriteFile("\band_click.txt", "Screen width: " & ScreenWidth() & "^NL^Screen height: " & ScreenHeight() & sMSGOutput1 & sMSGOutput2 & sMSGOutput3 & sMSGOutput4 & sMSGOutput5)
Message("Please send me these data. They are saved in root directory \band_click.txt^NL^")
Remove the .txt from the end of the script files.
Attached Files
File Type: txt Band_Toggle.mscr.txt - [Click for QR Code] (349 Bytes, 35 views)
File Type: txt PickPoints.mscr.txt - [Click for QR Code] (1.6 KB, 13 views)
File Type: txt Band_Changer.mscr.txt - [Click for QR Code] (2.8 KB, 32 views)
AT&T Samsung Galaxy S III
Read About Me to see what I am working on & following like CHTS, Reminder and AppTask widgets, and CHT basic function tweaks. Also, Fixed CHT restarting when you have no tasks.
Mortscript | iniEditor | regEditor| MortScripts to toggle settings
Samsung Infuse 4G drowned. If you have one check out Scott's CM10 or CM10PA Firmware
ATT Fuze (HTC RAPH110) with Energy ROM: Energy.RAPHAEL.29022.Sense2.5.Cookie.2.0.Jul.06
HTC Wizard|See about me for my ROM collection and other work
The Following User Says Thank You to RoryB For This Useful Post: [ Click to Expand ]
 
RoryB
Old
#3  
RoryB's Avatar
Recognized Developer - OP
Thanks Meter 652
Posts: 2,716
Join Date: Sep 2008
Location: Lexington

 
DONATE TO ME
Default Switch Sound Profile

These scripts call the main script with the argument for the profile you want.

Code:
# Sound_Automatic.mscr
CallScript("\Windows\Sound_Profile.mscr", "Automatic")
Code:
# Sound_Normal.mscr
CallScript("\Windows\Sound_Profile.mscr", "Normal")
Code:
# Sound_Silent.mscr
CallScript("\Windows\Sound_Profile.mscr", "Silent")
Code:
# Sound_Vibrate.mscr
CallScript("\Windows\Sound_Profile.mscr", "Vibrate")
This is the main script:

Code:
# Sound_Profile.mscr

# Change Sound Profile based on argument used to call this script from
# a short script in the form:
# CallScript("\Windows\Sound_Profile.mscr", "Automatic")

mode=argv[1]

If(mode EQ "Automatic")
 RegWriteString("HKCU", "ControlPanel\Profiles", "ActiveProfile", "Automatic")
 SendMessage("", 1156, 0, 0)
ElseIf(mode EQ "Normal")
 RegWriteString("HKCU", "ControlPanel\Profiles", "ActiveProfile", "Normal")
 SendMessage("", 1156, 0, 0)
ElseIf(mode EQ "Silent")
 SendMessage("", 1156, 3, 0)
ElseIf(mode EQ "Vibrate")
 SendMessage("", 1156, 2, 0)
Else
EndIf
In CHTS profile switching I use the Execute/Kill App(s) section with the executable as \windows\mortscript.exe and the argument one of these four:
\Windows\Sound_Profile.mscr Automatic
\Windows\Sound_Profile.mscr Normal
\Windows\Sound_Profile.mscr Silent
\Windows\Sound_Profile.mscr Vibrate

Remove the .txt from the end of the script files.
Attached Files
File Type: txt Sound_Automatic.mscr.txt - [Click for QR Code] (56 Bytes, 15 views)
File Type: txt Sound_Normal.mscr.txt - [Click for QR Code] (53 Bytes, 11 views)
File Type: txt Sound_Silent.mscr.txt - [Click for QR Code] (53 Bytes, 8 views)
File Type: txt Sound_Vibrate.mscr.txt - [Click for QR Code] (54 Bytes, 14 views)
File Type: txt Sound_Profile.mscr.txt - [Click for QR Code] (598 Bytes, 20 views)
AT&T Samsung Galaxy S III
Read About Me to see what I am working on & following like CHTS, Reminder and AppTask widgets, and CHT basic function tweaks. Also, Fixed CHT restarting when you have no tasks.
Mortscript | iniEditor | regEditor| MortScripts to toggle settings
Samsung Infuse 4G drowned. If you have one check out Scott's CM10 or CM10PA Firmware
ATT Fuze (HTC RAPH110) with Energy ROM: Energy.RAPHAEL.29022.Sense2.5.Cookie.2.0.Jul.06
HTC Wizard|See about me for my ROM collection and other work
 
Farmer Ted
Old
#4  
Senior Member
Thanks Meter 88
Posts: 2,372
Join Date: Nov 2008
This isn't written as a toggle, but these scripts will turn off or on the auto-time zone sync option in phone settings. Turning it off helps to keep active sync from running all the time.

Code:
#Auto time zone off
RegWriteDWord("HKLM","\Drivers\BuiltIn\RIL","NITZEnable",0)
Code:
#Auto time zone on
RegWriteDWord("HKLM","\Drivers\BuiltIn\RIL","NITZEnable",1)
ROM: Retro ROM
Radio: 1.17.25.09
 
RoryB
Old
(Last edited by RoryB; 27th June 2011 at 06:51 PM.)
#5  
RoryB's Avatar
Recognized Developer - OP
Thanks Meter 652
Posts: 2,716
Join Date: Sep 2008
Location: Lexington

 
DONATE TO ME
Default Auto time zone toggle

Thanks Farmer Ted

It is easy enough to create a toggle.

Code:
If(RegRead("HKLM","\Drivers\BuiltIn\RIL","NITZEnable"))
   RegWriteDWord("HKLM","\Drivers\BuiltIn\RIL","NITZEnable",0) #Auto time zone off
Else
   RegWriteDWord("HKLM","\Drivers\BuiltIn\RIL","NITZEnable",1) #Auto time zone on
EndIf
AT&T Samsung Galaxy S III
Read About Me to see what I am working on & following like CHTS, Reminder and AppTask widgets, and CHT basic function tweaks. Also, Fixed CHT restarting when you have no tasks.
Mortscript | iniEditor | regEditor| MortScripts to toggle settings
Samsung Infuse 4G drowned. If you have one check out Scott's CM10 or CM10PA Firmware
ATT Fuze (HTC RAPH110) with Energy ROM: Energy.RAPHAEL.29022.Sense2.5.Cookie.2.0.Jul.06
HTC Wizard|See about me for my ROM collection and other work
The Following User Says Thank You to RoryB For This Useful Post: [ Click to Expand ]
 
lesscro
Old
#6  
lesscro's Avatar
Senior Member
Thanks Meter 1674
Posts: 3,175
Join Date: Jul 2007
Location: paris

 
DONATE TO ME
Thx RoryB... toggle features are good... if you can store all here.. it must be a good base to share with communauty !

  • Need Host a Picture for free with Solid link ? Try my IMGhost
  • Need info on GPS software ? iGO is the Best, check here
  • Need a Professional Service for small amount ? Go to my Website
 
MichelDiamond
Old
#7  
MichelDiamond's Avatar
Recognized Developer
Thanks Meter 272
Posts: 2,222
Join Date: Jul 2009

 
DONATE TO ME
great job my friend! especially after the long test time in beta group to fulfill different device's needs.
this is the perfect extension for the post-run-scripts while profile switching.

I'm looking forward to much more of this scripts, which can be used.

Thanx also in name of all CHTS-users
Micha



Sense Apps: by me: CHTS,CHTSLoco | partly by me: CHTEditor | system parts by me: CHT

Other Apps: Blue Prodigy | TICS | MichasRefresh | TitaniumStarter | TitaniumRSS


 
Farmer Ted
Old
#8  
Senior Member
Thanks Meter 88
Posts: 2,372
Join Date: Nov 2008
Quote:
Originally Posted by RoryB View Post
Thanks Farmer Ted

It is easy enough to create a toggle.
Cool, that was a lot simpler than if I'd done it, lol. Here's the same script, with message boxes to let you know what the setting is.

Code:
If(RegRead("HKLM","\Drivers\BuiltIn\RIL","NITZEnable"))
   RegWriteDWord("HKLM","\Drivers\BuiltIn\RIL","NITZEnable",0) #Auto time zone off
Message("Active Sync under control")
Else
   RegWriteDWord("HKLM","\Drivers\BuiltIn\RIL","NITZEnable",1) #Auto time zone on
Message("Active Sync running wild")
EndIf
ROM: Retro ROM
Radio: 1.17.25.09
 
RoryB
Old
#9  
RoryB's Avatar
Recognized Developer - OP
Thanks Meter 652
Posts: 2,716
Join Date: Sep 2008
Location: Lexington

 
DONATE TO ME
LOL I love a sense of humor.
AT&T Samsung Galaxy S III
Read About Me to see what I am working on & following like CHTS, Reminder and AppTask widgets, and CHT basic function tweaks. Also, Fixed CHT restarting when you have no tasks.
Mortscript | iniEditor | regEditor| MortScripts to toggle settings
Samsung Infuse 4G drowned. If you have one check out Scott's CM10 or CM10PA Firmware
ATT Fuze (HTC RAPH110) with Energy ROM: Energy.RAPHAEL.29022.Sense2.5.Cookie.2.0.Jul.06
HTC Wizard|See about me for my ROM collection and other work
 
RoryB
Old
#10  
RoryB's Avatar
Recognized Developer - OP
Thanks Meter 652
Posts: 2,716
Join Date: Sep 2008
Location: Lexington

 
DONATE TO ME
I updated post #2 for the Band Changer because I have been getting failed to connect or dialed modem not answering error messages.
AT&T Samsung Galaxy S III
Read About Me to see what I am working on & following like CHTS, Reminder and AppTask widgets, and CHT basic function tweaks. Also, Fixed CHT restarting when you have no tasks.
Mortscript | iniEditor | regEditor| MortScripts to toggle settings
Samsung Infuse 4G drowned. If you have one check out Scott's CM10 or CM10PA Firmware
ATT Fuze (HTC RAPH110) with Energy ROM: Energy.RAPHAEL.29022.Sense2.5.Cookie.2.0.Jul.06
HTC Wizard|See about me for my ROM collection and other work

Tags
cht, chtloco, chts, mortscript
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


XDA PORTAL POSTS

Polish Your Custom Themes with Theme Debugger

Creating a custom Android theme from scratch can be quite the laborious task. In addition to … more

Clean Up Your Logcat Code with Lib Cleaner

Some of you may think that writing code is the hardest part of development. It’s not, as the … more

Tweak Your Xperia Device’s Camera App Yourself

We’ve come to expect nearly perfect cameraperformancein our modern day … more