Results 1 to 24 of 24

Thread: Something VB will not do...

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Unhappy Something VB will not do...

    I can't believe it... I think I've actually found something that VB just will not do...

    I can not, for the life of me, find a way to make vb trap keypresses without a control or form having to be in focus...

    Does ANYBODY know how to do this???? Is it possible???

    thanks,
    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  2. #2
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    Set the form's keypreview property to True.

  3. #3
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    That doesn't solve the chance if the user is working with another app.... I answered your question in your other thread Squirelly, and its called a keyhook. It can be done, but it should be done only if absolutely necessary.

  4. #4
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    You might want to try this sample project from William Storage

    http://bstorage.com/Downloadable/KeyHook.ZIP

  5. #5
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352
    Something VB can't do, haha? How about multithread, run reliably as a service app(without a wrapper), etc. . There are plenty of them, but VB is still useful none the less.

    Joe

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    joey.. you forgot interitence...

    but most of that stuff VB "can't" do can be done in .NET

  7. #7
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352
    Yes it can be done in .NET... to think all you have to do is sacrifice the convinient syntax conventions and learn an almost entirely new language .

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    yeah well it happens.... if new langauges didn't come around i would still be coding in COBOL

  9. #9
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352
    At the risk of starting a .NET debate, I will make one point. VB exists for a few simple reason: ease to learn, ease to use, and RAD(rapid application development). When VB loses all of that you mine as well be using c++.

  10. #10
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    ok we won't have a debate... because honestly if we all love it or hate it... it is going to take over VB6 and nothing can stop it...

    but I believe it still does have RAD without a doubt... it is still forms that you drag controls onto... all that is really different is it exposes more of the code behind what it is doing where as VB6 did not.. but it auto generates all that code for you.. so you can mess with it if you want.. or leave it alone..

    all in all once we get in the groove of it... i am sure we will all like it... cander has been using it for a while i believe and he likes it a lot

  11. #11
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    VB .NET is still just as easy and fast to write to write. You just got more power options. It isnt any harder to learn than VB6 was.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  12. #12
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Originally posted by kleinma


    all in all once we get in the groove of it... i am sure we will all like it... cander has been using it for a while i believe and he likes it a lot
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  13. #13
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Originally posted by Cander


    i knew you would be around here somewhere to back me up

  14. #14
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    If the thread says .NET, Im there!

    I need to my sig to say 'Master of the D'uh .NET!'

    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  15. #15
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352
    The transition between VB 5 to VB 6 was simple. For that matter so was VB 4 to VB 5. VB.NET is unlike any other BASIC language. If I want power, I will go to c++. If I want RAD, I will stick with VB 6, and if they become very insistent about .NET then I will switch to Delphi. It has some advantages already over VB, but came with a learning curve because I don't know PASCAL. PASCAL seems easier to learn than to begin memorizing the various changes to the BASIC language in .NET. But enough of this.

  16. #16
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    "then I will switch to Delphi"

    Now that is what gets me. Alot of devs have said that they are going to switch to Delphi becuase they dont want to learn changes to .NET.

    Can you not see the hypocrisy here? You dont want to learn the changes to .NET but you will learn a WHOLE brand new language?
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  17. #17
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    What gets me is that the "changes" to VB that people are complaining about are the [B]things developers have been asking for for years![B] GASP! MS finally gave us what we've been asking for, inheritance, truer OOP, more power, various shorthand notations... etc. And yet these are the verythings that people are now complaining about. I say it's about time VB grew up. The only thing basic about it is its name. While it's fairly easy to learn, it has eveloved into a complex language. Having worked w/ MANY languages, incl Pascal (pre-Delphi), MSBASIC (When the BASIC part was really an acronym, not a description), C, ASM, Ada and others, I've come to one conclusion: When you boil it all down, most are pretty much the same (excepting COBOL, because, well, it's COBOL), syntax may vary, but an "if" statement is an "if" statement. It works the the same. If some condition is true, execute statement X otherwise execute statement Y. For loops, are the same way. You have a start assignment, an exit condition, a counter modifier, and statements to execute.
    .NET is no different. It's just not what we are use to. I remember moving from InterDev 1 to InterDev 6 -- it was different, but I got use to it and learned its power.
    Familiarty breeds complacentcy (sp?). I heard the same type of griping when Win95 came out, and again when XP came out. The interfaces changed dramaticaly and people weren't use to it.
    Times change, things evolve. VB is finally starting to come into it's own.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  18. #18
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I love the fact that VB has evolved into vb.net, i think most people are just griping because the .NET framework has yet to be established on most consumer's computers. This obviously will not be the case a year from now, by then, I would imagine most people will have had the framework downloaded.. or there after purchasing a new computer. (And well, win95 consumers would be left in the cold, by i think they represent a small minority now, as my current website stats show)

    And if MS could get the framework on UNIX machines... we would all be in programming heaven...

  19. #19
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    MS wont do anything official for *nix, but they did put out Rotor which is an unsupported .NET for FreeBSD and Ximian has an Open source .NET running on Linux. They just need to finish all the class libraries.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  20. #20
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125

    Re: Something VB will not do...

    Originally posted by squirrelly1
    I can't believe it... I think I've actually found something that VB just will not do...

    I can not, for the life of me, find a way to make vb trap keypresses without a control or form having to be in focus...

    Does ANYBODY know how to do this???? Is it possible???

    thanks,
    Squirrelly1
    Why not just use GetAsyncKeyState in a timer? That is how I do all my capturing of keys when the program is not in focus. The only draw back is you have to be expecting the key, you can't just log all keys that get pressed, not very easily anyway.
    <removed by admin>

  21. #21

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    been tryin'

    I've been trying something like that, but I can't seem to get it right...

    Could you post some code for me???

    thnx,
    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  22. #22
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    VB Code:
    1. Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
    2. Private Const VK_A = &H41 'just take one of the keycodes from the txt file attached.
    3.  
    4. 'set the timer interval to 1
    5. Private Sub Timer1_Timer()
    6. If GetAsyncKeyState(VK_A) <> 0 Then
    7.   MsgBox "The A key was pressed."
    8. End If
    9. End Sub

    Attached is a list of virtual keycodes you can use in place of the A

    <removed by admin>

  23. #23
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Or actually... now it's attached.
    Attached Files Attached Files
    <removed by admin>

  24. #24
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352
    The Question:
    That method is horribly resource intensive. You are much better off using a keyboard hook.

    VB.NET:
    It is not hypocrisy. I acknowledged that it would entail learning a new language, but as was stated most languages are pretty similar. If I am going to invest time into a new learning curve, I will invest it in a product I feel is superior. Delphi has proven its stability and portability thus far. VB.NET is new. It's experimental, and it strays from the fundamental ease that was associated with programming with VB. C++ has always been superior to VB in terms of power so if I desire power, I will stick with that, but as for ease of use I still much much much prefer VB 6.0 to .NET.

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