yashsingh1/xdaforums huggingface dataset:
[Windows Mobile Apps and Games] Tribal123:
I have the app enabled with "Lock on Screen Off", but when the screen illumination turns off nothing happens:confused:

It only locks when the device completely turns off (after 1 minute)

Any suggestion?
[Windows Mobile Apps and Games] Bib_x:
Lock on Screen off is this what you wrote. Some applications (maybe audioplayers) shut off the display, but audio still plays. So the device is locked in this case. Otherwise, with option "lock on device wake up" your device won´t be locked, if you listen to music and the screen goes off.
[Windows Mobile Apps and Games] sc00basteve:
thanks. this is working great.

this explains some of the issues ive had with the phone heating up and eating battery when i choose -enable on screen off-

prob is a manila or tflo3d (something htc, like you said) that is not allowing a full suspend.

solved by simply using -enable on wakeup-
[Windows Mobile Apps and Games] Tribal123:
Ok.

But maybe i haven't understood how the WM 6.5 Lockscreen works:confused:

I thinked that the lock app starts when the LIGHT of the screen turns off.

It isn't?
[Windows Mobile Apps and Games] Bib_x:
There are two states of the display: dimming screen and screen completely off

1. While dimming screen, you still can see something on the display (very dark) - touchscreen still works. Only background lights shut off.

2. On screen off, the screen is shut off and you can´t see anything, the touchscreen won´t respond anymore. Background light and the whole screen is shut off.
[Windows Mobile Apps and Games] sc00basteve:
from how its been explained here, i believe it has to do withe the powerstates of the device. (ie. suspend, unattended, user idle, screen off, etc)

specifically the Suspend and Resuming power states. i had to reread post#1 a few times but I think I get the general idea now.

Hope this helps. did you try MSDN for descriptions. helped me like an MS dictionary for a while & still.
[Windows Mobile Apps and Games] Tribal123:
Ok, so i think that the WM 6.5 Lockscreen starts on "Screen off" only, not on "dimming screen" too....

It could be a good thing that it starts on dimming, because you could choose a smaller time (10 secs) to starts.

And it is the same condition that is used with others locks screen application (i.e. S2U2..) they starts when the screen dimmed off.
[Windows Mobile Apps and Games] bgcngm:
First of all, let me congratulate for your good work, danielherrero.

This is what I've been looking for. So far I've tried S2U2 (I think it uses too much memory) and AutoLockScreen v1.7E (from my experience it drains battery very fast). This seems very light and I will give it a try, for sure.

Regarding the player911 comments, I have one question... Is there any trick to use the stock standard app to auto lock the device without setting a PIN/Password? Only by setting the device to auto lock after XX seconds?
[Windows Mobile Apps and Games] adell_:
Does this app work on Miri WM 6.5?
[Windows Mobile Apps and Games] Tribal123:
It's in mine "wish-list" too....locking the device (with the standard lock app) after xx seconds without to wait the minimum 1 minute to shut off the device completely.
[Windows Mobile Apps and Games] bgcngm:
But can you auto lock your device after 1 minute (with the standard lock app)

without

setting a PIN/Password?
[Windows Mobile Apps and Games] Kasush:
Tribal: If you want the device to lock sooner than you have set the power off device in power options then click the power button and viola, screen is locked.

All: Daniel did NOT write a screen locking application. He wrote an application which monitors the power state of the device and tells Windows Mobile to run its internal lock screen routine. I for one applaud Daniel for this. I was trying to find a way to use the WM screen lock automatically and the guys at MS failed to use their brains yet again and only allow auto lock with a pin set. I did not like having to input a pin ever time I turned on my phone and this was the perfect solution.

I have been using the screen off option since day one to avoid the slight delay on wake up issue and I have noticed absolutely no battery use impact. I have a very high drain device and resident/background applications have often caused me serious drain issues.

Daniel thank you for this application.
[Windows Mobile Apps and Games] Tribal123:
I know it, i mean to lock the device before 1 minute (default minimum time adjustable by the WM power settings) AUTOMATICALLY WITHOUT PRESSING ANY BUTTON (like i.e S2U2)

If i want to use a button i have already a good solution provided by Daniel that in the last 1.04 release have released an .exe file to bind to ANY button you want, not only to the power button.

However a MUST-HAVE app!!!!:p
[Windows Mobile Apps and Games] vangrieg:
Jesus Christ!!!

