New: XDA launches forum for app developers. Discuss coding, tools, marketing, and more.
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
Mort
Old
#1  
Senior Member - OP
Thanks Meter 67
Posts: 414
Join Date: Dec 2004
Location: near Stuttgart
Default MortScript examples accumulation

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
 
_TB_TB_
Old
#2  
_TB_TB_'s Avatar
Senior Member
Thanks Meter 73
Posts: 382
Join Date: Apr 2006
Location: Ruda Śląska
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
[ANDROID] Remap HC/ICS external keyboard: here
[WM] LEDUp, simple LED control program: here
[WM] FloatMe, a stupid but maybe useful 'tool': here
[WM] More HW buttons for i780: here
[WM] i780/Omnia unlocking: here
[WM] Program Finder: here
 
_TB_TB_
Old
(Last edited by _TB_TB_; 9th January 2007 at 02:33 PM.)
#3  
_TB_TB_'s Avatar
Senior Member
Thanks Meter 73
Posts: 382
Join Date: Apr 2006
Location: Ruda Śląska
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
[ANDROID] Remap HC/ICS external keyboard: here
[WM] LEDUp, simple LED control program: here
[WM] FloatMe, a stupid but maybe useful 'tool': here
[WM] More HW buttons for i780: here
[WM] i780/Omnia unlocking: here
[WM] Program Finder: here
 
GldRush98
Old
(Last edited by GldRush98; 9th November 2009 at 04:09 AM.) Reason: removed dead link, sorry
#4  
GldRush98's Avatar
Senior Member
Thanks Meter 115
Posts: 1,809
Join Date: Jun 2006
Location: Taylorville, IL.
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.
---Phone---
Galaxy Nexus (AT&T)
Android 4.2.2 JDQ39, Baseband I9250XXLJ1, Unlocked, rooted, Clockwork Touch 6.0.2.3
---Tablet---
Nexus 7
Android 4.2.2 JDQ39, 16gb, Unlocked, rooted, Clockwork Touch 6.0.2.3
---Past---
Samsung Galaxy Tab (AT&T)
Android 2.3.3, 16gb, Smartass CPU Governor
Google Nexus One (AT&T)
Android 2.3.6 GRK39F, 5.08 Radio, Unlocked, rooted, Amon_RA 2.2.1
AT&T Fuze (Touch Pro)
AT&T 8525 (Hermes)
AT&T 8125 (Wizard)
 
le_cactus
Old
#5  
Senior Member
Thanks Meter 16
Posts: 436
Join Date: Nov 2005
Location: Amsterdam
Default 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
 
le_cactus
Old
#6  
Senior Member
Thanks Meter 16
Posts: 436
Join Date: Nov 2005
Location: Amsterdam
Default 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
 
_TB_TB_
Old
#7  
_TB_TB_'s Avatar
Senior Member
Thanks Meter 73
Posts: 382
Join Date: Apr 2006
Location: Ruda Śląska
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.
[ANDROID] Remap HC/ICS external keyboard: here
[WM] LEDUp, simple LED control program: here
[WM] FloatMe, a stupid but maybe useful 'tool': here
[WM] More HW buttons for i780: here
[WM] i780/Omnia unlocking: here
[WM] Program Finder: here
 
oldsap
Old
#8  
oldsap's Avatar
Senior Member
Thanks Meter 8
Posts: 1,078
Join Date: Apr 2006
this is a very informative and useful thread.
i use mortscript on my T-Mobile SDA smartphone.

Alarm Script (reminder):
Attached Thumbnails
Click image for larger version

Name:	reminder.jpg
Views:	4096
Size:	8.2 KB
ID:	32941  
Attached Files
File Type: zip Alarm Script.zip - [Click for QR Code] (84.0 KB, 1101 views)
http://oldsap.blogspot.com

SpeakerPhone Auto ON - Automatically turn on your speakerphone
OS Profiler - Volume Profile Scheduler.
DontSleep Wifi - will automatically turn on your wifi while preventing your device from going into sleep mode.
OS Logger - Log your SMS on your Calendar
i780 Flashing Guide
CNitrogen - Titanium Plugin for Nitrogen Music Player
SMSer - send multiple sms to multiple contacts
 
oldsap
Old
#9  
oldsap's Avatar
Senior Member
Thanks Meter 8
Posts: 1,078
Join Date: Apr 2006
Default 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
http://oldsap.blogspot.com

SpeakerPhone Auto ON - Automatically turn on your speakerphone
OS Profiler - Volume Profile Scheduler.
DontSleep Wifi - will automatically turn on your wifi while preventing your device from going into sleep mode.
OS Logger - Log your SMS on your Calendar
i780 Flashing Guide
CNitrogen - Titanium Plugin for Nitrogen Music Player
SMSer - send multiple sms to multiple contacts
 
oldsap
Old
#10  
oldsap's Avatar
Senior Member
Thanks Meter 8
Posts: 1,078
Join Date: Apr 2006
Default 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
http://oldsap.blogspot.com

SpeakerPhone Auto ON - Automatically turn on your speakerphone
OS Profiler - Volume Profile Scheduler.
DontSleep Wifi - will automatically turn on your wifi while preventing your device from going into sleep mode.
OS Logger - Log your SMS on your Calendar
i780 Flashing Guide
CNitrogen - Titanium Plugin for Nitrogen Music Player
SMSer - send multiple sms to multiple contacts

Tags
mortscript, mortscript examples