473,626 Members | 3,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code for Numlock for 64bit

DJRhino1175
221 New Member
I have VBA code to make sure the numlocks are on, but we I try to compile it it tells me it needs to be in 64bit.

Expand|Select|Wrap|Line Numbers
  1. Private Declare Sub keybd_event Lib "user32" ( _
  2. ByVal bVk As Byte, _
  3. ByVal bScan As Byte, _
  4. ByVal dwFlags As Long, _
  5. ByVal dwExtraInfo As Long)
  6. Private Const VK_NUMLOCK = &H90
  7. Private Const KEYEVENTF_KEYUP = &H2
  8. Declare Function GetKeyState Lib "user32.dll" ( _
  9. ByVal nVirtKey As Long) As Integer
  10.  
  11. Sub numon()
  12.      'NUM_Off
  13.     NUM_On
  14. End Sub
  15.  
  16. Sub NUM_TOGGLE()
  17.      'Toggle NUM-Lock key state
  18.     keybd_event VK_NUMLOCK, 1, 0, 0
  19.     keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
  20. End Sub
  21.  
  22. Sub NUM_On() 'Turn NUM-Lock on
  23.     If Not (GetKeyState(vbKeyNumlock) = 1) Then
  24.         keybd_event VK_NUMLOCK, 1, 0, 0
  25.         keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
  26.     End If
  27. End Sub
  28.  
  29. Sub NUM_Off() 'Turn NUM-Lock off
  30.     If (GetKeyState(vbKeyNumlock) = 1) Then
  31.         keybd_event VK_NUMLOCK, 1, 0, 0
  32.         keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
  33.     End If
  34.  
  35. End Sub
I do have 64bit, and I want to add this to all my database as we use the numpad a lot. We are so use to the numlocks being on all the time, but since we upgraded all our PC's to Win 10, the numlock always turns off.

Thanks a million for all your help.
Mar 28 '19 #1
11 3790
twinnyfo
3,653 Recognized Expert Moderator Specialist
DJ,

Actually, what you really want to do is change the num lock in the system settings. This is not a Win 10 thing, it is a Network System Administrator thing, in which, for some absolutely unknown reason, they are changing the system registry to default the system to Num Lock Off.
  • Press Win + R and type in Regedit
  • Navigate to registry key HKEY_USERS\.Def ault\Control Panel\Keyboard
  • Right-click on the “InitialKeyboar dIndicators”, select Modify and change Value data to 2.
  • Exit and Save the Registry.

This may (probably) need to be done by an administrator.

There are ways to "trick" the Num Lock to switch, but my experiences with it have have been and miss. But, I admit I haven't tried it with Win 10, so that may be more stable--but again, the above does not answer your specific question about a 64-bit key for that value.

Concerning converting it to 64-bit, an initial guess would be add two leading zeroes to your value? But that is purely speculation.
Mar 28 '19 #2
DJRhino1175
221 New Member
Our system is locked out by our company IT. If I do it through VBA, it will fix it for everyone that uses one of my Databases. I only have user rights in my company(unfortu nately), so makes it very difficult do fix issues when they arise....

But thanks for your reply. I even did research on what you put and I guess the solution you put forth isn't a 100% fix for Win10.

When will microsoft get things right???
Mar 28 '19 #3
twinnyfo
3,653 Recognized Expert Moderator Specialist
So, when you compile your DB, it hangs on Line 6 above?

