Sign in to follow this  
Followers 0
EmptySpace

(solved)Check my code

11 posts in this topic

#1 ·  Posted (edited)

Just need some advices for future. In my code is big mess... When I try to make something I get error. In this one I have error too.

While 1
_IELinkClickByText($oIE, "text") ;every this click page refreshes
Sleep(1000)
$body = _IEBodyReadHTML($oIE)
If StringInStr($body, "Text") Then
  _IELinkClickByText($oIE, "link text")
ElseIf StringInStr($body, "other text") Then
  _IELinkClickByIndex($oIE, 3)                                      ;I want to add StringInStr even more...
ElseIf StringInStr($body, "text 2") Then
  _IENavigate($oIE, "link")
  ;------------------
  $i = 0
  Do
   $oTags = _IETagNameGetCollection($oIE, 'input')
   If Not @error Then
    For $oTag In $oTags
     If $oTag.type == 'submit' And $oTag.value == 'valuei' Then
      _IEAction($oTag, 'click')
      _IELoadWait($oIE)
      If Not @error Then ExitLoop
     EndIf
    Next
   EndIf
   $i = $i + 1
  Until $i = 30
  ;--------------------------------------
EndIf
Next              ; too much something here. When I remove, I get error...
EndIf
WEnd
Edited by Edgaras

Share this post


Link to post
Share on other sites



sirfearless,

When I try to make something I get error

And so do the rest of us - all the time! ;)

I suggest you download SciTE4AutoIt3 from here and install it. You then get lots of extra utilities to help you code more efficiently in AutoIt. One of these is Tidy which nicely formats your code and, among other things, lets you know if you have missing loop elements. When I run your code above through Tidy I get this:

While 1
    _IELinkClickByText($oIE, "text") ;every this click page refreshes
    Sleep(1000)
    $body = _IEBodyReadHTML($oIE)
    If StringInStr($body, "Text") Then
        _IELinkClickByText($oIE, "link text")
    ElseIf StringInStr($body, "other text") Then
        _IELinkClickByIndex($oIE, 3) ;I want to add StringInStr even more...
    ElseIf StringInStr($body, "text 2") Then
        _IENavigate($oIE, "link")
        ;------------------
        $i = 0
        Do
            $oTags = _IETagNameGetCollection($oIE, 'input')
            If Not @error Then
                For $oTag In $oTags
                    If $oTag.type == 'submit' And $oTag.value == 'valuei' Then
                        _IEAction($oTag, 'click')
                        _IELoadWait($oIE)
                        If Not @error Then ExitLoop
                    EndIf
                Next
            EndIf
            $i = $i + 1
        Until $i = 30
        ;--------------------------------------
    EndIf
;### Tidy Error -> "next" is closing previous "while" on line 1
Next ; too much something here. When I remove, I get error...
;### Tidy Error: next line creates a negative tablevel.
;### Tidy Error: next line creates a negative tablevel for the line after it.
EndIf
;### Tidy Error: next line creates a negative tablevel.
;### Tidy Error: next line creates a negative tablevel for the line after it.
WEnd

So you can see at once that you have a Next and and EndIf too many. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Woooo.... I have SciTE4AutoIt3 already. Used tidy but got other errors lol... Anyway I will find my solution somehow... Going to spend few hrs on reading examples. I just need few advices how I can make my script better. Maybe I should learn functions?

Edited by sirfearless

Share this post


Link to post
Share on other sites

sirfearless,

Maybe I should learn functions?

That would be an excellent idea. Have you read the excellent AutoIt tutorials that you will find here and here? They will help you a lot. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks for links and for fast reply :)

Share this post


Link to post
Share on other sites

@sirfearless - when I became aware of AutoIt several years ago, one of the first things I did was read the Help file. You should browse thru it at least; come to be familiar with the AutoIt native functions and what they do, know what AutoIt can do. Then read thru the Help file again. Don't forget about the tutorials M23 has mentioned. Good luck with your projects. :)


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

I have one question, didnt wanted to create new topic. Its possible to make code to work when for example IE window is closed? Process would be open but without showing browser window?

Share this post


Link to post
Share on other sites

Its possible to make code to work when for example IE window is closed?

If you mean minimized then yes.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Not minimized... Closed. Like you cant find it anywhere in deskop. You can only see it in working processes.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Then see the WinSetState() function, with the @SW_HIDE parameter.

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Also its possible to make script to work in IE tabs? Like you make 3tabs and diffrent scripts work on it?

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