Results 1 to 24 of 24

Thread: [RESOLVED] Disabling Certain Keys

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Resolved [RESOLVED] Disabling Certain Keys

    Does anybody know how to disable only certain keys of the keyboard? I know about the blockinput(true/false) API but that blocks ALL the input including all of the mouse and the keyboard whereas all I want is blocking only certain keys e.g. A B C End Home etc. If someone knows then please tell.

  2. #2
    Junior Member
    Join Date
    May 2006
    Posts
    23

    Re: Disabling Certain Keys

    maybe try keycode or keydown... and if KeyCode = TheKeyYouWannaBlock Then Stop it... or something...

    wild guess

  3. #3
    Addicted Member
    Join Date
    Apr 2006
    Location
    USA
    Posts
    207

    Re: Disabling Certain Keys

    I agree... using keydown or keypress will "block" keys within your form or controls.

    What key(s) are you trying to "block" ? And do you want to "block" them in just your app or system wide ?
    Last edited by Keith_VB6; May 21st, 2006 at 04:43 PM. Reason: typos
    Keith_VB6

    If you have any further questions, just ask.
    If this solves things, then please mark the thread resolved.
    [Thread Tools] --> [Mark Thread Resolved]

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

    Re: Disabling Certain Keys

    Not sure why you would want to block certain basic keys system wide?
    How would you write an email or do anything with certain alpha characters blocked?

    What are you trying to accomplish?
    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
    Addicted Member
    Join Date
    Apr 2006
    Location
    USA
    Posts
    207

    Re: Disabling Certain Keys

    I only asked "system wide" in case lone_REBEL was trying to block system keys such as print-screen or ALT-CTR-BREAK. Something, I personally don't like doing. I didn't mean, block the "K" key.
    Keith_VB6

    If you have any further questions, just ask.
    If this solves things, then please mark the thread resolved.
    [Thread Tools] --> [Mark Thread Resolved]

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

    Re: Disabling Certain Keys

    Oh, I know. Its just I read that he already tried using the BlockInput API which is system wide.
    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

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Re: Disabling Certain Keys

    actually I want to block the keys system-wide since blocking keys in your app is such foolishly simple you can just use
    Private Sub ObjectName_KeyPress(KeyAscii As Long)
    If KeyAscii=YourBlockingKeyAscii Then
    KeyAscii=0
    End If

    Actually what I'm trying to do is blocking my space key since it is teasing me so much in gaming. Can you please tell me a way??

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

    Re: Disabling Certain Keys

    check out the GetAsyncKeyState 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

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Re: Disabling Certain Keys

    Oh man the GetAsyncKeyState tells me what keys have been pressed or are being pressed, if I get the ascii of my blocked key there, how can I stop the input??
    I mean while in game, when the space is pressed (by my ill fate), by the time I find out that the space key has been pressed, I wont be able to "undo" the press action and my poor character will be dead by that time!
    What do I do to DISABLE the input of space key to ALL the running apps at the time??

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

    Re: Disabling Certain Keys

    Not sure as I havent done much on blocking inputs.

    Wy does the space bar kill your character? Sounds like a suicide feature
    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

  11. #11
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Disabling Certain Keys

    Why would you block input to all other applications? You should try to correct the code in the game itself rather than blocking the input.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

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

    Re: Disabling Certain Keys

    I dont think he has access to the source.
    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

  13. #13
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    297

    Re: Disabling Certain Keys

    You'll need a low level keyboard hook, here's a link
    http://www.codeguru.com/vb/gen/vb_sy...icle.php/c4829

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

    Re: Disabling Certain Keys

    Ooooh, jo0ls burned you Shuja Ali. An article from CG.
    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

  15. #15
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Disabling Certain Keys

    Quote Originally Posted by RobDog888
    Ooooh, jo0ls burned you Shuja Ali. An article from CG.
    :burning:

    I still will not disable the space key system wide. And that too using CallBack functions will be tedious for a newbie.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Re: Disabling Certain Keys

    I've got the code and its working but I don't know how it damn works!
    Looks like I'll have to be contented that at least I got the code (even if in greek)

  17. #17
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Disabling Certain Keys

    Quote Originally Posted by lone_REBEL
    Actually what I'm trying to do is blocking my space key since it is teasing me so much in gaming. Can you please tell me a way??
    Your easiest solution is to pull the space bar off the keyboard whilst playing (that's not a joke - i have no left Windows key on my keyboard for just such a reason.)

  18. #18
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Disabling Certain Keys

    Quote Originally Posted by bushmobile
    Your easiest solution is to pull the space bar off the keyboard whilst playing (that's not a joke - i have no left Windows key on my keyboard for just such a reason.)

    And it is just a two second job, no coding required and no need to understand those horrible API's.

    Edit-- Finally 1000
    Use [code] source code here[/code] tags when you post source code.

    My Articles

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

    Re: Disabling Certain Keys

    Quote Originally Posted by bushmobile
    Your easiest solution is to pull the space bar off the keyboard whilst playing (that's not a joke - i have no left Windows key on my keyboard for just such a reason.)
    I actually was going to suggest that earlier in the thread!


    Ps, Congrats on 1,000 posts Shuja Ali
    Glad to see you have made VBF your home over CG
    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

  20. #20
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Disabling Certain Keys

    Quote Originally Posted by RobDog888
    Ps, Congrats on 1,000 posts Shuja Ali
    Glad to see you have made VBF your home over CG
    Thanks.

    I still belong to CG. I am a happy CGian contributing on VBF too.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  21. #21

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Re: Disabling Certain Keys

    Hahahahaha!
    Ever heard about the "Silh's" keyboards??
    My kb had builtin protrudings that prohibits me from such a job!

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

    Re: Disabling Certain Keys

    Use a joystick or other game controller to play the game. Problem solved. No c0d needed.
    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

  23. #23

  24. #24

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Re: Disabling Certain Keys

    Fool its my keyboard manufacturer company name
    And they make some terrible PC products!
    Bye the way my question has been solved. Thanx to you jo0ls.

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