kill and start processus when screen off - Windows Mobile Development and Hacking General

Hi,
Already , sorry for my english
I would like to make a script which kills a process when the screen is off and start process when screen is on , If possible with mortscript.
With windows mobile 6.5
I looked everywhere, I did not find
Thx very very very much
Yannis

Try this:
ProcessToKill="XYZ.exe"
While(ProcExists("device.exe"))
If(0=RegRead("HKLM","System\CurrentControlSet\Control\Power\State\BackLightOff","bkl1:"))
#
#backlight is off
If(ProcExists(ProcessToKill))
Kill(ProcessToKill)
EndIf
Else
#
#backlight is on
If(NOT ProcExists(ProcessToKill))
Run(ProcessToKill)
EndIf
EndIf
#
#yield
Sleep 1000
EndWhile

Try this:
ProcessToKill="XYZ.exe"
While(ProcExists("device.exe"))
If(0=RegRead("HKLM","System\CurrentControlSet\Control\Power\State\BackLightOff","bkl1:"))
#
#backlight is off
If(ProcExists(ProcessToKill))
Kill(ProcessToKill)
EndIf
Else
#
#backlight is on
If(NOT ProcExists(ProcessToKill))
Run(ProcessToKill)
EndIf
EndIf
#
#yield
Sleep 1000
EndWhile

Related

QiD: ActiveSync Toggle, and Bluetooth + profile Toggle

Quick and dirty;
i hated starting ActSync, -> tools -> Options -> Options -> uncheck 'When craddled' Eneble PC sync '...'
Everytime i had to change is, or Tomtom would not work, and i would see a Qtec trying to sync with my car !
So i made a quick, and not so dirty mortscript/mortrunner batch :
This is for the MDA 2/XDA2/Qtec 2020
Cut here
---8<-------------------------------------------------
Code:
Errorlevel Syntax
If regKeyEqualsDWord HKCU, ControlPanel\Comm, AutoCnct, 5
if question AutoActiveSync is On. Switch Off ?, ActiveSync when cradled
RegWriteDWord HKCU, ControlPanel\Comm, AutoCnct, 0
Else
Exit
Endif
Else
if question AutoActiveSync is Off. Switch On ?, ActiveSync when cradled
RegWriteDWord HKCU, ControlPanel\Comm, AutoCnct, 1
Else
Exit
Endif
---8<-------------------------------------------------
Save as toggleASync.mortrun or toggleASync.mscr and sitck it somewhere on the qtec and create a shortcut to it, install Mortrunner/Mortscript and assign a HW button to the shortcut, or add it to a Today launcher
Did the same for switching BT + profile on off..
Please test, since it don't work on my Qtec, i have BTTools installed
---8<-------------------------------------------------
Code:
Errorlevel Syntax
If regKeyExists HKCU, Software\PBT, PreferredAudioDevice
Message "BTTools is installed, Use it's TodayPlugin instead!", ToggleBT
Exit
Endif
If regKeyEqualsDWord HKCU, Software\Microsoft\Bluetooth\Settings, ScanMode, 1
if question Bluetooth is On. Switch Off ?, ToggleBT
RegWriteDWord HKCU, Software\Microsoft\Bluetooth\Settings, ScanMode, 0
RegWriteDWord HKCU, Software\HTC\BTProfile, On, 0
Else
Exit
Endif
Else
if question Bluetooth is Off. Switch On ?, ToggleBT
RegWriteDWord HKCU, Software\Microsoft\Bluetooth\Settings, ScanMode, 5
RegWriteDWord HKCU, Software\HTC\BTProfile, On, 1
Else
Exit
Endif
exit
---8<-------------------------------------------------
Save as ToggleBT.mscr or .mortrunner etc....

Turning BT off/on w/ mortscript

