Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Window Text
#1
Hi, I am using this example form the Help section, but it does not work, Notepad crashes:
;; _______________________________________________________________

out
int w=id(15 win("Notepad" "Notepad")) ;;get handle of Notepad edit control
WindowText x.Init(w)

if text "findme" exists...
if x.Find("findme") ;; <- it crashes here
out "text ''findme'' found" ;; there is a tab here that the editor does not show
;; ________________________________________________________________

I even replaced the second line with:

int w1=act(win("Untitled - Notepad" "Notepad"))

I am using Windows 8.1
Please help, thank you.
#2
If you don't need to open file with notepad,

Code:
Copy      Help
str S E("findme") M      ;;;;; 'E("findme")' is equal to ' str E="findme" '
str T = "c:\tmp.txt"     ;;;;; target file
int F
S.getfile(T)                ;;;;; load 'tmp.txt' to string S
F = find(S E)               ;;;;; find('target' 'what you want to find')
if (F>0)                      ;;;;; if found, F is >0
    M.format("text %s found" E)
    out M
#3
Thank you. Actually I need to look for text in a browser, I used Notepad as an example, but it crashed. I don't think a browser is going to do better than Notepad. Thank you again.
#4
QM can load html document to string

I was wrong about find. (if found, F is >=0)

Code:
Copy      Help
str E("findme") M      ;;;;; 'E("findme")' is equal to ' str E="findme" '
str T
int F

HtmlDoc HD.SetOptions(2)
HD.InitFromWeb(" 'html address you want to get' ")
T=HD.GetHtml

F = find(T E)               ;;;;; find('target' 'what you want to find')
if !(F<0)                      ;;;;; if found, F is >=0
   M.format("text %s found" E)
   out M
#5
One more question (sorry).
When I do a search in a browser using Control + F, and the string is found, it gets highllighted.
is there a QM function to retrieve the coordinates of the highlighted string? (the mouse is still in the search box, and GetCaretXY returns 0 0).

Thank you.
#6
Quote:Notepad crashes

Possibly QM interferes with some other software that hooks the same API functions in Notepad process. Some of possible software types: 1. A spyware program. 2. An anti-spyware or antivirus program.

In web browsers WindowText does not work.

Quote:When I do a search in a browser using Control + F, and the string is found, it gets highllighted.
is there a QM function to retrieve the coordinates of the highlighted string? (the mouse is still in the search box, and GetCaretXY returns 0 0).
There are no QM functions to get selected text position in web browsers. Maybe possible to create for Internet Explorer.
See also this, but with my Firefox version it does not work: [solved] find text and get position of found text


Forum Jump:


Users browsing this thread: 1 Guest(s)