Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > sendkeys not working in windows xp professional sp3

Reply
Thread Tools Display Modes

sendkeys not working in windows xp professional sp3

 
 
emrefan
Guest
Posts: n/a

 
      01-27-2011
I have a keyboard macro written in Windows Script and it was working
when I had Windows XP Professional SP2 (I have the traditional Chinese
version of XP, if that matters). After installing SP3, it stopped
working. It seems SP3 is preventing some type of keys to be sent to
applications. The following test script (NOT my original script, which
is a bit more complex) demonstrates the problem. If anyone has
Windows XP Pro + SP3, please try it out and better yet, provide a
solution / workaround.

-------------------------------------------- snip
-----------------------------------------------------------------------------------
set oShell = WScript.createObject( "WScript.Shell" )

oShell.run "notepad"
WScript.sleep 800

' Please adapt the window name in following function for your
' particular version of Windows XP:

wndFound = oShell.appActivate( "noname - notepad" )

if not wndFound then
WScript.Echo "Window not found, cannot send keys to it"
WScript.quit
end if

' Sending ctrl-o to start the Open document dialogue box does NOT
' work on XP w/ SP3:
oShell.sendKeys "^O"

WScript.sleep 100
oShell.sendKeys "sending plain text works"

--------------------------------------------- snip
---------------------------------------------------------------------
 
Reply With Quote
 
 
 
 
Tom Lavedas
Guest
Posts: n/a

 
      01-27-2011
On Jan 27, 4:19*am, emrefan <dksle...@hotmail.com> wrote:
> I have a keyboard macro written in Windows Script and it was working
> when I had Windows XP Professional SP2 (I have the traditional Chinese
> version of XP, if that matters). After installing SP3, it stopped
> working. *It seems SP3 is preventing some type of keys to be sent to
> applications. The following test script (NOT my original script, which
> is a bit more complex) demonstrates the problem. *If anyone has
> Windows XP Pro + SP3, please try it out and better yet, provide a
> solution / workaround.
>
> -------------------------------------------- snip
> -----------------------------------------------------------------------------------
> set oShell = WScript.createObject( "WScript.Shell" )
>
> oShell.run "notepad"
> WScript.sleep 800
>
> ' Please adapt the window name in following function for your
> ' particular version of Windows XP:
>
> wndFound = oShell.appActivate( "noname - notepad" )
>
> if not wndFound then
> * *WScript.Echo "Window not found, cannot send keys to it"
> * *WScript.quit
> end if
>
> ' Sending ctrl-o to start the Open document dialogue box does NOT
> ' work on XP w/ SP3:
> oShell.sendKeys "^O"
>
> WScript.sleep 100
> oShell.sendKeys "sending plain text works"
>
> --------------------------------------------- snip
> ---------------------------------------------------------------------


Try lower case letters for menu items. I don't know why things
changed, but they appear to have. The following script (which closes
the loop around locating the newly opened Notepad window) worked for
me in XPSP3.

set oShell = createObject( "WScript.Shell" )

oShell.run "notepad", 1 False

' Please adapt the window name in following function for your
' particular version of Windows XP:

For n = 1 to 10
WScript.sleep 50
wndFound = oShell.appActivate( "notepad" )
if wndFound then exit for
next

if not wndFound then
WScript.Echo "Window not found, cannot send keys to it"
WScript.quit
end if

' Sending ctrl-o to start the Open document dialogue box does NOT
' work on XP w/ SP3:
oShell.sendKeys "^o" ' lower case only

WScript.sleep 100
oShell.sendKeys "sending plain text works"

_____________________________
Tom Lavedas
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WLM 2011 Problems..back to 2010? Panic Windows Live Mail 17 01-01-2011 03:25 AM
Windows Update Error Code: 80070005 Joe Davis Windows Update 33 05-05-2010 08:03 AM
Updates were unable to be successfully installed wjousts Windows Update 6 01-30-2010 04:01 PM
Re: Disable Windows Firewall Lanwench [MVP - Exchange] Windows Small Business Server 7 01-06-2010 11:45 PM
Run Vista legally for at least one year/ Vista Activation doesn't stop Piracy Chad Harris Windows Vista Installation 56 12-25-2008 01:34 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59