I am trying to create a script that checks the BT state and then turn on/keeps on the BT then start a program (landscaper-->google maps) and then when the program terminates it returns the BT state that it was before starting the script...
the programs are
Program Files\BlindLemon\BTToggle.exe
Program Files\Landscaper.exe or \Windows\Start Menu\Programs\Landscaper.exe
Program Files\Googlemaps\googlemaps.exe
I have part of the script but I need the BT part. Here is what I have
Rotate(90)
Run( "\Window\Start Menu\Programs\Landscaper.exe" )
WaitForActive( "Landscaper", 05 )
SendDown ( "Landscaper" )
Runwait( "\Program Files\GoogleMaps\GoogleMaps.exe" )
Close( "Landscaper" )
Rotate(0)
And This portion Works fine.. just looking for the BT component
If anyone has experience with this or has a similar script let me know
Thanks..
__________________
You couldn't fool your mother on the foolingest day of your life even if you had an electrified fooling machine!
I saw him once. Sure I'm blind in one eye, and my other eye was infected that day from picking at it, and I was tired, and I'd been swimming in a pool with too much chlorine, and that was the hour my glasses were at Lenscrafters but I seen that fish!
bluetooth toggle
i just found this little app that toggles BT state when called. i mapped it to an icon in my program launcher/today screen to toggle BT on and off with the push of a button. I believe I found it on the forums here, but can't remember - it was late. Hope this helps.
Thanks, but I already have a BT Toggler app, (BlindLemon\BTToggle.exe) What I need to know is how to read the BT status, and then either turn the BT on or execute the program.
I need to know how to have Mortscript read the BT status also I cannot figure out the if/then part
Figured It out...
This script is for
1. Check the BT state and turn on if off (using a simple BT toggler program located HERE....and turn off when program is exited
2. Rotating the screen to 90º (So Keyboard will be Functional)
3. Keeping the screen rotated at 90º even if switched to portrait (this is achived with the program called Landscaper)
4. Running Google Maps
5. Returning everything (BT Status/Rotation) to state prior to executing the script
Of course you can change any of the programs to suite your needs..
Here is the Script I used
B = RegRead ("HKLM", "Software\oem\bluetooth\" , "BTcomstatus" )
If ( B = 0 )
Run( "\Program Files\BlindLemon\BTToggle.exe" )
Rotate(90)
Run( "\windows\Start Menu\programs\Landscaper.exe" )
WaitForActive( "Landscaper", 05 )
SendDown ( "Landscaper" )
Runwait( "\Program Files\GoogleMaps\GoogleMaps.exe" )
Close( "Landscaper" )
Run( "\Program Files\BlindLemon\BTToggle.exe" )
Rotate(0)
Else
If ( B = 1 )
Rotate(90)
Run( "\windows\Start Menu\programs\Landscaper.exe" )
WaitForActive( "Landscaper", 05 )
SendDown ( "Landscaper" )
Runwait( "\Program Files\GoogleMaps\GoogleMaps.exe" )
Close( "Landscaper" )
Rotate(0)
Here is the BT monitoring part
0 is BT off
1 is BT on
B = RegRead ("HKLM", "Software\oem\bluetooth\" , "BTcomstatus" )
If ( B = 0 )
run( "Prorgam path for BT toggler such as BlindLemon's BTTolgger" )
runwait( "Insert your program path here" )
run( "Prorgam path for BT toggler such as BlindLemon's BTTolgger" )
Else
If ( B = 1 )
run( "Insert your program path here" )

Roaming Comes Back On After Reset

I'm near the border lately and my phone keeps going into roaming on a different carrier. I turned off roaming but it keeps going back to automatic after a reset. Is it possible to permanently disable roaming?
I played around with QPST to try to disable roaming with no luck. Finally I wrote a VERY rough MortScript that will do it.
Anyone else notice with Mortscript that WaitForActive seems to do nothing? Maybe I'm using it wrong.
Anyway, here's my script. I have it a shortcut to it in my Startup folder.
Code:
ShowWaitCursor
sleep( 30000 )
Run( "cprog.exe" )
WaitForActive( Phone, 90 )
sleep(2000)
SendRightSoft()
sleep(100)
SendUp()
sleep(100)
SendUp()
sleep(100)
SendUp()
sleep(100)
SendCR()
sleep(2000)
SendUp()
sleep(100)
SendUp()
sleep(100)
SendRight()
sleep(100)
SendDown()
sleep(100)
SendDown()
sleep(100)
SendDown()
sleep(100)
SendTab()
sleep(100)
SendTab()
sleep(100)
SendCR()
sleep(500)
SendUp()
sleep(100)
SendCR()
sleep(100)
SendOK()
sleep(1000)
SendOK()
WaitForActive( Phone, 90 )
sleep(5000)
Minimize( Phone )
HideWaitCursor
The huge sleep at the beginning is to wait for the phone to completely boot up since it does wonky things if I leave that out.
If anyone has a more elegant way of doing this, please let me know! This is a horrible hack job and I know it

MortScript with Tzone Hack

I've been searching throughout the forum and haven't found any post teaching me how to use the t-zone hack with mortscript. After using trial and error I believe i have figured out a way to use the Tzone hack with most of the Mortscripts.
Within the script itself, if you paste Connect("The Internet") then
Connect("T-mobile US") in the section before the script starts grabbing data it should now work with the tzone hack. Certain script already uses the Connect("The Internet"), therefore all you have to do is paste Connect("T-mobile US) under it
Since I use joemanb tzone 5.99 cab within his post here http://forum.xda-developers.com/showthread.php?t=395203, he names the proxy setting "T-mobile US" therefore it is what i put in the connection command. If you did the hack manually replace "T-mobile US" with the name you provided when you first set up the hack. This name can be found through Setting->Connections-->Connections-->General(Tab).
Here is a sample in which i successfully changed chriscsh minicolour theme weather script to work with T-zone Hack. I've only started to learn Mortscript for about 2 days, and I've been aiming to make the weather script below to end its connection after grabbing the weather data but EndConnection or Disconnection isnt working, I hope someone can help me with this! I hope someone finds this useful!
local=RegRead("HKCU", "\Software\Manila\Weather\", "Locationcode")
If(local eq "")
CallScript("locationinput.mscr")
EndIf
# your location (see http://developer.yahoo.com/weather/ on finding your location)
location= RegRead("HKCU", "\Software\Manila\Weather\", "Locationcode")
# desired units for temp, f or c
units=RegRead("HKCU", "\Software\Manila\Weather\", "Units")
weather = ""
Connect("The Internet")
Connect("T-mobile US")
Connect=InternetConnected("http://www.goolge.com")
If (Connect=TRUE)
raw = ReadFile("http://weather.yahooapis.com/forecastrss?p="&location&"&u="&units)
Sleep(1000)
SleepMessage (2, "DATA READING....", "WEATHER UPDATE", 0)
cond = ""
code = ""
ccond = ""
ccode = ""
temp = ""
lotemp = ""
hitemp = ""
day = ""
location=""
ForEach line in split(raw,"^LF^",1)
If(Find(line,"<yweather:location"))
CallFunction("getValue", location, line,"location city")
EndIf
#<yweather:condition text="Mostly Cloudy" code="28" temp="39" date="Fri, 21 Dec 2007 7:53 am PST" />
if (Find(line,"<yweather:condition"))
CallFunction("getValue", ccond, line, "text")
CallFunction("getValue", ccode, line, "code")
CallFunction("getValue", temp, line, "temp")
EndIf
#<yweather:forecast day="Fri" date="21 Dec 2007"low="34" high="55" text="Mostly Sunny" code="34" />
if (Find(line,"<yweather:forecast"))
CallFunction("getValue", cond, line, "text")
CallFunction("getValue", hitemp, line, "high")
CallFunction("getValue", lotemp, line, "low")
CallFunction("getValue", day, line, "day")
EndIf
EndForEach
weather="W|"&ccode&"|"&hitemp&"|"&lotemp&""
Tweather= day&" H: "&hitemp&" L: "&lotemp&" "&cond
RegWriteString("HKCU", "\Software\A_C\S2U2\", "UserWeather", weather)
RegWriteString("HKCU", "\Software\Manila\Weather\", "CurrentCond", ccond)
RegWriteString("HKCU", "\Software\Manila\Weather\", "Temp", temp)
RegWriteString("HKCU", "\Software\Manila\Weather\", "Status", ccode)
RegWriteString("HKCU", "\Software\Manila\Weather\", "Location", location)
RegWriteString("HKCU", "\Software\Manila\Weather\", "TCond", Tweather)
SleepMessage (2, "DONE", "WEATHER UPDATE", 0)
Else
Message ("NO CONNECTION", "WEATHER UPDATE")
EndIf
# subroutine to pull value out of XML
Sub getValue
offset = Find(argv[1],argv[2]) + Length(argv[2])+2
endoff = find(argv[1], """", offset)
return(SubStr(argv[1], offset, endoff-offset))
EndSub
Click to expand...
Click to collapse
I did a similar mortscript on my device where it would connect if there was no connection and then disconnect. The only way I was able to accomplish the disconnect was to use VJVolubilis with a -gprstoggle switch from the ViJay555 site.
http://www.vijay555.com/?Releases:VJVolubilis

[MORT] GAlarm bug fix

Some users, including myself are having a problem with GAlarm turning our devices on at midnight but they don't reenter standby thereafter. GAlarm offers a registry setting change to avoid this (MidnightWakeUp: False), but it could interfere with alarms being properly scheduled and cause them not to go off. Since I rely on GAlarm heavily, that wasn't a solution I could try.
The following script needs to be manually executed once. That places a notification in place to run the script automatically at 12:05am, will reschedule itself for the next day automatically, and then turn off your device.
prscott, RoryB, and CLHatch are the bomb for generously fixing my screwups and providing various code.
Code:
# Turn off your device at 12:05am every morning to counteract a gAlarm bug where device turns on at midnightand refuses to reenter standby.
# Thanks to prscott from xda devs for scheduling script example: http://forum.xda-developers.com/showthread.php?p=1925725#post1925725
# Additional thanks to RoryB and CLHatch for helping me with mortscript time: http://forum.xda-developers.com/showpost.php?p=7414028&postcount=3494
# getting time, date and weekday information
GetTime(hour,min,sec,day,month,year)
date = TimeStamp()
year = (FormatTime("Y"))
nextyear = (FormatTime("Y") + 1)
month = (FormatTime("m"))
nextmonth = (FormatTime("m") + 1)
day = (FormatTime("d"))
weekday = (FormatTime( "w" ))
hour = (FormatTime("H"))
nexthour = (hour + 1)
tomorrow = FormatTime("d", TimeStamp()+86400)
nextday = (FormatTime( "d" ) + 1)
# kill old notification(s) to prevent overlap
RemoveNotifications( "\Storage Card\gamidnightfix.mscr" )
# If on phone - wait 5 minutes to start again
CallActive = RegRead( "HKLM", "System\State\Phone", "Active Call Count" )
If (CallActive > 0)
RunAt( ( TimeStamp() + 60*5 ), "\Storage Card\gamidnightfix.mscr" )
Call ExitNow
EndIf
# add tomorrow's 12:05 am notification and poweroff
# set new notify
If (tomorrow = 01)
If (month = 12)
RunAt( nextyear, 01, 01, 00, 05, "\Storage Card\gamidnightfix.mscr")
Else
RunAt( year, nextmonth, 01, 00, 05, "\Storage Card\gamidnightfix.mscr")
EndIf
Else
RunAt( year, month, nextday, 00, 05, "\Storage Card\gamidnightfix.mscr")
EndIf
# go into standby
poweroff
# exit routine
exit

Categories

Resources