Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

activate / deactivate screen server 2

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
425
IT
POssible to activate/deactivate screen saver, via commandbutton?
Tks.
 
If the screen saver is active, i.e. blank screen, how would you see the command button to deactivate it?

[gray]Experience is something you don't get until just after you need it.[/gray]
 
ERROR7, Im stupid!

My request is:

pseudo code

...
deactivate scree saver
...
do until rs.eof
...
rs.move.next
...
loop
reactivate normal screen saver
....
 
What do you do to your [tt]rs[/tt] 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
 
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
 
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
 
Will a simple Send Key command periodically prevent the screen saver from kicking in?

[gray]Experience is something you don't get until just after you need it.[/gray]
 
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
 
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

[gray]Experience is something you don't get until just after you need it.[/gray]
 
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
...

 
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
 
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
 
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
 
>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

 
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
 
Code:
[COLOR=blue]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 [b]MOUSEEVENTF_MOVE = &H1[/b] [COLOR=green]' as detailed in one of my previous posts[/color]

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

Private Sub Timer1_Timer()
[COLOR=green]' A tiny wiggle[/color]
Call mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0)
Call mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0)
End Sub[/color]

 
Hi stringm,
tks, work!

but possible to stop the execution of timer?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top