July 23, 2011

zakirenish zakirenish
Lab Rat
8 posts

[SOLVED] How to check if computer is not used for some time.

 

The process is running all the time on a background and when computer is not used for certain amount of time it needs to do some.
First i thought to check mouse position if changed from the last time. But it records the position only if the widget is shown. I don`t want to show widget.
Now i think maybe there is a way to check screen saver state…
Any ideas?
Thank you!

8 replies

July 23, 2011

Eddy Eddy
Area 51 Engineer
1296 posts

Afaik this cannot be done by Qt directly. You will need to go in the OS API.

On windows you can use GetSystemTimes [msdn.microsoft.com]

 Signature 

Qt Certified Specialist
Qt Ambassador

July 25, 2011

zakirenish zakirenish
Lab Rat
8 posts

Hey thanks. But i am new to programming. Can you please explain how to use it.
I include <winbase.h> and <windows.h> but then how you get the state out of it?
Thank you!

July 25, 2011

Eddy Eddy
Area 51 Engineer
1296 posts

It has been some time since I used it with VB.

What have you tried so far?

I’ll have a look if I can dig up something.

You’ll have to use WINAPI. maybe you’ll get a faster solutiuon on a windows c++ forum.

 Signature 

Qt Certified Specialist
Qt Ambassador

July 25, 2011

koahnig koahnig
Mad Scientist
2106 posts

You could possibly use QThread [doc.qt.nokia.com] there is at least a possibility to set the priority appropriately.
Priority [doc.qt.nokia.com]
I have never changed the priorities so far. Therefore, I do not know if it helps at all.
Furthermore, this may not be some beginner’s stuff :-(

July 26, 2011

Eddy Eddy
Area 51 Engineer
1296 posts

Here is example code [eggheadcafe.com] on how to use getsystemtimes.

 Signature 

Qt Certified Specialist
Qt Ambassador

July 28, 2011

zakirenish zakirenish
Lab Rat
8 posts

Thank you so much guys!

July 28, 2011

Eddy Eddy
Area 51 Engineer
1296 posts

Does this mean your topic is solved? In that case could you add [Solved] in front of your title by editing your first post.

If you can share it with us, we would appreciate to know how you solved it.

 Signature 

Qt Certified Specialist
Qt Ambassador

August 3, 2011

zakirenish zakirenish
Lab Rat
8 posts

Yes i did this on Win api level by calling the Function: SystemParametersInfoA() with parameter SPI_GETSCREENSAVERRUNNING to check if the screen Saver went on!

 
  ‹‹ silly newb question, regarding text inputs and the return key      [Solved] Making filter in QTableWidget ››

You must log in to post a reply. Not a member yet? Register here!