Computer Hope

Microsoft => Microsoft DOS => Topic started by: kamak on July 25, 2008, 08:13:35 AM

Title: Wscript/cscript help
Post by: kamak on July 25, 2008, 08:13:35 AM
Hi all!

I have a small question:

How would i go about automating mouse clicks sing a .vbs file?

I know that the following saves a notepad file, but how can i use the same language and method to make the mouse click?

Code: [Select]
set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 10
WshShell.AppActivate "wordola.txt"
WScript.Sleep 10
WshShell.SendKeys "%"
WScript.Sleep 0.1
WshShell.SendKeys "{DOWN}"
WScript.Sleep 0.1
WshShell.SendKeys "{DOWN}"
WScript.Sleep 0.1
WshShell.SendKeys "{DOWN}"
WScript.Sleep 0.1
WshShell.SendKeys "~"
WScript.Sleep 10

Thanks in Advance,

kamak
Title: Re: Wscript/cscript help
Post by: diablo416 on July 25, 2008, 08:25:18 AM
you can read more here http://msdn.microsoft.com/en-us/library/aa922603.aspx
Title: Re: Wscript/cscript help
Post by: kamak on July 25, 2008, 08:43:43 AM
you can read more here http://msdn.microsoft.com/en-us/library/aa922603.aspx

How would i implement that into a .vbs file like my example above?
Title: Re: Wscript/cscript help
Post by: Sidewinder on July 25, 2008, 12:18:30 PM
Quote
How would i implement that into a .vbs file like my example above?

You probably wouldn't unless you've gone mobile!

Consider which control has focus; then consider how many times you have to hit the tab key to give the control in question focus. Once the the control has focus, send the enter key (same as a mouse click in this context).

Microsoft might have had a great editor if they'd made notepad scriptable. Instead only the clunky sendkeys method seems to work. You can make menu choices with sendkeys by using alt+underline letter (atl-f for file or alt+e for edit etc) to grab the menu, or use the menu shortcuts to do things like save (ctl-s) or paste (ctl-v), etc.

Are you sure the WshShell.AppActivate "wordola.txt" is correct? That does not appear to be the window title for notepad.

 8)