Bob23

Command Mode Scripts

2 posts in this topic

#1 ·  Posted

This evening I installed AutoIt then tried creating and running a script to simply initiate command mode and enter dir.

My script (below) enters command mode fine but does not enter dir.  Would someone out there please run my

script then let me know if able to enter cmd mode AND enter dir ?  What am I not doing?  (My o/s is Win7x64.)

 

#include <Constants.au3>

; Run cmd.exe
Run("cmd.exe")

Sleep(2000)
WinWaitActive("[CLASS:cmd]")
Sleep(2000)

; Once in command mode execute dir
Send("dir{ENTER}")

Can someone please tell me why my script fails to enter dir to show files in directory?

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Autoit comes with "AutoIt v3 Window Info" use it to get window information :)

When using the finder tool on the command prompt i got this information:

>>>> Window <<<<
Title:  Administrator: C:\Windows\system32\cmd.exe
Class:  ConsoleWindowClass
Position:   175, 175
Size:   677, 342
Style:  0x14EF0000
ExStyle:    0x00040310
Handle: 0x0000000000201708

So the class you need is "ConsoleWindowClass"

Here's you script with that changed and no sleep:

; Run cmd.exe
Run("cmd.exe")

WinWaitActive("[CLASS:ConsoleWindowClass]")

; Once in command mode execute dir
Send("dir{ENTER}")

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now