I have tried all lockers on Earth, tried to make mine, and this is the first and only solution that works properly and does everything I need!!!

You're the man!
[Windows Mobile Apps and Games] danielherrero:
happy to know it. It solved too my problems with "unlock" system ;)

Dani
[Windows Mobile Apps and Games] skycamefalling:
This application is absolutely great but it's a shame that you have to do Microsoft's work. Still with Win6.5 they are unable to implement a "lock on wakeup" function into the System :rolleyes:

I flashed Win6.5 on my Rhodium yesterday and since then I'm using your application. The one thing I found is the "sometimes I have to unlock the screen again after unlocking it". This mostly occurs when the phone has been in standby for a long time. It's no big deal but I hope you can fix it sometimes. Would make a good program even better :)

Thanks for your work!
[Windows Mobile Apps and Games] benko286:
how can i get lcok on incoming call?

possible with this app?
[Windows Mobile Apps and Games] vangrieg:
Actually, I rushed to conclusions it seems, unfortunately, nothing is perfect including this application. :(

It doesn't lock device automatically when I listen to music using TF3D player (and that's the only case when I need automatic locking, as a matter of fact) when a wired headset is plugged in. I'm trying to use the screen off activation option.

I tested it first using A2DP, that's why it seemed to have worked.
[Windows Mobile Apps and Games] vangrieg:
Which registry key/value shows the state of the screen, if you don't mind sharing?
[Windows Mobile Apps and Games] danielherrero:
the program simple registers itself upon windows to get changes in the power state so it get a callback from windows when the state changes (there are 7 power levels currently). When the state is "unattended" then it locks the device. This power state implies backlight off but the program DOESNT monitor the backlight state but the system power state. Because of this when you use HTC player with screen off the program doesnt lock the device because the power state is ON (maximum level)but HTC Player just turn video off to save battery. To make this program work with htc player I should monitor video driver states and this this would spend battery and would depend of the video driver......:)

Dani
[Windows Mobile Apps and Games] milaq:
that's related to the buggy wm6.5 releases not to the locking tool itself

;)
[Windows Mobile Apps and Games] Bib_x:
Is there an exception list? I use g-alarm and when an alarm pops up, i have to unlock my device first, to end the alarm.

With s2u2 i can put g-alarm.exe to an exception list and if there an alarm pops up, the device won´t be locked.
[Windows Mobile Apps and Games] vangrieg:
Not necessarily. If the driver state is located in the registry somewhere the program can be launched using RegistryNotifyApp function on value change, and saving the current/new state someplace else, say, HKLM\System\State. By the way, you can do it for your second method to avoid having your program resident.
[Windows Mobile Apps and Games] qbus00:
I would not agree - LockDevice and SmartLock has that issue but on the other side CSDevCtrl work flawlessly...
[Windows Mobile Apps and Games] milaq:
that's because csdevctrl is resident and will not trigger via the internal "device has woken up" notification while lockdevice, smartlock, etc do.

so NO bug in lockdevice at all.

wm6.5 has still problems in standard situations - like notifications - and is a VERY buggy os.
[Windows Mobile Apps and Games] vangrieg:
Wait, but what about BackLightOff or UserIdle? unattended doesn't cover all situations when backlight goes off!
[Windows Mobile Apps and Games] vangrieg:
OK, I had to download and install Visual Studio, learn C#, read half the internet, and almost wrote my own locker, but finally figured out what happens when screen blanks during playback in Manila player.

I wrote a program that records current power state using GetSystemPowerState and it shows that device power mode is changed to "ScreenOff", not "Unattended" when screen blanks. That simple. So I guess it would be quite easy to modify your locker to adjust for this, right? I need to sleep sometimes, otherwise I would of course do it myself. :D
[Windows Mobile Apps and Games] oluwaponmile:
You are very clever :)
[Windows Mobile Apps and Games] danielherrero:
ok I will do a try..... ;)
[Windows Mobile Apps and Games] danielherrero:
I didnt find any "screen off" state...

