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
|