Results 1 to 16 of 16

Thread: vb6 get user idle time

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2008
    Posts
    198

    vb6 get user idle time

    hi.
    i wanna get the user idle time. i used this code
    '-------------------------------------------------------
    Option Explicit
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    Private Declare Function GetLastInputInfo Lib "user32" (plii As Any) As Long
    Private Type LASTINPUTINFO
    cbSize As Long
    dwTime As Long
    End Type

    Private Sub Timer1_Timer()
    Dim lii As LASTINPUTINFO
    lii.cbSize = Len(lii)
    Call GetLastInputInfo(lii)
    With Label1
    .Caption = FormatNumber((GetTickCount() - lii.dwTime) / 1000, 2)
    .Refresh
    End With
    If Label1.Caption = "10.00" Then
    MsgBox "hi"
    End If
    End Sub
    '---------------------------------------------------------------------
    it's works good but not on windows 98.
    can anone help me get the idle time in windows 98 too?
    thanx.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: vb6 get user idle time

    Thread Moved
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: vb6 get user idle time

    Welcome to the forums.

    What does it do on Windows 98?

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: vb6 get user idle time

    GetLastInputInfo is not supported on operating systems before Windows 2000. So on Windows 98 it will fail. You need to create (if possible) your own duplicate function to replace the unsupported API.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: vb6 get user idle time

    This should work on all OS

    System Wide Idle Time - Idle time dll

    http://www.developerfusion.co.uk/show/2013/

    Also see:
    API GetQueueStatus, QS_INPUT = QS_MOUSE Or QS_KEY
    http://www.planet-source-code.com/vb...29735&lngWId=1

    Check if an Application is Idle for a Period of Time
    http://www.freevbcode.com/ShowCode.asp?ID=3297

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Apr 2008
    Posts
    198

    Re: vb6 get user idle time

    thanx but it's not work
    i want to show the user idle time

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Apr 2008
    Posts
    198

    Re: vb6 get user idle time

    heloo hack.
    in windows 98 i get error
    i user user32 to get the idle time, the function "getlastinfo" not exist in the user32.dll of windows 98!!!

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: vb6 get user idle time

    Quote Originally Posted by yosef_mreh
    heloo hack.
    in windows 98 i get error
    i user user32 to get the idle time, the function "getlastinfo" not exist in the user32.dll of windows 98!!!
    Did you see RobDog888's comment?
    Quote Originally Posted by RobDog888
    GetLastInputInfo is not supported on operating systems before Windows 2000. So on Windows 98 it will fail. You need to create (if possible) your own duplicate function to replace the unsupported API.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Apr 2008
    Posts
    198

    Re: vb6 get user idle time

    it's ok... i know i can do this
    but i want the application to run under windows98 too
    is any function can return the idle time in windows 98?

  10. #10
    New Member
    Join Date
    Nov 2008
    Posts
    2

    Thumbs up Re: vb6 get user idle time

    I think this code exactly suites my requirement. I have implemented this code to find user's idle time. It is working find until now.

    I have implemented this on Windows XP

    A BIG thanks for providing this code.

    Quote Originally Posted by yosef_mreh
    hi.
    i wanna get the user idle time. i used this code
    '-------------------------------------------------------
    Option Explicit
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    Private Declare Function GetLastInputInfo Lib "user32" (plii As Any) As Long
    Private Type LASTINPUTINFO
    cbSize As Long
    dwTime As Long
    End Type

    Private Sub Timer1_Timer()
    Dim lii As LASTINPUTINFO
    lii.cbSize = Len(lii)
    Call GetLastInputInfo(lii)
    With Label1
    .Caption = FormatNumber((GetTickCount() - lii.dwTime) / 1000, 2)
    .Refresh
    End With
    If Label1.Caption = "10.00" Then
    MsgBox "hi"
    End If
    End Sub
    '---------------------------------------------------------------------
    it's works good but not on windows 98.
    can anone help me get the idle time in windows 98 too?
    thanx.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Apr 2008
    Posts
    198

    Re: vb6 get user idle time

    no way.
    there is no idle time in windows 98.
    microsoft ceck the if the mouse replaced or an intrapt from the keyboard. this what microsoft do in windows 98 to run the SCREEN SERVER.
    you can do the same thing. replay me if u wanna know how to get the OS using vb6

  12. #12
    Member
    Join Date
    Dec 2012
    Posts
    49

    Re: vb6 get user idle time

    HI yosef_mreh, i need ya help with your timer code too.

    can your code detect a user idle states ??

    cause im doing an auto logout page for the user if the user is idle, when the user forgot to logout.
    can you help me with that cause i'm doing my Final year project, left a fews days!! please help me!! Thanks

  13. #13
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: vb6 get user idle time

    Quote Originally Posted by fatboycgn View Post
    HI yosef_mreh, i need ya help with your timer code too.
    Well, considering the thread is over 4 years old I am not sure if the original poster is still active. Your best bet would be to start your own thread and refer to this thread via a link.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  14. #14
    Member
    Join Date
    Dec 2012
    Posts
    49

    Re: vb6 get user idle time

    okay thanks

  15. #15
    New Member
    Join Date
    Apr 2020
    Posts
    4

    Thumbs up Re: vb6 get user idle time

    Quote Originally Posted by yosef_mreh View Post
    hi.
    i wanna get the user idle time. i used this code
    '-------------------------------------------------------
    Option Explicit
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    Private Declare Function GetLastInputInfo Lib "user32" (plii As Any) As Long
    Private Type LASTINPUTINFO
    cbSize As Long
    dwTime As Long
    End Type

    Private Sub Timer1_Timer()
    Dim lii As LASTINPUTINFO
    lii.cbSize = Len(lii)
    Call GetLastInputInfo(lii)
    With Label1
    .Caption = FormatNumber((GetTickCount() - lii.dwTime) / 1000, 2)
    .Refresh
    End With
    If Label1.Caption = "10.00" Then
    MsgBox "hi"
    End If
    End Sub
    '---------------------------------------------------------------------
    it's works good but not on windows 98.
    can anone help me get the idle time in windows 98 too?
    thanx.
    Its works good
    Thanks

  16. #16
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: vb6 get user idle time

    Leave no grave undug.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width