We've got 64-bit at work, too, and I've had no issues with compiling--and I use your same function for some other things I do. I am having no issues with toggling the Num Lock.
Mar 28 '19 #4
DJRhino1175
221 New Member
Expand|Select|Wrap|Line Numbers
  1. Private Declare Sub keybd_event Lib "user32" ( _
Line 1 is where it hangs up when trying to compile.
Mar 28 '19 #5
DJRhino1175
221 New Member
Here is the error that pops up

Compile Error:
The code in this project must be updated for use on64-bit systems. Please review and update Declare statements and then mark them with PtrSafe attribute.
Mar 28 '19 #6
twinnyfo
3,653 Recognized Expert Moderator Specialist
Expand|Select|Wrap|Line Numbers
  1. Private Declare PtrSafe Sub keybd_event Lib "user32"
Mar 28 '19 #7
DJRhino1175
221 New Member
That did it, need it in 2 spots, but got it to compile. Now to test the code to make sure it works. I put this into a Module, I'm not 100% sure if this was the right place to put it.
Mar 28 '19 #8
DJRhino1175
221 New Member
Compiled Code:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Declare PtrSafe Sub keybd_event Lib "user32" ( _
  5. ByVal bVk As Byte, _
  6. ByVal bScan As Byte, _
  7. ByVal dwFlags As Long, _
  8. ByVal dwExtraInfo As Long)
  9. Private Const VK_NUMLOCK = &H90
  10. Private Const KEYEVENTF_KEYUP = &H2
  11. Declare PtrSafe Function GetKeyState Lib "user32.dll" ( _
  12. ByVal nVirtKey As Long) As Integer
  13.  
  14. Sub numon()
  15.      'NUM_Off
  16.     NUM_On
  17. End Sub
  18.  
  19. Sub NUM_TOGGLE()
  20.      'Toggle NUM-Lock key state
  21.     keybd_event VK_NUMLOCK, 1, 0, 0
  22.     keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
  23. End Sub
  24.  
  25. Sub NUM_On() 'Turn NUM-Lock on
  26.     If Not (GetKeyState(vbKeyNumlock) = 1) Then
  27.         keybd_event VK_NUMLOCK, 1, 0, 0
  28.         keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
  29.     End If
  30. End Sub
  31.  
  32. 'Sub NUM_Off() 'Turn NUM-Lock off
  33. '    If (GetKeyState(vbKeyNumlock) = 1) Then
  34. '        keybd_event VK_NUMLOCK, 1, 0, 0
  35. '        keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
  36. '    End If
  37. '
  38. 'End Sub
  39.  
Mar 28 '19 #9
DJRhino1175
221 New Member
Trying to run this code, but cannot get it to trigger through an Autoexec macro(I know bad)

Would I put this in "On Open" event of the form? Would I need to put this onto every form as to make sure it runs for every form? Is there a way to run this a different way? Should I just use one of the subs and if so how would I call this out in my database?

Sorry for the multiple questions, but this is new territory for me.
Mar 28 '19 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3240
by: Christian McArdle | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.os.ms-windows.programmer.64bit This is a formal Request For Discussion (RFD) to create comp.os.ms-windows.programmer.64bit as an unmoderated world-wide Usenet newsgroup dedicated to the discussion of Microsoft Windows 64-bit programming. This is not a Call for Votes (CFV); you cannot vote at this time. Procedural details appear below. All followup discussion should be crossposted to...
1
9535
by: George | last post by:
Every time I used the Sendkeys command in my application the "Numlock" turned off and I couldn't use the keypad to hit numbers...... The old code was: Private Sub Command1_Click() SendKeys "{DOWN}" SendKeys "^{END}" SendKeys "{TAB}" End Sub
5
12132
by: James Kirkup | last post by:
Hello, Does anyone know in code how to turn the NumLock key on in C#? with regards James *** Sent via Developersdex http://www.developersdex.com ***
2
6382
by: Chris | last post by:
can anyone out there tell me how do u check the state of these keys in vb.net? or is there any components in the .NET Framework that supports doing so? any help is appreciated. Thanks.
2
3213
by: Woody Splawn | last post by:
Could someone tell me what code I run to determine if the user's numlock is on? Is there code I can run to set the numlock to on?
5
1958
by: Stan Sainte-Rose | last post by:
Hi I saw a post about numlock but I can't not read it. I would like to check the state of the numlock key and if it's not active, set its status on active. How can I accomplish that in vb ? Stan
10
7792
by: lgbjr | last post by:
Hi All, In VB.Net how do I determine if CapsLock is on/off (same for NumLock) and whether the input mode is set to Insert or Overwrite (Insert Key). I just added a status bar to my app, and I want to reflect the state of these three items (similar to Word, Excel, etc.) I've found the key enumerator value for each key, but I don't know how to tell if the state is on/off, etc. TIA Lee
4
3292
by: legrape | last post by:
I am porting a piece of C code to 64bit on Linux. I am using 64bit integers. It is a floating point intensive code and when I compile (gcc) on 64 bit machine, I don't see any runtime improvement when optimizing -O3. If I construct a small program I can get significant (>4x) speed improvement using -O3 versus -g. If I compile on a 32 bit machine, it runs 5x faster on the 64 bit machine than does the 64bit compiled code. It seems like...
3
3948
by: Z.K. | last post by:
I am trying to detect if the Numlock is pressed. I can do it okay with the CapsLock or the ScrLk, but not with NumLock. The code for all three checks is exactly the same, but for some reason numlock always thinks it is on. Z.K. code:
4
16115
twinnyfo
by: twinnyfo | last post by:
OK Race fans, here's a whacky one: In a separate module, I have these declarations: Option Compare Database Option Explicit Public Declare Function GetTickCount Lib "kernel32" () As Long Public Declare Function GetLastInputInfo Lib "user32" (pLII As Any) As Long
0
8266
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8199
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8638
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7196
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2626
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.