+ Reply to Thread
Results 1 to 22 of 22

Windows 7 and Send Keys not working

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Thumbs down Windows 7 and Send Keys not working

    Send Keys does not work in Windows 7 by default.

    Does anyone know the solution to any of the following:
    1. Is there a way to programatically re-enable Send Keys?
    2. Failing that, is there an alternative to Send Keys that achieves the same result?
    3. Failing 1 & 2, is there a way to determine if the Windows OS is Win 7 so it can exit the macro instead of coming to a halt at the send keys command?
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,767

    Re: Windows 7 and Send Keys not working

    Using sendkey with which application? Because in my experience sendkey wont worked with Notepad even in xp too...

    Make use of Application.OperatingSystem with instr combination to check 32 and 64 bit for your question #3. Since I am an XP user I cant test and provide the code


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Windows 7 and Send Keys not working

    Send Keys does not work in Windows 7 by default.
    please clarify what you mean by that
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Windows 7 and Send Keys not working

    Quote Originally Posted by :) Sixthsense :) View Post
    Using sendkey with which application? Because in my experience sendkey wont worked with Notepad even in xp too...
    I should have specified. I meant Send Keys in Excel. Not intending to use Send Keys without external applications.

    Quote Originally Posted by :) Sixthsense :) View Post
    Make use of Application.OperatingSystem with instr combination to check 32 and 64 bit for your question #3. Since I am an XP user I cant test and provide the code
    Thanks. I have come up with two functions for this. (I could have done it as one function but I may have a use for the Windows version function later on).

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Windows 7 and Send Keys not working

    Quote Originally Posted by JosephP View Post
    please clarify what you mean by that
    Correct me if I am wrong but I understand that Windows 7 has UAC enabled by default and UAC prevents "Send Keys" from running.

  6. #6
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Windows 7 and Send Keys not working

    BTW this is the code I am trying to run Send Keys on (I found it on the net).

    Please Login or Register  to view this content.
    It also requires use of this function (can post in same or different module, it doesn't matter)
    Please Login or Register  to view this content.
    Last edited by mc84excel; 04-09-2013 at 10:27 PM. Reason: Overlooked including function required by sub posted

  7. #7
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Windows 7 and Send Keys not working

    UPDATE: In relation to question 2 (is there an alternative to Send Keys that achieves the same result?), I have just found the following: http://www.jack-frost.co.uk/vb6_sendkeys_vista.html

    I haven't tested it yet though.

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Windows 7 and Send Keys not working

    sendkeys works for me in 7 with uac on although it does toggle numlock similar to an old bug it always had

  9. #9
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Windows 7 and Send Keys not working

    Quote Originally Posted by JosephP View Post
    sendkeys works for me in 7 with uac on
    I can't understand it. It works me sometimes, other times it just stops at the Add-In manager list (refer code in earlier post). No idea why it does this.

    Quote Originally Posted by JosephP View Post
    although it does toggle numlock similar to an old bug it always had
    This is wandering off the thread topic slightly but just quickly - I know exactly what you mean. It really bugs me that the numlock key keeps getting turned off.
    It is a bug acknowledged by MS (see http://support.microsoft.com/default...b;en-us;179987 )
    From the link above, it appears to be triggered by Excel executing 2x Send Key statements in a row.
    I have found various solutions over the net but most of these either didn't work for me or involved API calls (I try to avoid API due to compatibility issues between 32 bit & 64 bit Excel)
    I eventually found a numlock key solution that worked without API (although it does rely on a windows dll ). See the code posted by Kenneth Hobson in this thread: http://www.mrexcel.com/forum/excel-q...mber-lock.html
    (Something strange with that solution though - I have to run the NUM_On to turn numlock off and run NUM_Off to turn numlock on. Maybe it's just this keyboard. )
    Last edited by mc84excel; 04-09-2013 at 07:33 PM.

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Windows 7 and Send Keys not working

    why don't you just give the user instructions how to remove the old add-in? there is a point of rapidly diminishing returns in coding and I think you're going past it ;-)

  11. #11
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Windows 7 and Send Keys not working

    Quote Originally Posted by JosephP View Post
    why don't you just give the user instructions how to remove the old add-in?
    Because I have two practical scenarios for this:
    1. I would be the main user as I frequently have dud add-in entries in my add-in list. (Due to automatic updater on a few personal add-ins) So yes I know how to remove old add-ins but I am lazy. So automation is the way to go!
    2. I have a certain tool designed for a small group of users but these users never learnt VBA (I've checked) and they struggle to even install an add-in.

    Quote Originally Posted by JosephP View Post
    there is a point of rapidly diminishing returns in coding and I think you're going past it ;-)
    Well you are entitled to your opinion
    IMO coding shines when it reduces (or if possible - removes) the need to manually do small mundane tasks.
    I would consider removing dead add-in links to fit into this category.

  12. #12
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Windows 7 and Send Keys not working

    The JackFrost solution (link in post #7) seems to be working for me so far, so I will mark this thread as solved.

  13. #13
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Windows 7 and Send Keys not working

    clearly I disagree. code shines for repetitive and/or frequent tasks. this shouldn't typically be either-updating an add-in should not leave dud entries behind in my opinion because that add-in name should not change and it should always be in the add-in folder (or on a network) so all you need to do is overwrite the file

  14. #14
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Windows 7 and Send Keys not working

    @ All: I think I gave the wrong impression in Post #11. I apologise. For the record, I would like to state that I hold JosephPs Excel skills in high regard.


    @ JosephP:
    Quote Originally Posted by JosephP View Post
    updating an add-in should not leave dud entries behind in my opinion because that add-in name should not change and it should always be in the add-in folder (or on a network) so all you need to do is overwrite the file
    I have two practical reasons not to. I will PM you as to the logic on this.

  15. #15
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Windows 7 and Send Keys not working

    I am marking this thread as unsolved because I have proven the JackFrost solution is not working for me.

    Does anybody have a solution to either:
    1. Enable Send Keys in Excel with Windows 7 UAC enabled?
    2. OR Have an alternative to SendKeys in Excel (other than the JackFrost solution)

    (If you think I am wasting my time on this idea, please PM me rather than posting in the thread).

  16. #16
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Windows 7 and Send Keys not working

    Have you looked at Windows API?
    If posting code please use code tags, see here.

  17. #17
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Windows 7 and Send Keys not working

    Quote Originally Posted by Norie View Post
    Have you looked at Windows API?
    No, not yet. (I have only ever had bad experiences with API & VBA ) Still, I will look at soon.

  18. #18
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Windows 7 and Send Keys not working

    UPDATE: Although there are known issues with Excel use of SendKeys on Windows 7 OS, I am now thinking that my issue is relating to the AddIn Manager List not the SendKeys code.

    I say this because the code in question works most times, it only plays up every now and then. Furthermore, when it does 'hang', it only does it when the code was fired on Workbook_Open, never on Workbook_BeforeClose. The significance of this difference is that Workbook_BeforeClose always has a visible open workbook (whereas the WorkBook_Open code fires before any workbook is visible) and AddIn Manager List plays up if there is no workbook visible. (This is why I put code to add a workbook if there was no visible workbooks but if my theory is right, why is it complaining?)

    If my theory is right, I have the following solutions to try:
    • Remove the call from Workbook_Open (I really only need it after I programatically delete an outdated add-in - which fires on Workbook_BeforeClose)
    • Add a fix to the 'hang' issue by using SendKeys to send an "Enter" button press
    • Add a name to the temp workbook created (line 20) so I can specifically close that workbook later on (line 200)

    Code below. Could somebody please provide code for points 2 and/or 3 above? Thank you.

    Please Login or Register  to view this content.

  19. #19
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Windows 7 and Send Keys not working

    No solutions to bullet points 2 & 3 in post 18?

    UPDATE 1: I confirm that the keyboard is responsible for the reversal of the NumLock On/Off code. (Tested the code on a laptop with two different keyboards. HP keyboard reverses the behavior of the NumLock On/Off code. Microsoft Keyboard works fine). (Thoughts: I don't suppose it would be possible for VBA to determine which keyboard is attached? Otherwise I could replace the On/Off call with NumLock toggle)

    UPDATE 2: I have further narrowed my SendKeys problem. My current code works fine on all workbooks except one particular XLSM. I just need to find out what is causing the interference.

  20. #20
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Windows 7 and Send Keys not working

    Ignore UPDATE 2 in the previous post.

    The problem occurred in different workbooks. The only similarity between them was the use of the CleanAddinList code on Workbook Open.

    I removed it from firing on Workbook Open event and the problem stopped.

    The thread is unsolved (because I never found out why this code played up occasionally and only on WB open) but I will close the thread as I am no longer interested in the solution.

  21. #21
    Registered User
    Join Date
    01-02-2014
    Location
    istabn
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Windows 7 and Send Keys not working

    Im using sendkey function, its always working on notepad or another screens. but it doesnt work on a Java screen. Actually on Java screen working too, but just key combination is not working. for example TAB,ENTER,a,b,c all working, but Alt+M or another combination is not working.
    Another computer, same OS same Java screen , all of them working. but on this computer key combination is not working on Java screen.
    who can help me, its urgent.
    thank you very much

  22. #22
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,811

    Re: Windows 7 and Send Keys not working

    @deneme82

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1