AppActivate problem
-
Here is my code
Shell("C:\Windows\Notepad.exe") AppActivate("Sans titre - Bloc-notes") 'French computer ^^ SendKeys("test")
Doesn't work. I get an error on the AppActivate line Please help Thanks ~MichaelOK. First, it helps if you supplied what the error was. Without that, we just speculating as to what is wrong. What your doing is problematic at best. If the system launches another app or dialog, or the user clicks anywhere between the time the AppActivate and SendKeys statements are run, (and, YES it DOES happen!), your keystroke will end up going to another application. Now... At first glance, the title of the application your activating doesn't match the title of any window. What you can do in place of the title is use the TaskID that is returned by the Shell function and use that in the AppActivate statement. On top of that, when you launched Notepad, it was launched, by default, minimized. To correct that:
Dim taskID as Long
taskID = Shell("C:\Windows\Notepad.exe", vbNormalFocus)
AppActivate taskID
SendKeys "test", TrueRageInTheMachine9532
-
OK. First, it helps if you supplied what the error was. Without that, we just speculating as to what is wrong. What your doing is problematic at best. If the system launches another app or dialog, or the user clicks anywhere between the time the AppActivate and SendKeys statements are run, (and, YES it DOES happen!), your keystroke will end up going to another application. Now... At first glance, the title of the application your activating doesn't match the title of any window. What you can do in place of the title is use the TaskID that is returned by the Shell function and use that in the AppActivate statement. On top of that, when you launched Notepad, it was launched, by default, minimized. To correct that:
Dim taskID as Long
taskID = Shell("C:\Windows\Notepad.exe", vbNormalFocus)
AppActivate taskID
SendKeys "test", TrueRageInTheMachine9532