Jump to content

Scan like pixelsearch


Recommended Posts

I've been looking for something like that for around half year but I haven't found it so I'll just ask here - is there any command that scan selected area [like in pixelsearch] for one/few strings? Example: this forum - i select this window where i write this message and i tell script to scan this window for strings like "example"... is that possible?

Link to comment
Share on other sites

  • Moderators

SmokNiszczyciel,

Something involving ControlGetText and StringInStr should do the trick. Give it a go and see how you get on. :blink:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

SmokNiszczyciel,

Because you asked so nicely: :P

#include <GUIConstantsEx.au3>

$sText = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut" & @CRLF & _
"labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco" & @CRLF & _
"laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in" & @CRLF & _
"voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" & @CRLF & _
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

$hGUI = GUICreate("Test", 500, 500)

$hEdit = GUICtrlCreateEdit($sText, 10, 10, 480, 200)
GUICtrlSetState(-1, $GUI_FOCUS)

GUICtrlCreateLabel("Enter text to search for", 10, 230, 480, 20)
$hInput = GUICtrlCreateInput("", 10, 250, 480, 20)

$hButton = GUICtrlCreateButton("Find text", 10, 300, 80, 30)

$hList = GUICtrlCreateList("", 10, 350, 480, 100)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            ; Clear exisitn return
            GUICtrlSetData($hList, "")
            ; Get string to look for
            $sSearchString = GUICtrlRead($hInput)
            ; As long as we have a string
            If $sSearchString <> "" Then
                ; Read the text from the control
                $sGotString = ControlGetText($hGUI, "", $hEdit)
                ; Start at the first character
                $iStart = 1
                ; Loop until we find no more matches
                While 1
                    ; Get position of search string in the text
                    $iPos = StringInStr($sGotString, $sSearchString, 0, 1, $iStart)
                    ; Exit if we do not find the string
                    If $iPos = 0 Then
                        ; Announce if we found no instances
                        If $iStart = 1 Then GUICtrlSetData($hList, "No instances found")
                        ExitLoop
                    EndIf
                    ; Announce the find
                    GUICtrlSetData($hList, "Found " & $sSearchString & " at position " & $iPos)
                    ; Set the start point for the next search
                    $iStart = $iPos + 1
                WEnd
            EndIf
    EndSwitch
WEnd

This code shows how to read from a GUI you created, but you can (usually ;) ) read the text from any GUI - just use the Au3 Window Info tool ("C:\Program Files\AutoIt3\Au3Info.exe") to get the window and control details to put in the ControlGetText command.

All clear? :blink:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

SmokNiszczyciel,

It works only with GUI?

And FireFox is not a GUI......? :blink:

You could try ControlGetText to get text from FireFox, but I suggest you look at the FF.au3 UDF - it no doubt has a suitable function for the task. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

SmokNiszczyciel,

Ok i think its not possible to check text from something that's not autoit GUI :/

You do give up easily. ;)

Here is some code to read from Notepad - slightly modified, it should work on most things: :blink:

#include <GUIConstantsEx.au3>

$sText = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut" & @CRLF & _
"labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco" & @CRLF & _
"laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in" & @CRLF & _
"voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat" & @CRLF & _
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

Run("Notepad.exe")
WinWaitActive("Untitled")

ControlSend("[CLASS:Notepad]", "", "Edit1", $sText)

$hGUI = GUICreate("Test", 500, 250)

GUICtrlCreateLabel("Enter text to search for", 10, 230, 480, 20)

$hInput = GUICtrlCreateInput("", 10, 10, 480, 20)

$hButton = GUICtrlCreateButton("Find text", 10, 40, 80, 30)

$hList = GUICtrlCreateList("", 10, 100, 480, 100)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            ; Clear existing return
            GUICtrlSetData($hList, "")
            ; Get string to look for
            $sSearchString = GUICtrlRead($hInput)
            ; As long as we have a string
            If $sSearchString <> "" Then
                ; Read the text from the control
                $sGotString = ControlGetText("[CLASS:Notepad]", "", "Edit1")
                ; Start at the first character
                $iStart = 1
                ; Loop until we find no more matches
                While 1
                    ; Get position of search string in the text
                    $iPos = StringInStr($sGotString, $sSearchString, 0, 1, $iStart)
                    ; Exit if we do not find the string
                    If $iPos = 0 Then
                        ; Announce if we found no instances
                        If $iStart = 1 Then GUICtrlSetData($hList, "No instances found")
                        ExitLoop
                    EndIf
                    ; Announce the find
                    GUICtrlSetData($hList, "Found " & $sSearchString & " at position " & $iPos)
                    ; Set the start point for the next search
                    $iStart = $iPos + 1
                WEnd
            EndIf
    EndSwitch
