Jump to content

AutoIT questions


kaje_ovo

Recommended Posts

How can I get %SYSTEMDRIVE%

Well when I wanna copy some file I wanna make it %SYSTEMDRIVE% or %PROGRAMFILES%

I dont wanna make it C: or D: i dont wanna FIX it.! I wanna to be in systemdrive.!

I sow FileCopy but I doesent have %PROGRAMFILES%.

I wanna that some Batch Commandes.!!!

How Can I do that.!

e.g. File BLA.txt

FileCopy ("BLA.txt", "%PROGRAMFILES%\Here\" [, 1])

Link to comment
Share on other sites


Yes I look them all.! Thank you.!

But now when I sow posibilites I go little further and I need some new things and questions.!

----

Do I need to have Installed AutoIT on Computer if I wanna Run from Compiled AutoIT .EXE

What If I wanna install on another computer and that computer doesent have AutoIT.! Will it work.!

---

How can I take some word from some NOTEPAD or Oether .EXE file and paste it in looking app.!

Something like.!

GetStringFrom_NOTEPAD or oether app

PasteStringTo_APP

---

Well there I dont know what number will be written. Let's name it $i

WinWaitActive("Here is number it can be from 0 to 30 like in TRIAL apps")

Concrete

WinWaitActive("Application days let say 11 remains")

Well I dont know what number will be here.! And how can I make some LOOP to make it if number is from 0 to 30

Link to comment
Share on other sites

Do I need to have Installed AutoIT on Computer if I wanna Run from Compiled AutoIT .EXE

What If I wanna install on another computer and that computer doesent have AutoIT.! Will it work.!

Compiled scripts = No

Uncompiled Au3 = Requires just the interpreter AutoIt3.exe. Installing AutoIt sets up a good environment for full system usage.

How can I take some word from some NOTEPAD or Oether .EXE file and paste it in looking app.!

Something like.!

GetStringFrom_NOTEPAD or oether app

PasteStringTo_APP

ControlGetText() to get text and ControlSetText to paste it.

Well there I dont know what number will be written. Let's name it $i

WinWaitActive("Here is number it can be from 0 to 30 like in TRIAL apps")

Concrete

WinWaitActive("Application days let say 11 remains")

Well I dont know what number will be here.! And how can I make some LOOP to make it if number is from 0 to 30

You can take off from the right side of the string.

WinWaitActive("Application days let say")

Place this in your script to allow Environment variables to be used like you would in a batch file. ;)

Opt("ExpandEnvStrings", 1)

Bugged feature in AutoIt 3.1.1 and it will fail. I would not use this feature unless it was totally necessary and I would use the AutoIt beta (bug fixed) if I did use it. AutoIt macro's are recommended where suitable.

Link to comment
Share on other sites

From where AutoIT gets it's template. So I can add few lines into AutoIT new script template.!

----

Formated text like this

-----

Line One

This Line I Need

----

Then I make TAB and Select text

When I make

$var = ControlCommand ( "Key", "", "Edit1", "GetSelected", "" )

.

.

ControlCommand ( "Untitled -", "", "Edit1", "EditPaste", "" & $var )

It Paste into Notepad "Line One"

But I need "Not This Line I need"

Edited by kaje_ovo
Link to comment
Share on other sites

Run("TEST.exe")

WinWaitActive("TEST", "testing")

Send("{BS 8}")

Send(@ScriptName)

Send("{TAB}")

Send("{ENTER}")

$text = WinGetText ( "TEST", "" )

WinClose("TEST")

Run("notepad.exe")

WinWaitActive("Untitled")

Send( $text )

Send("!e")

Send("{g}")

Send("{2}{ENTER}")

Send("{SHIFTDOWN}{END}")

Send("{SHIFTUP}")

Send("{CTRLDOWN}{C}")

Send("{CTRLUP}")

Send("{END}")

Send("{ENTER}")

Send("{CTRLDOWN}{V}")

Send("{CTRLUP}")

-----------

Well Like this i Went into second line and Copy it.!

How can I take from buffer that line and put it into let say $keyvar

and that it can be longer than 100 characters

I manage it with

Send($text, 1)

----------------------------

Second.!

How can I make that Script is take control.! So when It's installing then user cant do nothing.! I'll installing never mind if it's Active.!

Or that it's always on top:!

Edited by kaje_ovo
Link to comment
Share on other sites

I make it like this.! But $var is too short.!

How can I make it bigger.! It have 80 chars

AutoItSetOption("SendKeyDelay", 50)

Run("TEST.exe")
WinWaitActive("TEST")
Send("{BS 8}")
Send("TESTKEY")
Send("{TAB}")
Send("{ENTER}")
Send("{TAB 2}")
$text = WinGetText("TEST", "")
WinClose("TEST")

Run("notepad.exe")
WinWaitActive("Untitled")
Send($text)
Send("!e")
Send("{G}")
Send("2") ; GO TO SECOND LINE IN NOTEPAD
Send("{ENTER}")

Send("{SHIFTDOWN}{END}")
Send("{SHIFTUP}")
Send("{CTRLDOWN}{C}") ; GET KEY INTO CLIPBOARD
$ActKey = ClipGet() ; PASTE KEY INTO VARIABLE
Send("{CTRLUP}")
Send("{ENTER}")

