Jump to content

My first script


 Share

Recommended Posts

I tried to run the notepad script from the tutorial, but it doesn't write anything on the notepad.

I'm runing it Windows 7 ultimate x64 french version.

After that i tried to compile it and it created multiple instance of the program (approx. 50)

Here is my modified script so that normally it should work on my machine :

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.6.1
 Author:         condor666

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

Run("notepad.exe")
WinWaitActive("Sans titre - Bloc-notes")
Send("azerty")
WinClose("Bloc-notes")
WinWaitActive("Bloc-notes", "Voulez vous enregistrer les modifications de sans titre ?")
Send("!r")
Link to comment
Share on other sites

  • Moderators

Did you name your script notepad.au3 that when compiled is notepad.exe? ( that would explain why it keeps running copies of itself ).

If so, rename it to something else.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Did you name your script notepad.au3 that when compiled is notepad.exe? ( that would explain why it keeps running copies of itself ).

If so, rename it to something else.

A note should be added to the tutorial about this. It seems like a pretty commong mistake.
Link to comment
Share on other sites

A note should be added to the tutorial about this. It seems like a pretty commong mistake.

Surely it is common sense and does not need to be noted.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Surely it is common sense and does not need to be noted.

Sense, yes. Common, not quite. This exact situation keeps popping up every now and then.

The choice is between one person taking the time to review the tutorial (and possibly causing almost everyone reading it to waste 5 seconds of their lives) and aswering someone on the forum every now and then.

I'm happy either way. :)

Link to comment
Share on other sites

  • Developers

Adding notes like this will create a lengthy list of remarks which, by definition, aren't read. :)

My vote goes to try to think and understand what you are doing when you see a program being shelled over and over.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

try it like this

Run("notepad.exe")
If Not WinWait("Sans titre - Bloc-notes","",5) Then
    MsgBox(0,"Cant wait anymore","sry")
    Exit
EndIf
Sleep(100)
SendKeepActive("Sans titre - Bloc-notes")
Send("azerty")
WinClose("Sans titre - Bloc-notes")
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

try it like this

Run("notepad.exe")
If Not WinWait("Sans titre - Bloc-notes","",5) Then
    MsgBox(0,"Cant wait anymore","sry")
    Exit
EndIf
Sleep(100)
SendKeepActive("Sans titre - Bloc-notes")
Send("azerty")
WinClose("Sans titre - Bloc-notes")

i've tried and it writes nothing, but the msgbox appears and don't closes the notepad

Yes it is, i've taken a screenshot :

Posted Image

I've discovered a strange thing, now it works partially, the text is still the same but i've copied it from AutoIt Window Info.

It still doesn't close the program

Edited by condor666
Link to comment
Share on other sites

Probably some strange char in there

try to run this and it will probably tell you where is that diffrent char (ASCll Character list from help file related), post the picture of msgbox if you wona share where and if it finded some diffrance in title :)

#include <Array.au3>
Run("notepad.exe")
WinWaitActive("[CLASS:Notepad]")
$c = StringSplit("Sans titre - Bloc-notes","")
$a = StringSplit(WinGetTitle(""),"")
Dim $b[$c[0]+1][2]
For $y = 1 To $c[0]
    $c[$y] = Asc($c[$y])
    $b[$y][1] = $c[$y]
    $a[$y] = Asc($a[$y])
    $b[$y][0] = $a[$y]
Next
For $r = 0 to UBound($b,1) - 1
    If $b[$r][0] <> $b[$r][1] Then MsgBox(0,$b[$r][0]&" diffrent from "&$b[$r][1]&" pos. "&$r,"'"&Chr($b[$r][0])&"' diffrent from "&"'"&Chr($b[$r][1])&"' on position "&$r)
Next

or try to use class instead of title in your script

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Cool xD

so there is diffrance in space charecters ("ASCll Charactes" help file)

So try to use "[CLASS:Notepad]" instead of title from notepad win, and other class for your WinWaitActive("Bloc-notes", "Voulez vous enregistrer les modifications de sans titre ?"), use win info to get class (its probably "[CLASS:#32770]"), and it shud work

or try Opt("WinTitleMatchMode", 2) and instead of full win title use first 10 char-s of title

edit: (changed ASCII to ASCll in text above, misspelled it :) )

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

its WinWaitActive("[CLASS:Notepad]")

you dont have "" :)

look at the

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
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
 Share

  • Recently Browsing   0 members

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