Sign in to follow this  
Followers 0
zasxes

How can I speed up this Func?

10 posts in this topic

This function basically waits until the FooterPage loads on a website then checks if certain objects exist. If they do it then disables them one way or another. The reason I do not simply have the .id spelled out is because in some cases it is dynamicly generated. The problem with the function is that it can be slow at times and you can beat it to the objects and use them before I disable them. If possible I would like to speed this process up or find a way to ensure the objects cannot be used until after this function sets them to "SafeMode = 1". Anyt thoughts would be helpful.

Func IEEvent_FrameNavigateComplete($1)
    If StringInStr($1, "FooterPage") then
        ToolTip("In Frame", 0, 0)
        With $B_oIE5
            $elems = .document.frames.main.document.getElementsByTagName("*")   
            $Max = $elems.length
            $count = 0
            For $elem in $elems
                $count = $count + 1
                if isobj($elem) then 
                    if $elem.SafeMode.value <> 1 then  
                        $elem.setAttribute("SafeMode",1) 
                        if StringRight($elem.id, 3) = "_SB" then $elem.disabled="True" ; Submit Button (Subjects)
                        if StringRight($elem.id, 6) = "log_IB" then $elem.disabled="True" ;Inactivate Log Line button
                        if StringInStr($elem.id, "Save") then $elem.disabled="True" ; Submit Button 
                        if StringInStr($elem.id, "SubmitBut") then $elem.disabled="True" ; Submit Button
                        if StringInStr($elem.id, "AddLine") then $elem.disabled="True" ; Add log line
                        if StringInStr($elem.id, "AddLine") then $elem.href=$1 ; Add log line
                        if StringInStr($elem.id, "_SibB") then $elem.disabled="True" ; Sign Box
                        if StringInStr($elem.id, "_SIG") then $elem.disabled="True" ; Sign Button
                    Endif
                EndIf
            Next
            ;WEnd
        EndWith
    EndIf
EndFunc

Share this post


Link to post
Share on other sites



Instead of causing object references repeatedly for the same property ($elem.id), save it to a variable and work with that:

