Andreik Posted August 12, 2008 Posted August 12, 2008 I want to get text from current control, but control is not in my GUI and I don't know what should I use for controlID in this case. I use this but not work: ControlGetText("[ACTIVE]","",_WinAPI_GetDlgCtrlID(_WinAPI_GetFocus()))
Minikori Posted August 12, 2008 Posted August 12, 2008 I want to get text from current control, but control is not in my GUI and I don't know what should I use for controlID in this case. I use this but not work: ControlGetText("[ACTIVE]","",_WinAPI_GetDlgCtrlID(_WinAPI_GetFocus()))Whats the window your trying to get? For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com
Andreik Posted August 14, 2008 Author Posted August 14, 2008 Someone know what should I use for controlID or how I can get controlID?
Moderators SmOke_N Posted August 14, 2008 Moderators Posted August 14, 2008 (edited) Someone know what should I use for controlID or how I can get controlID? Try:WinGetText(_WinAPI_GetFocus())Edit:Interesting enough:WinGetTitle(_WinAPI_GetFocus()) Edited August 14, 2008 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Andreik Posted August 14, 2008 Author Posted August 14, 2008 Try:WinGetText(_WinAPI_GetFocus())Is not work. Return 0.
Moderators SmOke_N Posted August 14, 2008 Moderators Posted August 14, 2008 Is not work. Return 0. Read my edit. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Moderators SmOke_N Posted August 14, 2008 Moderators Posted August 14, 2008 Is not work. Return 0. Read my edit. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Andreik Posted August 14, 2008 Author Posted August 14, 2008 Return 0. Is another way to get text from a control?
7h331337 Posted August 14, 2008 Posted August 14, 2008 Return 0. Is another way to get text from a control? use autoit info to get the control id
Moderators SmOke_N Posted August 14, 2008 Moderators Posted August 14, 2008 Return 0. Is another way to get text from a control? The method with WinGetTitle worked fine for me.#include <WinAPI.au3> #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $gui, $msg, $btnFocus, $win, $text $gui = GUICreate("__WinAPI_GetFocus Example", 200, 200) Local $hlabel = GUICtrlCreateEdit("I am an edit", 10, 10, 150, 50) $btnFocus = GUICtrlCreateButton("Get Focus", 50, 85, 100, 30) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $btnFocus ControlFocus($gui, "", $hlabel) ;;;;;;; Put focus on edit $win = _WinAPI_GetFocus() $text = "Full Title: " & WinGetTitle($win) & @LF $text &= "Full Text: " & WinGetText($win) & @LF $text &= "Handle: " & WinGetHandle($win) & @LF $text &= "Process: " & WinGetProcess($win) & @LF MsgBox(0, "", $text) EndSelect WEnd EndFunc ;==>_MainThat clearly demonstrating it working. Are you even sure it's a standard control and not owner drawn. Did you try using AutoInfo tool to see what the results are? Maybe what you think has focus doesn't? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Andreik Posted August 14, 2008 Author Posted August 14, 2008 (edited) use autoit info to get the control id I can't use autoit info to get control id Just tested and _WinAPI_GetFocus() return 0x000000, but the edit control is selected. @SmOke_N Your example is good but I can't focus edit control because I don't know controlID. ControlFocus($gui, "", $hlabel) Edited August 14, 2008 by Andreik
Moderators SmOke_N Posted August 14, 2008 Moderators Posted August 14, 2008 I can't use autoit info to get control id Just tested and _WinAPI_GetFocus() return 0x000000, but the edit control is selected. @SmOke_N Your example is good but I can't focus edit control because I don't know controlID. ControlFocus($gui, "", $hlabel)Doesn't mean it has focus... doesn't mean it isn't owner drawn. Is this a public/free download? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Andreik Posted August 14, 2008 Author Posted August 14, 2008 Doesn't mean it has focus... doesn't mean it isn't owner drawn.Is this a public/free download?Look post#4. Is free download (oDC 5.31)
Moderators SmOke_N Posted August 14, 2008 Moderators Posted August 14, 2008 Look post#4. Is free download (oDC 5.31)That's a picture... you don't expect me to go out of my way to find a link to it do you? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Andreik Posted August 14, 2008 Author Posted August 14, 2008 http://www.softpedia.com/get/Internet/File...as-DC-oDC.shtml
Moderators SmOke_N Posted August 14, 2008 Moderators Posted August 14, 2008 http://www.softpedia.com/get/Internet/File...as-DC-oDC.shtmlLocal $hWnd = WinGetHandle("oDC 5.31 - The following untitled edition - [Public Hubs]") While WinExists($hWnd) If WinActive($hWnd) Then ConsoleWrite( ControlGetText($hWnd, "", "[CLASSNN:" & ControlGetFocus($hWnd) & "]") & @CRLF) Sleep(10) WEnd Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Andreik Posted August 14, 2008 Author Posted August 14, 2008 Local $hWnd = WinGetHandle("oDC 5.31 - The following untitled edition - [Public Hubs]") While WinExists($hWnd) If WinActive($hWnd) Then ConsoleWrite( ControlGetText($hWnd, "", "[CLASSNN:" & ControlGetFocus($hWnd) & "]") & @CRLF) Sleep(10) WEnd Thanks SmOke_N.
DssTrainer Posted March 4, 2009 Posted March 4, 2009 (edited) Having this same problem. Is there a bug with _WinAPI_GetFocus() ? I can't even get focus on calc.exe or notepad.exe. Keeps returning 0x0000000. The final solution here does me no good as my script will be used on many diff windows, not one with a static name sleep (5000) ;give time to focus a window after start $win =_WinAPI_GetFocus() MsgBox(0, "handle", $win) -----> 0x0000000 $wintitle = WinGetTitle($win) MsgBox(0, "title", $wintitle) ------> 0 Edited March 4, 2009 by DssTrainer
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now