WinClose("Untitled")
WinWaitActive("Notepad", "The text in the Untitled file has changed")
Send("!n")

But $ActKey is too short by default.! How can I make it bigger.!

-----------

OK.! I sole this problem like

DIM $text[81]

and when sending I dont send

Send($text)

But I send

Send($text, 1)

Bacuse It have special chars.!

Same thing with $ActKey

Edited by kaje_ovo
Link to comment
Share on other sites

Ok, got a couple of questions of my own:

1. I'm rather well versed in VBscript and even though I have done a little bit of AutoIt here and there, I'm still somewhat of a noob in AutoIt. In VBscript I like to do things in subroutines whenever possible. This makes it easy to cut and paste code from one script to the next and it also makes it easy to disable entire sections of a script when testing things out. Does AutoIt have subroutines? Or are functions the closest thing I'm gonna get?

2. When using AutoIt to interact with applications, sometimes there are two or more possibilities as to what dialog box will pop up next. Example: An application will run in one fashion if there is an internet connection, and in an entirely different way if there is not. For instance you might get a particular dialog box warning that there is no internet connection available. What is an efficient manner of coding "if this dialog box appears next do this, otherwise do this instead."

Link to comment
Share on other sites

1. I'm rather well versed in VBscript and even though I have done a little bit of AutoIt here and there, I'm still somewhat of a noob in AutoIt. In VBscript I like to do things in subroutines whenever possible. This makes it easy to cut and paste code from one script to the next and it also makes it easy to disable entire sections of a script when testing things out. Does AutoIt have subroutines? Or are functions the closest thing I'm gonna get?

Your using AutoItX right? This means you are still working from a VBScript environment. AFAIK, AutoIt (user defined) functions do not exist in a VBScript with AutoItX used. This would mean that you would use your functions and subroutines native to VBScript.

The standalone version of AutoIt has only (ud) functions. These (ud) functions are not an exact equivalent to VBScript functions, so the need for subroutines has not been created. You can comment a function call in AutoIt so the function will not run for testing. While AutoIt is based or similar to VBSript, the developers do look at other languages to add improved functionality. I think you may find the AutoIt (ud) functions are more versitile then to VBScript functions. They need to be better as for no subroutine support. We are talking about 2 different breeds of animal here and you need how to learn how to work with either of them separately.

2. When using AutoIt to interact with applications, sometimes there are two or more possibilities as to what dialog box will pop up next. Example: An application will run in one fashion if there is an internet connection, and in an entirely different way if there is not. For instance you might get a particular dialog box warning that there is no internet connection available. What is an efficient manner of coding "if this dialog box appears next do this, otherwise do this instead."

The standalone version of AutoIt has functions called AdlibEnable and AdlibDisable. AdlibEnable can be set so it will call a (ud) function every set amount of time. You would use *Exists functions to detect and react accordingly to these possible events. AdlibDisable simply turns off AdlibEnable when required to save resources.

Here is a basic example:

Run(@ScriptDir & '\program.exe')

WinWait('title1', 'test1')
ControlClick('title1', 'text1', 'button1')

; Window title may show here called 'Connect to Internet'
; Turn on Adlib and use _Adlib() function for the scanning.
AdlibEnable('_Adlib')

WinWait('title2', 'text')
ControlClick('title2', 'text', 'button1')

; Save cpu so we turn off Adlib here.
AdlibDisable()

WinWait('title3', 'text')
ControlClick('title3', 'text', 'button1')

Func _Adlib()
If WinExists('Connect to Internet') Then
ControlClick('Connect to Internet', '', 'Button2')
EndIf
EndFunc

I do not see any Adlib functionality in AutoItX. You may need to use a temporary loop to check for the unexpected window. You could also as refering to the example above without Adlib in mind, turn WinWaits into WinExists functions and have them inside a big loop. The big loop would also have the unexpected windows in them also.

Edit: Pepair code indent only

Edited by MHz
Link to comment
Share on other sites

I actually do a bit of all three types of scripting - pure VBS, VBS w/ AutoItX, and pure AutoIt. I've found circumstances when any of three are most appropriate believe it or not. What I was really asking about was pure standalone AutoIt and you provided just what I was looking for :thumbup

I have gone into the AutoIt forums searching for answers, but in all honesty the majoriy of discussion there seems way over my head. Most of what I've learned in VBS has come from trial and error but also four different books on the topic. I really wish there was the same offering in publications for AutoIt. That way I wouldn't have to keep on pestering you guys ;)

Thanks for the help!

Link to comment
Share on other sites

All 3 types, hmm, smart person. ;)

AutoIt forum try to help but i have a common interest in UA Windows like you so I can answer at a better level to help you. I have learnt most of AutoIt by trial and error. The helpfile is concise and brief, but you still may need to test the functions to get the overall understanding of them. It comes with time to master them, but it cones along. Pestering?, well that is what forums are for. Sometimes people just like to help, so pest is an unknown word unless you become a nuisence of wasting peoples time, but i see that you are not a nuisence. ;)

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

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