if $elem.SafeMode.value <> 1 then 
                        $elem.setAttribute("SafeMode",1)
                        $ElemId = $elem.id
                        if StringRight($ElemId, 3) = "_SB" then $elem.disabled="True" ; Submit Button (Subjects)
                        if StringRight($ElemId, 6) = "log_IB" then $elem.disabled="True" ;Inactivate Log Line button
                        if StringInStr($ElemId, "Save") then $elem.disabled="True" ; Submit Button 
                        if StringInStr($ElemId, "SubmitBut") then $elem.disabled="True" ; Submit Button
                        if StringInStr($ElemId, "AddLine") then $elem.disabled="True" ; Add log line
                        if StringInStr($ElemId, "AddLine") then $elem.href=$1 ; Add log line
                        if StringInStr($ElemId, "_SibB") then $elem.disabled="True" ; Sign Box
                        if StringInStr($ElemId, "_SIG") then $elem.disabled="True" ; Sign Button
                    EndifoÝ÷ Ø×±¶f§ÊírÇh¶¬jg­)à{az«¨µ8^«¨¶+*'RǪºN®«¨¶Ú)ºÛayÊ'v+{-¢­êÛyÆ®±ê'qê'z+-®ç¢·¥Ëh¦Z()àjÛaz·¬µ©Ý¦ºyçbg«^+hªê-N§ªê-jëh×6                    if $elem.SafeMode.value <> 1 then 
                        $elem.setAttribute("SafeMode",1)
                        $ElemId = $elem.id
                        if StringRight($ElemId, 3) = "_SB" Or _
                            StringRight($ElemId, 6) = "log_IB" Or _
                            StringInStr($ElemId, "Save") Or _
                            StringInStr($ElemId, "SubmitBut") Or _
                            StringInStr($ElemId, "_SibB") Or _
                            StringInStr($ElemId, "_SIG")  Or _
                            StringInStr($ElemId, "AddLine") then $elem.disabled="True"
                        if StringInStr($ElemId, "AddLine") then $elem.href=$1 ; Add log line
                    Endif

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Instead of causing object references repeatedly for the same property ($elem.id), save it to a variable and work with that:

if $elem.SafeMode.value <> 1 then 
                        $elem.setAttribute("SafeMode",1)
                        $ElemId = $elem.id
                        if StringRight($ElemId, 3) = "_SB" then $elem.disabled="True" ; Submit Button (Subjects)
                        if StringRight($ElemId, 6) = "log_IB" then $elem.disabled="True" ;Inactivate Log Line button
                        if StringInStr($ElemId, "Save") then $elem.disabled="True" ; Submit Button 
                        if StringInStr($ElemId, "SubmitBut") then $elem.disabled="True" ; Submit Button
                        if StringInStr($ElemId, "AddLine") then $elem.disabled="True" ; Add log line
                        if StringInStr($ElemId, "AddLine") then $elem.href=$1 ; Add log line
                        if StringInStr($ElemId, "_SibB") then $elem.disabled="True" ; Sign Box
                        if StringInStr($ElemId, "_SIG") then $elem.disabled="True" ; Sign Button
                    EndifoÝ÷ Ø×±¶f§ÊírÇh¶¬jg­)à{az«¨µ8^«¨¶+*'RǪºN®«¨¶Ú)ºÛayÊ'v+{-¢­êÛyÆ®±ê'qê'z+-®ç¢·¥Ëh¦Z()àjÛaz·¬µ©Ý¦ºyçbg«^+hªê-N§ªê-jëh×6                    if $elem.SafeMode.value <> 1 then 
                        $elem.setAttribute("SafeMode",1)
                        $ElemId = $elem.id
                        if StringRight($ElemId, 3) = "_SB" Or _
                            StringRight($ElemId, 6) = "log_IB" Or _
                            StringInStr($ElemId, "Save") Or _
                            StringInStr($ElemId, "SubmitBut") Or _
                            StringInStr($ElemId, "_SibB") Or _
                            StringInStr($ElemId, "_SIG")  Or _
                            StringInStr($ElemId, "AddLine") then $elem.disabled="True"
                        if StringInStr($ElemId, "AddLine") then $elem.href=$1 ; Add log line
                    EndifoÝ÷ Ûú®¢×ÛaÊ®¢Ù¢jºfjG¢µëÞö¬µêÚºÚ"µÍY    ÌÍÙ[[KØYS[ÙK[YH    ÉÝÈH[    ÌÍÙ[[KÙ]]X]J    ][ÝÔØYS[ÙI][ÝËJB  ÌÍÑ[[RYH ÌÍÙ[[KYYÝ[ÔYÚ
    ÌÍÑ[[RYÊHH  ][Ý×ÔÐ][ÝÈÜÂÝ[ÔYÚ
    ÌÍÑ[[RY
HH  ][ÝÛÙ×ÒP][ÝÈÜÂBBBBBBTÝ[ÔYÑ^
    ÌÍÑ[[RY  ][ÝÊÜÊJÚJTØ]_ÝXZ]    ÌL×ÔÚXÔÒQËY[I][ÝÊH[    ÌÍÙ[[KØXYI][ÝÕYI][ÝÂYÝ[Ò[Ý   ÌÍÑ[[RY  ][ÝÐY[I][ÝÊH[   ÌÍÙ[[KYIÌÍÌHÈYÙÈ[B[Y

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.

Share this post


Link to post
Share on other sites

Thanks for the quick replies. I will let you know how well this works. One quick question. I am a bit new to Reg Expressions. If this correct:

"(?s)(?i)Save|Submit|\_SibB|_SIG,AddLine"

The above basicly means

"(?s=Find any match)(?i=Not Case Sensituive)Save |=Or Submit Or (\=Special Char) _SibB Or _SIG (What does the comma do?) Addline"

I guess the onlything I am unsure of is the comma before Addline

Share this post


Link to post
Share on other sites

You'd think a shinny new Moderator would jump all over that forum editor bug, huh?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks for the quick replies. I will let you know how well this works. One quick question. I am a bit new to Reg Expressions. If this correct:

"(?s)(?i)Save|Submit|\_SibB|_SIG,AddLine"

The above basicly means

"(?s=Find any match)(?i=Not Case Sensituive)Save |=Or Submit Or (\=Special Char) _SibB Or _SIG (What does the comma do?) Addline"

I guess the onlything I am unsure of is the comma before Addline

I think that should be delimiter "|", escape "\", underbar "_", before SIG, and just delimiter before AddLine:

"(?s)(?i)Save|Submit|\_SibB|\_SIG|AddLine"

...but I'm pretty lame on RegExp.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

This function basically waits until the FooterPage loads on a website then checks if certain objects exist. If they do it then disables them one way or another. The reason I do not simply have the .id spelled out is because in some cases it is dynamicly generated. The problem with the function is that it can be slow at times and you can beat it to the objects and use them before I disable them. If possible I would like to speed this process up or find a way to ensure the objects cannot be used until after this function sets them to "SafeMode = 1". Anyt thoughts would be helpful.

Also:

$count   += 1
               ;if isobj($elem) then

isobj($elem) is not neccessary probably - inside FOR IN LOOP it's always object

Share this post


Link to post
Share on other sites

I think that should be delimiter "|", escape "\", underbar "_", before SIG, and just delimiter before AddLine:

"(?s)(?i)Save|Submit|\_SibB|\_SIG|AddLine"

...but I'm pretty lame on RegExp.

:)

That's correct, I typed it in the fast reply box, and tend to make mistakes when I do that ;) ... thanks PDS.

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.

Share this post


Link to post
Share on other sites

You'd think a shinny new Moderator would jump all over that forum editor bug, huh?

;)

You think to much :) .. I'm fairly sure Jon has seen the reports on it, and He's the only one that I'm aware of that can fix/add/update it.

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.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

You think to much ;) .. I'm fairly sure Jon has seen the reports on it, and He's the only one that I'm aware of that can fix/add/update it.

When it gets scrambled like that, I have to look close to see if it's just the bug, or a hairy RegExp I just don't understand!

:)

This is the way I see it...

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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