Sign in to follow this  
Followers 0
KingO

Stepping Through Autoit Code

6 posts in this topic

Hello:

I'm self taught & fairly proficient at writing VB code in Excel and have found the ability to "step" through the code in VB editor to be an immense learning/ debugging tool. Basically you can hit F8 and step through the code line by line so that it is possible to watch what the code is doing (in excel in this case) line by line. You can also select a line of code and press ctl-F8 and have the code run to the cursor (nice for getting past loops).

My question is how do I do this using sciTE for autoIT scripting or is this possible using some other editor for autoIT?

I'm trying to figure out how DaleHolm has done what he's done in the below example because I have a similar situation in something I'm trying to use autoIt to automate. In other words I have to access an in-house system (html interface, accessing an oracle database) and need to click on checkboxes &/or boxes that show no contol i.d. using AU3INF.exe. I've printed out IE.au3 and read through the descriptions of the relevant IE functions, but I'm still not getting it.

This example opens the AutoIt forum search page and toggles the sortby radiobuttons. An identical technique can be used with checkboxes.

#include <IE.au3>

$oIE = _IECreate()

_IENavigate($oIE, "http://www.autoitscript.com/forum/index.php?act=Search&f=")

$oFrom = _IEFormGetObjByName($oIE, "sForm")

$oRelevant = _IEFormElementGetObjByName($oFrom, "sortby", 0)

$oRecent = _IEFormElementGetObjByName($oFrom, "sortby", 1)

For $i = 1 to 5

$oRelevant.checked = True

Sleep(1000)

$oRecent.checked = True

Sleep(1000)

Next

http://www.autoitscript.com/forum/index.ph...opic=13398&st=0

some very helpful VB editor debug commands:

step into F8

step over

step out

run to cursor ctl-F8

Thanks!

Share this post


Link to post
Share on other sites



Try viewing the source of your webpage and look for <form name="this vaule is what you are looking for">. The example you showed targets a form with the name "sForm". I provided a piece of the source from that example to help you understand what to look for.

<form action="http://www.autoitscript.com/forum/index.php?act=Search&CODE=simpleresults&mode=simple" method="post" name="sForm">

Share this post


Link to post
Share on other sites

Hello:

I'm self taught & fairly proficient at writing VB code in Excel and have found the ability to "step" through the code in VB editor to be an immense learning/ debugging tool. Basically you can hit F8 and step through the code line by line so that it is possible to watch what the code is doing (in excel in this case) line by line. You can also select a line of code and press ctl-F8 and have the code run to the cursor (nice for getting past loops).

My question is how do I do this using sciTE for autoIT scripting or is this possible using some other editor for autoIT?

I'm trying to figure out how DaleHolm has done what he's done in the below example because I have a similar situation in something I'm trying to use autoIt to automate. In other words I have to access an in-house system (html interface, accessing an oracle database) and need to click on checkboxes &/or boxes that show no contol i.d. using AU3INF.exe. I've printed out IE.au3 and read through the descriptions of the relevant IE functions, but I'm still not getting it.

This example opens the AutoIt forum search page and toggles the sortby radiobuttons. An identical technique can be used with checkboxes.

#include <IE.au3>

$oIE = _IECreate()

_IENavigate($oIE, "http://www.autoitscript.com/forum/index.php?act=Search&f=")

$oFrom = _IEFormGetObjByName($oIE, "sForm")

$oRelevant = _IEFormElementGetObjByName($oFrom, "sortby", 0)

$oRecent = _IEFormElementGetObjByName($oFrom, "sortby", 1)

For $i = 1 to 5

$oRelevant.checked = True

Sleep(1000)

$oRecent.checked = True

Sleep(1000)

Next

http://www.autoitscript.com/forum/index.ph...opic=13398&st=0

some very helpful VB editor debug commands:

step into F8

step over

step out

run to cursor ctl-F8

Thanks!

first off, welcome to the forum. VB was one of my first languages too, and i can empathize that at first debugging scripts seems like more work. There are alot of ways to debug in SciTE though. here are a few things you can do to help track your script and your values during execution.

Opt("TrayIconDebug",1)
; the above line allows you to hover your mouse over the script's icon in the systray
; and see the line currently being interpretted at that time.  good for identifying loops
; that you may have set an invalid exit condition for.
Msgbox(0,"Value of", $variable)
; message boxes can be immeasurably helpful for tracking a value per iteration, 
; or just notifying you of the progress of your script during the debugging phase.
ConsoleWrite(@lf & $variable & " : Variable" & @lf)
;when you're running code from scite, that line sends information to the console window
;allowing you to see the same information you could have in a message box, without delaying 
;the script with an interrupting message box
ToolTip($variable)
; creates a tooltip at your mouse position, with whatever information you'd like.
; this is good when your script activates other windows and you can't keep an eye on the
; scite console.  i frequently use this for checking mouse colors, tracking counters, or
; just letting myself know exactly where i am in the script.

in scite's tools menu, there are alot of debugging and tracing options there so that you usually don't have to even write the lines above yourself (although i typically do so that i get exactly what i want formatted the way i want it) . also in scripts and scraps, i remember about 2 weeks ago (maybe 3?) someone also made an additional debugging tool, it looked like it may allow selecting execution similar to stepping, but i really didn't check it out very much.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

sorry, i went off on a debugging rant, and didn't address the explanation you were looking for...

#include <IE.au3>

that line allows you to call the functions in the ie.au3 file as if they were part of your script.

$oIE = _IECreate()

that function creates an instance of internet explorer, and assigns that instance a name you can use to reference that object.

_IENavigate($oIE, "http://www.autoitscript.com/forum/index.php?act=Search&f=")

that function tells the named instance of IE to navigate to the page indicated

$oFrom = _IEFormGetObjByName($oIE, "sForm")

here he grabs the form object by name. in order to figure out the name, you'd just look for a name property in the source code of the page you intend to interact with.

$oRelevant = _IEFormElementGetObjByName($oFrom, "sortby", 0)

this line is to create a reference to an element of the form. again the name he's using to get the object by name, "sortby", comes from the source of the page, it's not just an arbitrary name. alot of times if there are more than one checkbox or radio button, they will have the same name. in that case you could also use _IEFormElementGetObjByIndex(). here dale is using the '0' parameter to indicate that it is the first object with that name.

$oRecent = _IEFormElementGetObjByName($oFrom, "sortby", 1)

the "1" here specifies the second object with the same name

For $i = 1 to 5
    $oRelevant.checked = True
    Sleep(1000)
    $oRecent.checked = True
    Sleep(1000)
Next

this loop just alternates the selection between the two checkboxes, but setting the .checked property of each, then waiting a second...


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Thank you cameronsdad!

I especially appreciated your code commentary.

This is a really powerful program.

:)

Share this post


Link to post
Share on other sites

Thank you cameronsdad!

I especially appreciated your code commentary.

This is a really powerful program.

:)

no problem man, always glad to help. for help getting started, i'd also suggest checking out Val's new user guide; it's got alot of good advice in there.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

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
Sign in to follow this  
Followers 0