Results 1 to 20 of 20

Thread: Sys Tray security app?

  1. #1

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Sys Tray security app?

    I have a security app on this computer that keeps people out of my personal files. However, at this time, it's a standard .exe sitting in one of the folders, nothing difficult to find.

    What I'm looking for is a program that launches from the Windows startup, and maintains itself active in the system tray so I know it's running, but registers keystrokes that the user makes. That way, if I enter a certain key set, then the program will kick up the password screen. I can run everything after that no problem.

    the problem is with the system tray, startup, and keystrokes... Is there any way to accomplish all of this with vb6?

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Sys Tray security app?

    Why not use the password feature of the desktop? Just activate the screensaver when you've got to go.

  3. #3

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Sys Tray security app?

    This computer is one of the fastest in the house, so I let everyone use it... otherwise I wouldn't have a problem. My account does have a password on it. I'm not that dumb...

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Sys Tray security app?

    Are you using Windows XP?

    If so the easy solution is to create another user (which everyone else will use), then "Fast user switching" will do the job.. on the Start menu click on "Log off", then "Switch User".

    They can then log in as the other user, but not as 'you' unless they know the password. That way they can't see your files, and your desktop will stay as it was (along with any open programs).

  5. #5

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Sys Tray security app?

    I have that too, but the guest file can't download to the right directories. That's mostly what other people use it for... downloading stuff that I put on iPods and Cd's and the like... otherwise I'd just use that method.

    Either way, it'd be a good experience and a good way to expand my knowledge of VB.

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Sys Tray security app?

    Fair enough.. but I'll just point out that you could give the other user permission to the directories, and put shortcuts on their desktop.

  7. #7

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Sys Tray security app?

    Noted.

    So, with a project like this, where should I start? I've modified the end routine (when I hit a certain keystroke) to work a little more sleekly, but what should the first target be? I'm thinking working backwards, since testing the whole program would require restarting Windows. Should the System Tray be first? If so, how? I've never even thought about venturing here before... I'm planning on having fun and learning.

  8. #8
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Sys Tray security app?

    Well the way I see it there's a few things that would be useful...

    First off would be HotKeys (example code) to get the key-strokes you want, no matter which program has the focus.

    The system tray is fairly easy, and can be seen here.

  9. #9

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Sys Tray security app?

    Ok, now that I have some code... Is there any chance you could catch me on MSN or AIM and help me pick this stuff apart? Some of it looks kinda confusing...

  10. #10

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Sys Tray security app?

    I have the system tray code incorporated successfully, with just minor problems...

    First, I need to know how to call up a subroutine when I double click (debugging purposes), that involves the form itself, and two...

    I think I'm going to have to set Form.Visible to False to keep the application hidden until the keystroke is entered, but will the previously mentioned subroutine be able to launch while invisible?

  11. #11
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Sys Tray security app?

    I didn't notice that the systray code I linked to was missing the interaction part, see this thread for another example which includes that side of things.

    The hotkey should work no matter whether the form is visible or not.

    Quote Originally Posted by timeshifter
    Ok, now that I have some code... Is there any chance you could catch me on MSN or AIM and help me pick this stuff apart? Some of it looks kinda confusing...
    I'm afraid I dont use any kind of messenger, only the forums.

  12. #12

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Sys Tray security app?

    OK... I've got the SysTray part working the way it should... and the hotkey works, but only until focus is diverted to something... seems to be a problem...

  13. #13
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Sys Tray security app?

    I just read the documentation and it looked like the window does actually need to be visible, but a quick test showed it is not the case - changing "WindowState = vbMinimized" to "Me.Visible = Not (Me.Visible)" worked fine.

    I think we'll need to see your code.

  14. #14

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Sys Tray security app?

    I can do that... Single form with one text box (Text1) and one command box (Command1):


    VB Code:
    1. 'Hotkey Credits:
    2.         'KPD-Team 2000
    3.         'URL: [url]http://www.allapi.net/[/url]
    4.         'E-Mail: [email][email protected][/email]
    5.  
    6.  
    7. Option Explicit
    8.  
    9.  
    10.  
    11. '//////Start Sys Tray Info\\\\\\
    12.     Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Long
    13.    
    14.     Private Type NOTIFYICONDATA
    15.         cbSize As Long
    16.         hWnd As Long
    17.         uId As Long
    18.         uFlags As Long
    19.         ucallbackMessage As Long
    20.         hIcon As Long
    21.         szTip As String * 64
    22.     End Type
    23.    
    24.     Private Const NIM_ADD = &H0
    25.     Private Const NIM_MODIFY = &H1
    26.     Private Const NIM_DELETE = &H2
    27.     Private Const NIF_MESSAGE = &H1
    28.     Private Const NIF_ICON = &H2
    29.     Private Const NIF_TIP = &H4
    30.    
    31.     Private Const WM_LBUTTONDBLCLK = &H203
    32.     Private Const WM_LBUTTONDOWN = &H201
    33.     Private Const WM_RBUTTONUP = &H205
    34.    
    35.     Dim NID As NOTIFYICONDATA
    36. '\\\\\\End Sys Tray Info//////
    37.  
    38.  
    39.  
    40. '//////Start Hotkey Info\\\\\\
    41.     Private Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long, ByVal fsmodifiers As Long, ByVal vk As Long) As Long
    42.     Private Declare Function UnregisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long) As Long
    43.     Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As Msg, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
    44.     Private Declare Function WaitMessage Lib "user32" () As Long
    45.    
    46.     Private Const MOD_ALT = &H1
    47.     Private Const MOD_CONTROL = &H2
    48.     Private Const MOD_SHIFT = &H4
    49.     Private Const PM_REMOVE = &H1
    50.     Private Const WM_HOTKEY = &H312
    51.    
    52.     Private Type POINTAPI
    53.         x As Long
    54.         y As Long
    55.     End Type
    56.    
    57.     Private Type Msg
    58.         hWnd As Long
    59.         Message As Long
    60.         wParam As Long
    61.         lParam As Long
    62.         time As Long
    63.         pt As POINTAPI
    64.     End Type
    65.    
    66.     Private bCancel As Boolean
    67. '\\\\\\End Hotkey Info//////
    68.  
    69.  
    70.  
    71.  
    72. Private Sub Form_Load()
    73.  
    74.     '///System Tray\\\
    75.  
    76.         With NID
    77.             .cbSize = Len(NID)
    78.             .hIcon = Me.Icon
    79.             .hWnd = Me.hWnd
    80.             .szTip = "Crazy Dave's Security Suite" & vbNullChar
    81.             .ucallbackMessage = WM_LBUTTONDBLCLK
    82.             .uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP
    83.             .uId = 1&
    84.         End With 'Set the data
    85.        
    86.         Shell_NotifyIcon NIM_ADD, NID 'Add the Icon
    87.    
    88.     '\\\System Tray///
    89.    
    90.    
    91.    
    92.     '///Hotkeys\\\
    93.    
    94.         Dim ret As Long
    95.         bCancel = False
    96.        
    97.         ret = RegisterHotKey(Me.hWnd, &HBFFF&, MOD_CONTROL, vbKeyT) 'register the Ctrl-T hotkey
    98.        
    99.         ProcessMessages 'process the Hotkey messages
    100.    
    101.     '\\\Hotkeys///
    102.    
    103.     Me.Visible = False
    104.     Me.WindowState = vbMinimized
    105.    
    106. End Sub
    107.  
    108. Private Sub ProcessMessages()
    109.  
    110.     Dim Message As Msg
    111.    
    112.     Do While Not bCancel 'loop until bCancel is set to True
    113.        
    114.         WaitMessage 'wait for a message
    115.        
    116.         If PeekMessage(Message, Me.hWnd, WM_HOTKEY, WM_HOTKEY, PM_REMOVE) Then 'check if it's a HOTKEY-message
    117.             Visible = True
    118.             WindowState = vbNormal
    119.         End If 'any needed tasks upon detection of the hotkey
    120.        
    121.         DoEvents 'let the operating system process other events
    122.     Loop
    123.    
    124. End Sub
    125.  
    126. Private Sub Form_Unload(Cancel As Integer)
    127.  
    128.     bCancel = True
    129.    
    130.     Call UnregisterHotKey(Me.hWnd, &HBFFF&) 'unregister hotkey
    131.    
    132. End Sub
    133. Private Sub Text1_KeyPress(KeyAscii As Integer)
    134.  
    135.     If KeyAscii = 13 Then Command1_Click
    136.    
    137. End Sub
    138.  
    139. Private Sub Command1_Click()
    140.  
    141.     If Text1.Text = "youdonotneedmypassword" Then
    142.         Shell "explorer.exe myFolder", vbNormalFocus
    143.         Me.Visible = False
    144.     End If
    145.    
    146.     Text1.Text = ""
    147.  
    148. End Sub
    Last edited by timeshifter; Oct 29th, 2006 at 08:55 PM.

  15. #15

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Sys Tray security app?

    Never mind about the problems... must have just been one of those wierd things that causes something not to work. Seems to work great now.

    That leaves just one problem: activating on startup. Any great ideas?

  16. #16
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Sys Tray security app?

    It seems the barrage of phone calls I recieved came at the right time, I would have been hunting for a cause & solution otherwise!

    As it is just for your PC, the easiest way is to go into the registry, and add a new entry here:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

    ..you should be able to work out what kind of thing needs to be entered based on what is there already.

  17. #17

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Sys Tray security app?

    I feel like a real noob with this question, but I've never dealt with registries before...

  18. #18
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Sys Tray security app?

    No problem, we've all had to learn at some point!

    Open up the Start menu, and select Run; then type in "Regedit" (without quotes), and press enter. RegEdit will then open, and you will notice it looks like Windows Explorer - just navigate to the location I mentioned above in the usual way.

    On the right hand side you will then see several entries, and you are just going to add one more - to do this Right-click in the right hand pane, and select "New" -> "String Value". The name doesn't really matter that much (preferably something that makes sense to you!), just set the value to the full path & filename of your executable.

  19. #19
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Sys Tray security app?


  20. #20
    Addicted Member Jazz00006's Avatar
    Join Date
    Feb 2006
    Posts
    185

    Re: Sys Tray security app?

    http://sf.greyfyre.info/forums/index...opic,13.0.html

    Is this the kind of thing you are looking for? if so i can help you out a lot with a project like this. (if you need anymore). all this one needs is a run @ start up

    EDIT: i know it is a bit late, but this has almost everything you want

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