#define POWER_STATE(f) ((f) & 0xFFFF0000) // power state mask
#define POWER_STATE_ON (DWORD)(0x00010000) // on state
#define POWER_STATE_OFF (DWORD)(0x00020000) // no power, full off
#define POWER_STATE_CRITICAL (DWORD)(0x00040000) // critical off
#define POWER_STATE_BOOT (DWORD)(0x00080000) // boot state
#define POWER_STATE_IDLE (DWORD)(0x00100000) // idle state
#define POWER_STATE_SUSPEND (DWORD)(0x00200000) // suspend state
#define POWER_STATE_UNATTENDED (DWORD)(0x00400000) // Unattended state.
#define POWER_STATE_RESET (DWORD)(0x00800000) // reset state
#define POWER_STATE_USERIDLE (DWORD)(0x01000000) // user idle state
#define POWER_STATE_PASSWORD (DWORD)(0x10000000) // This state is password protected.
[Windows Mobile Apps and Games] vangrieg:
I don't really know where you looked, so can't comment on that, but as far as I can see it's listed as POWER_STATE_IDLE (see explanation below).

Here's an official list of system power states that mentions ScreenOff. This state is intended primarily for players like WMP or Manila player which turn screen off by calling CoreDLL.dll (in other words, using the driver).

What needs to be done to catch this state, I think, is get notified by power manager that system state is changing (RequestPowerNotifications(MessageQueue, PBT_TRANSITION)) and then check what state device is in using GetSystemPowerState (see below).

Here goes the code I used to see which state is used instead of "Unattended" while Manila player is working and screen gets turned off (in C#, I haven't managed to learn C++ in the two days I've been learning programming, but I'm sure you'll easily convert this :D)

First some needed references, among others:

// I'm sure you're already using these, but just in case
using Microsoft.WindowsMobile;
using Microsoft.WindowsMobile.Status;
// This is to import external DLL functions
using System.Runtime.InteropServices;

Now some declarations:

[DllImport("coredll.dll", SetLastError = true)]
private static extern int GetSystemPowerState(string psState, UInt32 dwLength, out PowerState flags);
// This enum seems to be completely wrong (I found it somewhere and used as is), but it's ignored by the actual function, and is used here just to declare a new variable type. I guess
public enum PowerState
{
On = 0x00010000,
Off = 0x00020000,
Critical = 0x00040000,
Boot = 0x00080000,
Idle = 0x00100000,
Suspend = 0x00200000,
Reset = 0x00800000
}

Than some other code that's irrelevant to this discussion, and now we get down to the crux of the issue:

// Now I open registry "State" key as read-write to record the power state value:
RegistryKey powerStatusKey = Registry.LocalMachine.OpenSubKey(@"System\State", true);

// Variable to store power state as string
string strState = "";
//Creating an instance of that wrong enum. this pState will store power state in this 0x000000 format
PowerState pState = new PowerState();
// Variable to store function result error code
// "30" is length of the "buffer", strState in other words
// Calling the actual function (or "method" or whatever it is in this OOP gibberish lingo) from CoreDLL.dll
int psresult = GetSystemPowerState(strState, 30, out pState);
// Checking if everything is OK
if (psresult == 0)
{
// Writing power state to \HKLM\System\State\Powermode
powerStatusKey.SetValue("Powermode", pState, RegistryValueKind.DWord);
}

Executing this little program writes dword 0x00100000 in the registry (or string "screenoff" using strState instead of pState).

Hope this helps.

By the way, would you mind sharing how you call the standard lock mechanism? :)
[Windows Mobile Apps and Games] vangrieg:
No, I'm just desperate to get this very simple function working. :)
[Windows Mobile Apps and Games] danielherrero:
Well. idle state doesnt work when the device is suspended but WORKS when htc player or other player turns screen off. I am going to create a new version adding an option to lock when a player is working and the screen is off....because some people (me included) prefers not to lock the device in those cases to play, stop, rewind a song witout unlock the device.... :)
[Windows Mobile Apps and Games] danielherrero:
Ok, V1.5 uploaded in the first post. The gui includes a check box to lock or not lock when a player turns the screen off. Not too much time to test but I ve tested all the functions and works ok. Please report any problem, suggestion, etc, etc... :)

Dani
[Windows Mobile Apps and Games] benko286:
it is working :)
[Windows Mobile Apps and Games] vangrieg:
Thanks for the quick update!

Anyway, would you answer my question about how you call the standard lock mechanism? Or at least say that you won't answer it? :)
[Windows Mobile Apps and Games] vangrieg:
Oh my. It works, but crashes Audio Manager a couple of seconds after pressing the Power button... :(
[Windows Mobile Apps and Games] danielherrero:
Ops sorry, I didnt see your question. Of course I tell you :). I found it googling easily. Its two keybd calls, one for key down and other for key up. Now I am in a car but later I will wirte the code......
[Windows Mobile Apps and Games] danielherrero:
mmmm No problems here. what device and rom you have? any other with same problem?
[Windows Mobile Apps and Games] vangrieg:
It's Touch HD, my own ROM, so it won't say much to you.

