×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

activate / deactivate screen server
2

activate / deactivate screen server

activate / deactivate screen server

(OP)
POssible to activate/deactivate screen saver, via commandbutton?
Tks.

RE: activate / deactivate screen server

If the screen saver is active, i.e. blank screen, how would you see the command button to deactivate it?

Experience is something you don't get until just after you need it.

RE: activate / deactivate screen server

(OP)
ERROR7, Im stupid!

My request is:

pseudo code

...
deactivate scree saver
...
do until rs.eof
...
rs.move.next
...
loop
reactivate normal screen saver
....

RE: activate / deactivate screen server

What do you do to your rs that you exceed the time limit of your screen saver?
My point is – if you do it more efficiently, you may not need to mess with the screen saver.

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson

RE: activate / deactivate screen server

Really the RS are approx 123.xxx
And i fill a TXT file with RS valute.

Note:
I have 2 account on forum, sal21 and 2009luca

RE: activate / deactivate screen server

That is not many records. Writing to a text file is pretty straight forward process.
That should not take so long to have a screen saver kick in.

Why are you exceeding the time limit of your screen saver?

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson

RE: activate / deactivate screen server

Will a simple Send Key command periodically prevent the screen saver from kicking in?

Experience is something you don't get until just after you need it.

RE: activate / deactivate screen server

Error7 - true, so is periodically moving a mouse just a little in code, but I am trying to figure out what takes so long for screen saver to kick in. I would rather speed up my process rather that mess with PC settings.
pc2

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson

RE: activate / deactivate screen server

Error7.
Nice suggestioni,
For example...?

RE: activate / deactivate screen server

This solution is based on Andrzejek idea:

Private Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_LEFTDOWN = &H2

Private Sub Form_Load()
Timer1.Interval = 50000
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
Call mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
End Sub

Experience is something you don't get until just after you need it.

RE: activate / deactivate screen server

(OP)
wat you think about my knowledge...

...
I = I + 1
If I Mod 1000 = 0 Then
Call mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
DoEvents
End If
...

RE: activate / deactivate screen server

"the RS are approx 123.xxx" records (?)
I would investigate why my process takes so long (how long anyway?) for so few records...

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson

RE: activate / deactivate screen server

I'd use Error7's approach - but I wouldn't use the MOUSEEVENTF_LEFTDOWN event. I'd incline towards using MOUSEEVENTF_MOVE (MOUSEEVENTF_MOVE = &H1) instead to invisibly wiggle the mouse.

>wat you think about my knowledge...
I wouldn't do it that way. A tight loop, with DoEvents? No. Use Error7's technique, which uses a timer.

>Will a simple Send Key command periodically prevent the screen saver from kicking in?

No. SendKeys (a horrible kludge, IMO) doesn't do enough to convince the screensaver that there has been activity

RE: activate / deactivate screen server

(OP)
ok. strongm
wath is your approch?

in other case found this:

CODE

Option Explicit
Private Const SPI_GETSCREENSAVEACTIVE = 16&
Private Const SPI_SETSCREENSAVEACTIVE = 17&
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
'Active = True  - To Activate
'Active = False - To Deactivate
'ScreenSaver False
'ScreenSaver True
Public Function ScreenSaver(Active As Boolean) As Boolean

    Dim A As Long
    Dim R As Long

    A = Abs(Active)    'Needs 1 or 0
    R = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, A, 0, 0)
    ScreenSaver = (R > 0)

End Function
Public Function IsScreenSaverActivated() As Boolean

    Dim A As Long
    Dim R As Long

    R = SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, A, 0)
    IsScreenSaverActivated = (A <> 0)

End Function 

RE: activate / deactivate screen server

>wath is your approch?

I already said - I'd use MOUSEEVENTF_MOVE rather than MOUSEEVENTF_LEFTDOWN. You might want to have a quick look at the documentation for the mouse_event API

>in other case found this:

Great at starting a screensaver, rubbish at stopping one

RE: activate / deactivate screen server

(OP)
please strongm, can you modify this:

CODE

Private Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_LEFTDOWN = &H2

Private Sub Form_Load()
Timer1.Interval = 50000
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
Call mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
End Sub 

RE: activate / deactivate screen server

CODE -->

Private Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_MOVE = &H1 ' as detailed in one of my previous posts

Private Sub Form_Load()
Timer1.Interval = 50000
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
' A tiny wiggle
Call mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0)
Call mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0)
End Sub 


RE: activate / deactivate screen server

(OP)
Hi stringm,
tks, work!

but possible to stop the execution of timer?

RE: activate / deactivate screen server

> stop the execution of timer?

Timer1.Enabled=False

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close