Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggling the NUMLOCK when using SendKeys
I've tried, without success, to do this in a variety of ways when attempting
to send multiple SendKey commands from Excel to an Oracle-based database called 'Vantage Point' running in Windows. The code I used on a UserForm1 was as follows: (it will be obvious that I tried to adapt it from 'CAPSLOCK toggle, by the comments I left unchanged) Private Sub UserForm_Click() Private Sub Text1_Click() SendKeys "1" SendKeys "{NUMLOCK}" ' Turn on the CapsLock SendKeys "1" ' will be printed in caps For i = 0 To 10 SendKeys Chr(Asc("1") + i) 'will be printed in caps Next 'DoEvents ' uncommenting this will print next line in smalls SendKeys "o" ' will be printed in caps SendKeys "{NUMLOCK}" ' Turn off the caps lock SendKeys "o" ' Will be printed in smalls End Sub I used the following code on 'Sheet1' of my Excel workbook: Sub inputvpco() AppActivate "Maintain Queue Actuals" With ThisWorkbook.Sheets("Sheet1") SendKeys .Range("A1").Value End With End Sub If the NUM LOCK is turned off, this does not turn it back on again. I've also tried another test of this toggle using the following method (which I'm pretty sure I followed correctly) Start a new Standard EXE project in Visual Basic. Form1 is created by default. Add a CommandButton to Form1. Copy the following code to the Code window of Form1: Option Explicit Private Sub Command1_Click() SendKeys "a" SendKeys "b" End Sub On the Run menu, click Start or press the F5 key to start the program. If the NumLock light is off, turn on the NumLock light by pressing the NumLock key. Click the CommandButton and note that the NumLock light turns off. Close Visual Basic and repeat the steps above; this time adding DoEvents, as follows: Private Sub Command1_Click() SendKeys "a" DoEvents SendKeys "b" End Sub Again, the first half of this failed to toggle an 'on' num lock light to off!!!! Where do I go from here? I really do need to solve this problem of sending data in this way, it must be possible, and I've replicated the process from Excel to other non Microsoft 3rd Party programs running in Windows. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggling the NUMLOCK when using SendKeys
Is there a reason for NumLock to be on other than sending only upper case
characters? If you just need to send upper case only, you can use the UCase function to convert the string to upper case when you do the SendKeys: SendKeys "1" ' Note the below has no real effect but included since you had it: SendKeys UCase("1") ' will be printed in caps For i = 0 To 10 SendKeys UCase(Chr(Asc("1") + i)) 'will be printed in caps Next 'DoEvents ' uncommenting this will print next line in smalls ' Note: DoEvents only tells Excel to pause here for a moment to allow other process to occur; it will not to anything on its own to change the CapsLock state SendKeys UCase("o") ' will be printed in caps SendKeys "o" ' Will be printed in smalls If for some reason I am not aware of it is important not only that these be caps but that the CapsLock is actually on, that would involve Windows API calls: too much info to cover here but here is a reference: http://support.microsoft.com/default...b;en-us;190000 -- - K Dales "Zakynthos" wrote: I've tried, without success, to do this in a variety of ways when attempting to send multiple SendKey commands from Excel to an Oracle-based database called 'Vantage Point' running in Windows. The code I used on a UserForm1 was as follows: (it will be obvious that I tried to adapt it from 'CAPSLOCK toggle, by the comments I left unchanged) Private Sub UserForm_Click() Private Sub Text1_Click() SendKeys "1" SendKeys "{NUMLOCK}" ' Turn on the CapsLock SendKeys "1" ' will be printed in caps For i = 0 To 10 SendKeys Chr(Asc("1") + i) 'will be printed in caps Next 'DoEvents ' uncommenting this will print next line in smalls SendKeys "o" ' will be printed in caps SendKeys "{NUMLOCK}" ' Turn off the caps lock SendKeys "o" ' Will be printed in smalls End Sub I used the following code on 'Sheet1' of my Excel workbook: Sub inputvpco() AppActivate "Maintain Queue Actuals" With ThisWorkbook.Sheets("Sheet1") SendKeys .Range("A1").Value End With End Sub If the NUM LOCK is turned off, this does not turn it back on again. I've also tried another test of this toggle using the following method (which I'm pretty sure I followed correctly) Start a new Standard EXE project in Visual Basic. Form1 is created by default. Add a CommandButton to Form1. Copy the following code to the Code window of Form1: Option Explicit Private Sub Command1_Click() SendKeys "a" SendKeys "b" End Sub On the Run menu, click Start or press the F5 key to start the program. If the NumLock light is off, turn on the NumLock light by pressing the NumLock key. Click the CommandButton and note that the NumLock light turns off. Close Visual Basic and repeat the steps above; this time adding DoEvents, as follows: Private Sub Command1_Click() SendKeys "a" DoEvents SendKeys "b" End Sub Again, the first half of this failed to toggle an 'on' num lock light to off!!!! Where do I go from here? I really do need to solve this problem of sending data in this way, it must be possible, and I've replicated the process from Excel to other non Microsoft 3rd Party programs running in Windows. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggling the NUMLOCK when using SendKeys
Sorry, reread it and realized you wanted NumLock; but the same issue is true:
if you just need to send the numbers, use your code to specify that. I am not sure why else having the NumLock key "On" would affect your database unless Oracle uses it for some proprietary purpose? (I have never used Oracle). I also realized that you can indeed set Numlock or Capslock with SendKeys but I had never used that before since I have had no need for it. Sorry for the misdirection, combination of tryng to answer questions quickly on break time plus faulty brain circuits! -- - K Dales "K Dales" wrote: Is there a reason for NumLock to be on other than sending only upper case characters? If you just need to send upper case only, you can use the UCase function to convert the string to upper case when you do the SendKeys: SendKeys "1" ' Note the below has no real effect but included since you had it: SendKeys UCase("1") ' will be printed in caps For i = 0 To 10 SendKeys UCase(Chr(Asc("1") + i)) 'will be printed in caps Next 'DoEvents ' uncommenting this will print next line in smalls ' Note: DoEvents only tells Excel to pause here for a moment to allow other process to occur; it will not to anything on its own to change the CapsLock state SendKeys UCase("o") ' will be printed in caps SendKeys "o" ' Will be printed in smalls If for some reason I am not aware of it is important not only that these be caps but that the CapsLock is actually on, that would involve Windows API calls: too much info to cover here but here is a reference: http://support.microsoft.com/default...b;en-us;190000 -- - K Dales "Zakynthos" wrote: I've tried, without success, to do this in a variety of ways when attempting to send multiple SendKey commands from Excel to an Oracle-based database called 'Vantage Point' running in Windows. The code I used on a UserForm1 was as follows: (it will be obvious that I tried to adapt it from 'CAPSLOCK toggle, by the comments I left unchanged) Private Sub UserForm_Click() Private Sub Text1_Click() SendKeys "1" SendKeys "{NUMLOCK}" ' Turn on the CapsLock SendKeys "1" ' will be printed in caps For i = 0 To 10 SendKeys Chr(Asc("1") + i) 'will be printed in caps Next 'DoEvents ' uncommenting this will print next line in smalls SendKeys "o" ' will be printed in caps SendKeys "{NUMLOCK}" ' Turn off the caps lock SendKeys "o" ' Will be printed in smalls End Sub I used the following code on 'Sheet1' of my Excel workbook: Sub inputvpco() AppActivate "Maintain Queue Actuals" With ThisWorkbook.Sheets("Sheet1") SendKeys .Range("A1").Value End With End Sub If the NUM LOCK is turned off, this does not turn it back on again. I've also tried another test of this toggle using the following method (which I'm pretty sure I followed correctly) Start a new Standard EXE project in Visual Basic. Form1 is created by default. Add a CommandButton to Form1. Copy the following code to the Code window of Form1: Option Explicit Private Sub Command1_Click() SendKeys "a" SendKeys "b" End Sub On the Run menu, click Start or press the F5 key to start the program. If the NumLock light is off, turn on the NumLock light by pressing the NumLock key. Click the CommandButton and note that the NumLock light turns off. Close Visual Basic and repeat the steps above; this time adding DoEvents, as follows: Private Sub Command1_Click() SendKeys "a" DoEvents SendKeys "b" End Sub Again, the first half of this failed to toggle an 'on' num lock light to off!!!! Where do I go from here? I really do need to solve this problem of sending data in this way, it must be possible, and I've replicated the process from Excel to other non Microsoft 3rd Party programs running in Windows. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggling the NUMLOCK when using SendKeys
Try using (eg)
SendKeys "1", True second parameter means wait until the keystrokes have been processed. -- Tim Williams Palo Alto, CA "Zakynthos" wrote in message ... I've tried, without success, to do this in a variety of ways when attempting to send multiple SendKey commands from Excel to an Oracle-based database called 'Vantage Point' running in Windows. The code I used on a UserForm1 was as follows: (it will be obvious that I tried to adapt it from 'CAPSLOCK toggle, by the comments I left unchanged) Private Sub UserForm_Click() Private Sub Text1_Click() SendKeys "1" SendKeys "{NUMLOCK}" ' Turn on the CapsLock SendKeys "1" ' will be printed in caps For i = 0 To 10 SendKeys Chr(Asc("1") + i) 'will be printed in caps Next 'DoEvents ' uncommenting this will print next line in smalls SendKeys "o" ' will be printed in caps SendKeys "{NUMLOCK}" ' Turn off the caps lock SendKeys "o" ' Will be printed in smalls End Sub I used the following code on 'Sheet1' of my Excel workbook: Sub inputvpco() AppActivate "Maintain Queue Actuals" With ThisWorkbook.Sheets("Sheet1") SendKeys .Range("A1").Value End With End Sub If the NUM LOCK is turned off, this does not turn it back on again. I've also tried another test of this toggle using the following method (which I'm pretty sure I followed correctly) Start a new Standard EXE project in Visual Basic. Form1 is created by default. Add a CommandButton to Form1. Copy the following code to the Code window of Form1: Option Explicit Private Sub Command1_Click() SendKeys "a" SendKeys "b" End Sub On the Run menu, click Start or press the F5 key to start the program. If the NumLock light is off, turn on the NumLock light by pressing the NumLock key. Click the CommandButton and note that the NumLock light turns off. Close Visual Basic and repeat the steps above; this time adding DoEvents, as follows: Private Sub Command1_Click() SendKeys "a" DoEvents SendKeys "b" End Sub Again, the first half of this failed to toggle an 'on' num lock light to off!!!! Where do I go from here? I really do need to solve this problem of sending data in this way, it must be possible, and I've replicated the process from Excel to other non Microsoft 3rd Party programs running in Windows. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2007 is turning off numlock | Excel Discussion (Misc queries) | |||
Numlock | Excel Discussion (Misc queries) | |||
How do I get the numlock + key to display a plus instead of a v? | Setting up and Configuration of Excel | |||
Sendkeys will change the status of Numlock | Excel Programming | |||
Sendkeys and NumLock Key | Excel Programming |