WEnd

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

SmokNiszczyciel,

In a word:

Yes. :blink:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Ok now I have problems with these commands, because I know nothing about them:P F1 doesnt help me much:(

1. CtrlSend

2. Switch

3. GuiCtrlSetData

4. GuiCtrlRead

5. ControlGetText

6. StringInStr

I never met with some of these commands:/ </3 F1

@edit

2. switch -

Switch @HOUR
Case 6 To 11
    $msg = "Good Morning"
Case 12 To 17
    $msg = "Good Afternoon"
Case 18 To 21
    $msg = "Good Evening"
Case Else
    $msg = "What are you still doing up?"
EndSwitch
        
MsgBox(0, Default, $msg)

Ok I understand this as

1. check hour

2. if hour is 6-11 then send msg "good morning"

3. etc

@edit2

Do I need GUI to scan for text in firefox?

Edited by SmokNiszczyciel
Link to comment
Share on other sites

  • Moderators

SmokNiszczyciel,

I have problems with these commands

Have you looked in the Help file? :blink:

switch - I understand this as

You are partly correct. It will display the text in a MsgBox, not Send it. ;)

Do I need GUI to scan for text in firefox?

No, I just made the little GUI in the code I posted above to show you what was happening. As I mentioned above, look at the FF.au3 UDF which is designed to work with FireFox - no doubt there is a command in there to read the FireFox window directly. I do not use FireFox so I cannot help you there. :P

Any more random questions? :

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • 5 weeks later...
  • Moderators

SmokNiszczyciel,

Let us back up a couple of posts:

I have problems with these commands, because I know nothing about them. F1 doesnt help me much:(

1. CtrlSend

2. Switch

3. GuiCtrlSetData

4. GuiCtrlRead

5. ControlGetText

6. StringInStr

I never met with some of these commands

These are basic AutoIt commands. If you really do not know how they work then you need to learn more about AutoIt before trying to read text on the screen. Did you actually understand the script I posted a while back?

Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page). There are even video tutorials on YouTube if you prefer watching to reading.

I know you want to start coding NOW, but a little study will save you (and us when we get inundated with questions ;) ) a lot of trouble later on, believe me. :blink:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Sorry I've forgot to add that I've read in helpfile about these commands and I understand them, but they say nothing about getting position from ControlGetText so I've asked you:/

I will also read these tutorials, thanks and BTW I'm reading this topic: http://www.autoitscript.com/forum/index.php?showtopic=113217&st=0&p=792571&hl=memory%20scan&fromsearch=1&#entry792571 so maybe I'll learn something

Link to comment
Share on other sites

  • Moderators

SmokNiszczyciel,

I've read in helpfile about these commands and I understand them

Excellent. :blink:

What exactly is it that you are trying to read? Because how you get the text will depend on where it is. Once you have the text, searching within it is relatively easy. :P

So, where are you looking? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Um example is firefox or something like that:

I want to find text "text" in window Firefox, so I use "ControlGetText" [or something like that:P] and after script find the text then I want to get it's position... [position of text]\

Btw, I have read topic and checked tutorials

@edit

Also this:

if a controlgettext get some numbers like 5000 and i want it do something if it's under 5k or over 5k then how i do that and is it even possible?

Edited by SmokNiszczyciel
Link to comment
Share on other sites

  • Moderators

SmokNiszczyciel,

I have tried to be helpful since you arrived here.

What exactly is it that you are trying to read?

Um example is firefox or something like that

get some numbers like 5000 and i want it do something if it's under 5k or over 5k

Just how stupid do you think I, and the other long-term members, are?

Go and play somewhere else. :blink:

"click"

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Developers

Um example is firefox or something like that:

I want to find text "text" in window Firefox, so I use "ControlGetText" [or something like that:P] and after script find the text then I want to get it's position... [position of text]\

Btw, I have read topic and checked tutorials

@edit

Also this:

if a controlgettext get some numbers like 5000 and i want it do something if it's under 5k or over 5k then how i do that and is it even possible?

I have been patient enough with you and gave you ample warnings.

Goodbye forever

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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