Jump to content

Recommended Posts

Posted

Hi,

I am new to AutoIT, i have created my first script which is nothing much but just opening a word document and start typing few things.. The problem that i am facing is With CPU load the moment i satrted the script my CPU goes to 100% :(

Can anyone suggest me what could be the problem :(

many Thanks in Advance :

Manish

Posted

hi,

please post your source.....

without it it's hard to see whats wrong.

Andre

What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!
Posted

hi,

please post your source.....

without it it's hard to see whats wrong.

Andre

<{POST_SNAPBACK}>

Hi Andre,

Thx for replying very soon.. please find the code mentioned below

run("c:\Program Files\Microsoft Office\Office\WINWORD.EXE")

WinWaitActive("Document1 - Microsoft Word")

send("TEST DOCUMENT")

send("{ENTER}")

For $a = 5 to 1 Step -1

send("The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog")

send("{ENTER}")

Next

WinClose("Document1 - Microsoft Word")

WinWaitActive("Microsoft Word")

send("!n")

Posted

Should put the code into '['code']' you code there '['/code']' without the '

It's easier to read

<{POST_SNAPBACK}>

For $a = 5 to 1 Step -1
send("The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog")
send("{ENTER}")
Next

WinClose("Document1 - Microsoft Word")
WinWaitActive("Microsoft Word")
send("!n")
Posted (edited)

Pretty sure its because your sending so much text at the same time in one go, copy it to the clip board and then paste it. I also added a little Sleep() and changed the Run function so you can open up your word document faster and easier. I got rid of the WinWait stuff cause I don't know what the title would be lol, so you should add that back in.

Run('C:\Program Files\Microsoft Office\Office\WINWORD.EXE "TEST document.doc"')

Sleep(5000)

ClipPut("The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog")

For $A = 5 to 1 Step - 1
   Send("^v"); Not sure if this would work >> Send(ClipGet())
   Send("{ENTER}")
   Sleep(10)
Next

send("!N")
Edited by Burrup

qq

Posted

I need to create a script which will generate some keystroke so copy paste will not work.. what else can i do for reducing the cpu load

<{POST_SNAPBACK}>

gafrost gave you your answer on how to modify your original script to reduce the CPU load... but per your request, here is a script that will "generate some keystroke" and does not use much CPU time.

AutoItSetOption ("SendKeyDelay", 20)
AutoItSetOption ("WinTitleMatchMode", 2)
AutoItSetOption ("TrayIconDebug", 1)

HotKeySet ("{PAUSE}", "Terminate")

Run("notepad.exe")
WinWait("Notepad")
WinActivate("Notepad")
WinWaitActive("Notepad")

For $i = 1 to 5
   For $ii = 1 to 10
      Send("The quick brown fox jumps over the lazy dog. ")
   Next
   Send("{ENTER}")
Next

EXIT
Func Terminate()
   EXIT
EndFunc

If you want to use MS Word - then change the "Run line" and the subsequent "Win... lines" of code.

The reason for shortening this line

send("The quick brown fox jumps over the lazy dog. ")

is to allow for quick termination of the script. Hitting pause will not exit the script until the "Send line" has completed. The same is true of attempting to exit the script via the system tray icon.

What is this script for?

[size="1"][font="Arial"].[u].[/u][/font][/size]

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...