I found out. I tried ObjCreate instead of DllCall, but I also had some problems with the variable type of the window handle.
Well... you asked for some code, so here you are, and working now.
Thank you!
; ######################################
HotKeySet("{F5}", "GetText")
HotKeySet("{F6}", "ClearText")
HotKeySet("{F7}", "Close")
Global $notepad
Global $inicpos
Run ( "notepad.exe" )
if @OSLang = 0416 then ; Portuguese - BR
WinWait ( "Sem título - Bloco de notas", "" )
$notepad = WinGetHandle ( "Sem título - Bloco de notas", "" )
$close_title = "Bloco de notas"
$close_text = "Deseja salvar as alterações?"
elseif @OSLang = 0409 then ; English - US
WinWait ( "Untitled - Notepad", "" )
$notepad = WinGetHandle ( "Untitled - Notepad", "" )
$close_title = "Notepad"
$close_text = "Do you want to save the changes?"
endif
$inicpos = WinGetPos( $notepad )
WinMove ( $notepad, "", $inicpos[0], $inicpos[1], 400, 200 )
ControlSend ( $notepad, "", "Edit1", _
"Press F5 to capture the text" & @LF & _
"Press F6 to clear this area" & @LF & _
"Press F7 to quit the script" & @LF _
"(F7 will restore previous size)" & @LF )
while WinExists ( $notepad ) = 1
sleep ( 100 )
if WinExists ( $close_title, $close_text ) then
WinMove ( $notepad, "", _
$inicpos[0], _
$inicpos[1], _
$inicpos[2], _
$inicpos[3] )
while WinExists ( $close_title, $close_text ) = 1
sleep ( 100 )
wend
endif
wend
exit
func GetText()
WinActivate ( $notepad )
$pos = WinGetPos( $notepad )
$x = 6 + $pos[0]
$y = 44 + $pos[1]
$w = 372
$h = 114
$handle = String ( $notepad )
$handle = Int ( $handle )
$obj = ObjCreate("TCaptureX.TextCaptureX")
$text = $obj.GetTextFromRect ( $handle, $x, $y, $w, $h )
ClipPut ( $text )
MsgBox ( 0, "Text", $text )
endfunc
func ClearText()
ControlSetText ( $notepad, "", "Edit1", "" )
endfunc
func Close()
WinMove ( $notepad, "", _
$inicpos[0], _
$inicpos[1], _
$inicpos[2], _
$inicpos[3] )
WinClose ( $notepad )
exit
endfunc
; ######################################