jso8ootb

Using browser CTRL+F to highlight data continuously

1 post in this topic

Hi all looking into this topic,

I am completely new to AutoIt and not tech-savvy at all, so thank you in advance for your patience that you might need with my question.
I read through the FAQ and watched through some tutorials, but I am sure that I have missed some crucial logic on the so far short way that would help me to move forward.

In short what I want to make and to have is a script that will ask for a value from the user, will store it and every time a certain tab in a browser is opened, the input value will be put into the CTRL+F box which would then highlight the value. And I want to make it so that it works continuously until the user stops it. Either because is done or just needs to change the highlighted value to new one to start again.

Why I am using CTRL+F find option in browser is, because after searching for a week I did not find any hints of getting the AutoIt script to highlight the values itself. Maybe possible, but as I do not know enough to search for it, then I cannot be sure. Ctrl+F at least for one time works.

Why I want to make it, is because in my work I use a web based application, where a list of links is generated and clicking on any link opens a new tab where I have to find the value. If the value I am looking for would be highlighted as soon as the tab opens, it would make going through the links to find the value much easier. For the example, I have used Chrome, but for myself I am using IE because it seems to have more supported functions and helpful materials with AutoIt.

I changed the example to match my thread through Chrome browser as the web application itself I am trying to do it for is locked.
If i did not mess anything up, then running it will ask for input and if you search for example for my username jso8ootb, it should jump to the tab of this thread and search/highlight my username.
What I have noticed, is that if you wait a while (most likely because of the sleeps or something like that) without typing anything into the input box and then do, it will execute the search even without pressing OK, which I don't mind but I still would like to understand it and do have control over it.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Ops = GUICreate("Highlight value", 195, 126, -1, -1)
Global $InsertValue = GUICtrlCreateLabel("Insert value", 53, 0, 93, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
Global $Input1 = GUICtrlCreateInput("", 39, 24, 121, 24)
Global $input = GUICtrlRead($Input1)
Global $PressOK = GUICtrlCreateButton("OK", 62, 56, 75, 24)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Input1
            $input = GUICtrlRead($Input1)

            AutoItSetOption("WinTitleMatchMode", 2)

            Global $searchString = "Using browser CTRL+F"


            WinActivate("Chrome")
            For $i = 0 To 100
                Send("^" & $i)
                Sleep(25)
                If Not (StringInStr(WinGetTitle("[ACTIVE]"), $searchString) = 0) Then

                    ExitLoop
                EndIf
            Next

            Send("^f")
            Sleep(10)
            Send($input)
            ; Close Find dialog
            Send("{PAUSE}")


    EndSwitch
WEnd

Many lines here I have just typed as 1:1 from other examples and changed them until they do something I think they should do. So I do not truly understand them which should be clear to you due to the way use them.

I assume that I have to learn structuring or restructure the code in a way that:
Getting the info from the user is a separate process.
Then either IE or Chrome is activated and searching for the tab (where the input value will figure) is one continuous loop. So it continues to search for that tab with the specified title and continues to the further code only when the tab comes up.
Then, when the tab is located it will carry out the search which will highlight the value.
During work I would always close the tab after locating the value and would open up a new one, so I would want it to make it restart the search loop for the new tab which would have the same title name. 
//With this example it would be as if the value you put in was highlighted and then you closed this thread. While it would be closed, the script would search for it. And it would continue to do so until it would be opened again. And then it would highlight the value again and would restart the process.

As I understand my code at the moment, it just searches for the tab after activating Chrome and then highlights the value.  On line 36 I tried to use ContinueLoop and very mistakenly hoped it would keep searching for the tab until it comes up and then it would carry out the search and start the loop again. I have such huge gaps even in the modicum of understanding I have that I feel stuck. 

Thank you in advance if anybody can nudge me to the right direction!
jso8ootb

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