It shoudln't be related to your program in any way if it works the way I think it works. :) Trying to locate the source of the issue.

The problem with googling is that it gives so many approaches it makes someone with two days of coding experience quite dizzy. :) Especially when this someone spends 60-70 hours a week at work where his only relation with computers should be Outlook and Powerpoint. ;)

In addition to that, your locker doesn't act quite like the standard one, it locks volume buttons. I wonder why...
[Windows Mobile Apps and Games] danielherrero:
As promised.....

keybd_event(VK_F22, 0, 0, 0);
keybd_event(VK_F22, 0, 0x02, 0);

Dani
[Windows Mobile Apps and Games] vangrieg:
Jesus! So simple.

In the meanwhile, my investigation showed that your program is not at fault with this Audio Manager crashing, it's rather my registry tweaking. Problem solved.
[Windows Mobile Apps and Games] Curb71:
thank you very much! finally something to replace LML. I still dont really see a big difference between the two run modes available and why I cant check both of them but it seems to do what I want it to do when I have it set to lock on screen off. As another guy on here said, it would be great to make an exceptions list so you can have certain programs such as G-Alarm override and unlock automatically. thanks again!
[Windows Mobile Apps and Games] danielherrero:
lock on screen off works always when the screen goes off but keeps resident althought is blocked (doesnt polling). Lock on wakeup isnt resident in memory but it works if you wait 3 or 4 seconds or more between power off and on....

Dani
[Windows Mobile Apps and Games] vangrieg:
danielherrero, sorry for a stupid and off-topic question, but I've spent a whole day googling and couldn't find an answer - how do you make a windowless application stay in memory without doing anything?
[Windows Mobile Apps and Games] danielherrero:
Its just a endless loop bloqued in a synchronous system call (readmsgqueue). Each time there is a change in the power mode this call returns with the new state. Something like this.

while(true) {
// This call is bloqued (so no cpu use) until there is a power change
fRet = ReadMsgQueue(h, buffer, 1000, &dwBytesRead, INFINITE, &dwFlags);
if (!fRet) {
fRet = GetLastError();
MessageBox(NULL, L"Error reading notifications queue...¡¡", NULL, NULL);
return;
}
if (dwBytesRead) {
// Process the power change...
// ----
}
}
[Windows Mobile Apps and Games] vangrieg:
Hmm, thanks a lot, but unfortunately notifications are handled differently in managed code, the whole notification routine is done by four lines of code (not counting the curly brackets, the code is watching for an incoming call, not power state change):

SystemState CallReceived = new SystemState(SystemProperty.PhoneIncomingCall);
CallReceived.Changed += new ChangeEventHandler(CallReceived_Changed);

void CallReceived_Changed(object sender, ChangeEventArgs args)
{
// Event processed
}

After this the application exits.

All examples I've seen are for cases when there's a window, and while a form is open the program runs, so there's no need for doing anything special. When there's no form I run into trouble. I can of course create a hidden form but that sounds a bit lame. If, on the other hand, I put the notification routine in an endless loop the program uses 100% CPU.
[Windows Mobile Apps and Games] danielherrero:
Hi

Ok, no problem. I develop in C# too. There are several ways. The callback is called using the caller thread so you could sleep your main thread for ever or similar.....

while (true) {

sleep(9999999);

}

In this way your program will be in pause mode and will be called (using the caller thread) when a power change occurs
[Windows Mobile Apps and Games] vangrieg:
Uhm, what, sorry? :) You have too high of an opinion about my programming skills. :)
[Windows Mobile Apps and Games] benko286:
any idea why is locking on incoming call slow??

firstly pop up message comes(left soft key answer, right ignore) than after 2-3sec normal lock comes(slide to unlock) and than after 2sec real slide to answer/ignore lock..

after call is ended i need to slide to unlock device again....

please help!!
[Windows Mobile Apps and Games] danielherrero:
Hi

I dont know if it is related with your issue. I ve discovered an issue happening in WM 6.5 (later builds). Instead of double unlock process the screen frezzes. It happens only in mode "lock in screen off". I am going to do some changes to prevent this.

Dani
[Windows Mobile Apps and Games] hecksk:
First of all I'd like to say it really lightweight app, and thanks. It works great.

