SmokNiszczyciel Posted July 5, 2010 Posted July 5, 2010 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?
Moderators Melba23 Posted July 5, 2010 Moderators Posted July 5, 2010 SmokNiszczyciel,Something involving ControlGetText and StringInStr should do the trick. Give it a go and see how you get on. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
SmokNiszczyciel Posted July 5, 2010 Author Posted July 5, 2010 Could you give me examples of use these commands, pleasE? I need to find strings a lot times but I have to use pixelsearch and pixelgetcolor:( These commands would be useful for me
Moderators Melba23 Posted July 5, 2010 Moderators Posted July 5, 2010 SmokNiszczyciel,Because you asked so nicely: expandcollapse popup#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 WEndThis 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? M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
SmokNiszczyciel Posted July 5, 2010 Author Posted July 5, 2010 It works only with GUI? I want it read from windows like firefox etc, I think about memory scan:P
Moderators Melba23 Posted July 5, 2010 Moderators Posted July 5, 2010 SmokNiszczyciel,It works only with GUI?And FireFox is not a GUI......? 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
SmokNiszczyciel Posted July 5, 2010 Author Posted July 5, 2010 Ok i think its not possible to check text from something that's not autoit GUI :/
Moderators Melba23 Posted July 5, 2010 Moderators Posted July 5, 2010 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: expandcollapse popup#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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
SmokNiszczyciel Posted July 5, 2010 Author Posted July 5, 2010 So, i can make script find a text on window X and it will look for the text and if it find it then it will get position of the text? And "if not @error then" will work only if script found the text?
Moderators Melba23 Posted July 5, 2010 Moderators Posted July 5, 2010 SmokNiszczyciel,In a word:Yes. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
SmokNiszczyciel Posted July 5, 2010 Author Posted July 5, 2010 (edited) 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 July 5, 2010 by SmokNiszczyciel
Moderators Melba23 Posted July 5, 2010 Moderators Posted July 5, 2010 SmokNiszczyciel,I have problems with these commandsHave you looked in the Help file? switch - I understand this asYou 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. Any more random questions? M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
SmokNiszczyciel Posted August 4, 2010 Author Posted August 4, 2010 Now I'm back to this problem - you said that it will return position of text it find, so 1. how do I make script read the position? Will variable with controlgettext also get it's position? 2. what if text is hidden or memory scan is needed?
Moderators Melba23 Posted August 4, 2010 Moderators Posted August 4, 2010 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 commandsThese 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. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
SmokNiszczyciel Posted August 4, 2010 Author Posted August 4, 2010 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
Moderators Melba23 Posted August 4, 2010 Moderators Posted August 4, 2010 SmokNiszczyciel,I've read in helpfile about these commands and I understand themExcellent. 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. So, where are you looking? M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
SmokNiszczyciel Posted August 4, 2010 Author Posted August 4, 2010 (edited) 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 August 4, 2010 by SmokNiszczyciel
Moderators Melba23 Posted August 4, 2010 Moderators Posted August 4, 2010 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 thatget some numbers like 5000 and i want it do something if it's under 5k or over 5kJust how stupid do you think I, and the other long-term members, are?Go and play somewhere else. "click"M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Developers Jos Posted August 4, 2010 Developers Posted August 4, 2010 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.
Recommended Posts