But there is a some bad thing I don't like when I do a call it locks and I cannot press end call button.

I'm using HTC Touch Pro2, it has subsystem which turns off screen and I believe it makes untouchable. But LockDevice makes windows lock and it is hard to use. Can you fix this issue?

Does anyone have such problem with your devices?

I really like this application and I'd like to continue use it.

thanks again.
[Windows Mobile Apps and Games] vangrieg:
Both call buttons work for me during the call on Touch HD.
[Windows Mobile Apps and Games] danielherrero:
mmmmmm, strange. I can push both buttons...
[Windows Mobile Apps and Games] qbus00:
"Two times unlock" bug occures in my case only in resident mode of LockDevice.

The other one based on notification queue is working OK (but it's slow).
[Windows Mobile Apps and Games] bankai03:
Thank you for your application. Good work
[Windows Mobile Apps and Games] hecksk:
How can I use this non-resident mode?

I run UI and there are option:

Enbaled - checked;

Lock if playing music - checked;

Run Mode - Lock on Screen OFF.

one more detail, when phone call is short is does right way - won't lock.

I've just tried v1.5 with Run Mode - Lock on Wake UP and it work just I want it to work. :))

Please just let me know the purpose of Run Mode - Lock on Screen OFF?
[Windows Mobile Apps and Games] danielherrero:
hi

Lock on screen off will lock the screen when the screen is off. So when the device wakes up its already locked (faster) but requires to be resident. The other way isnt resident but locks the device when windows notifies about the device just woke up. It can happen a few miliseconds after wakeup or 2-3 seconds after. The program is notified after drivers so if some drivers does much works then the time is longer (1-3 seconds)

Dani
[Windows Mobile Apps and Games] hecksk:
Thanks danielherrero for making it clear for me.

But it means it suppose to be working anyway.

Well, it works non-resident mode and it's cool!! :) thanks
[Windows Mobile Apps and Games] hecksk:
well, the issue is up again. i cannot use on wakeUp mode because it performs dummy phone calls. ok, let's again back to the issue when you making a call by HTC phones featured by turn off screen, LockDevice locks a device therefore I cannot end call until unlock by pressing it twice (usual unlock).

Is it possible to fix this issue? Or it's a major developement work or something unreal?

thanks for any help, I hope it is easy... :)
[Windows Mobile Apps and Games] danielherrero:
Hi

Maybe its only my device (HTC Touch Pro) but when the phone rings, even locked, I can reject the call pressing the ends button (hardware button or screen button). Am I missing something? :confused:

Dani
[Windows Mobile Apps and Games] vangrieg:
Same here on Touch HD (buttons work even when device is locked), and this is something quote annoying if you ask me. :)
[Windows Mobile Apps and Games] danielherrero:
I guess Phone program knows about lock system and ignores it ;)
[Windows Mobile Apps and Games] vangrieg:
Well, that's exactly what is happening. So I'm trying to write a program that will lock Talk/End buttons during an incoming call.
[Windows Mobile Apps and Games] hecksk:
It seems like an option required:). In my case I have hardware real buttons and it actually works but screen locked and screen software buttons don't react by tap and any touches and most anoyance is that screen does not updates ...

this application is great, I like how it works and it is really lightweight but this ...

thanks
[Windows Mobile Apps and Games] chris10230:
When i was running this to lock on music it was causing stuttering in playback. I have it set to lock on screen off. When I lock it normally it doesn't stutter. Any ideas on this one?
[Windows Mobile Apps and Games] vangrieg:
Well, danielherrero will correct me if I'm wrong here, but such an option isn't as easy as it may seem. The only thing this program does is get notified about certain system events and then emulate the "Lock" virtual key press. Everything else (i.e. whether keys work or not etc.) depends on how locking is implemented in your device/ROM.

One way to work around this issue would be to lock device on screen on rather than off, try to figure out what just woke the device on, and act according to certain rules. Much more complicated and much less reliable, I'm afraid.

Unlocking device programmatically on an incoming call would be an option, but again much more difficult than locking.
[Windows Mobile Apps and Games] hecksk:
Well great. This is difficult, but this is really inconvenient thing (I mean locking while phone call).
[Windows Mobile Apps and Games] vangrieg:
Well, if you cannot pick up a call than it's certainly a problem.

The question is why it happens though.

On the other hand, if you don't lock your device during calls, when do you need locking?