corgano Posted February 14, 2009 Share Posted February 14, 2009 (edited) this code will get control ID when you click it.i want to to get the control ID AND the TITLE of the window the control is onEDITsrry, this script was saulved by John2006, shoulda said sumthing......lolpm me if you want to see the script i used it in. Edited February 15, 2009 by corgano 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Authenticity Posted February 14, 2009 Share Posted February 14, 2009 $hParent = DllCall('user32.dll', 'hwnd', 'GetParent', 'hwnd', $hCtrl') ? Link to comment Share on other sites More sharing options...
corgano Posted February 14, 2009 Author Share Posted February 14, 2009 $hParent = DllCall('user32.dll', 'hwnd', 'GetParent', 'hwnd', $hCtrl')?could you add that to the script provided? 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Authenticity Posted February 14, 2009 Share Posted February 14, 2009 #include <Misc.au3> #include <WinAPI.au3> Global $hCtrl = _ControlGetHovered() Dim $prolist = ProcessList() while 1 $pos = MouseGetPos() $prolist2 = ProcessList() ;==================================== control ID ElseIf _IsPressed(01) = True Then $hCtrl = _ControlGetHovered() $hParent = _WinAPI_GetParent($hCtrl) ;<<== _HwndToID($hCtrl) FileWrite("123.txt","ControlClick("","", " & $controID[0] & ")" & @CRLF) FileWrite("123.txt","ParentWindow("",""," & $hParent & ")" & @CRLF) ;<<== Do sleep(100) Until _IsPressed(01) = false EndIf WEnd Func _HwndToID($hWnd) If Not IsHWnd($hWnd) Then Return SetError(1, 0, "") Global $controID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hWnd) If Not IsArray($controID) Then Return SetError(2, 0, "") Return $controID[0] EndFunc Func _ControlGetHovered() Local $controID = DllCall("user32.dll", "int", "WindowFromPoint", "long", MouseGetPos(0), "long", MouseGetPos(1)) Return HWnd($controID[0]) EndFunc Depend what can be the parent in this case and if this parent is not a child of another parent so you won't get the title this way... Link to comment Share on other sites More sharing options...
corgano Posted February 14, 2009 Author Share Posted February 14, 2009 (edited) Depend what can be the parent in this case and if this parent is not a child of another parent so you won't get the title this way...i will be useing it on installers.i eventually will make it so i run a program, install something, and it will generate a script to install it for me.i need it to give me the controll ID and the window title ( and eventually some window text )so it will write a winwaitactive() and a controlclick()EDITi found it out. thank you, the api func led me to the answer. look back because i might need more helpEDITwrong again..... Edited February 14, 2009 by corgano 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
corgano Posted February 14, 2009 Author Share Posted February 14, 2009 updated. how do i get it to only get 3 or 4 words in the text part of wingettext()? how do i make it stop getting text at a @CRLF? or make it write @CRLF instead of enter? ; Script Start - Add your code below here #include <Misc.au3> #include <WinAPI.au3> Global $hCtrl = _ControlGetHovered() Dim $prolist = ProcessList() while 1 $pos = MouseGetPos() $prolist2 = ProcessList() ;==================================== control ID If _IsPressed(01) = True Then $hCtrl = _ControlGetHovered() _HwndToID($hCtrl) $title = WinGetTitle("[active]") $text = WinGetText($title) FileWrite("123.au3",'ControlClick("","", "' & $controID[0] & '")' & @CRLF) FileWrite("123.au3",'WinWaitActive("' & $title & '","' & $text & '")' & @CRLF) Do sleep(100) Until _IsPressed(01) = false EndIf WEnd Func _HwndToID($hWnd) Global $controID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hWnd) Return $controID[0] EndFunc Func _ControlGetHovered() Local $controID = DllCall("user32.dll", "int", "WindowFromPoint", "long", MouseGetPos(0), "long", MouseGetPos(1)) Return HWnd($controID[0]) EndFunc 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
martin Posted February 14, 2009 Share Posted February 14, 2009 updated. how do i get it to only get 3 or 4 words in the text part of wingettext()? how do i make it stop getting text at a @CRLF? or make it write @CRLF instead of enter? expandcollapse popup; Script Start - Add your code below here #include <Misc.au3> #include <WinAPI.au3> Global $hCtrl = _ControlGetHovered() Dim $prolist = ProcessList() while 1 $pos = MouseGetPos() $prolist2 = ProcessList() ;==================================== control ID If _IsPressed(01) = True Then $hCtrl = _ControlGetHovered() _HwndToID($hCtrl) $title = WinGetTitle("[active]") $text = WinGetText($title) FileWrite("123.au3",'ControlClick("","", "' & $controID[0] & '")' & @CRLF) FileWrite("123.au3",'WinWaitActive("' & $title & '","' & $text & '")' & @CRLF) Do sleep(100) Until _IsPressed(01) = false EndIf WEnd Func _HwndToID($hWnd) Global $controID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hWnd) Return $controID[0] EndFunc Func _ControlGetHovered() Local $controID = DllCall("user32.dll", "int", "WindowFromPoint", "long", MouseGetPos(0), "long", MouseGetPos(1)) Return HWnd($controID[0]) EndFunc Maybe you should edit your first post to say see post #6 instead of see last post (I find its a bit confusing having $ControID as a local and a global variable.) If you only want first line of $text then you can do this $lineEnd = StringInStr($text,@CRLF) if $lineEnd > 0 then $text = StringLeft($text,$lineEnd - 1) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Malkey Posted February 14, 2009 Share Posted February 14, 2009 updated. how do i get it to only get 3 or 4 words in the text part of wingettext()? how do i make it stop getting text at a @CRLF? or make it write @CRLF instead of enter?This may help you. Replace $text = WinGetText($title) with $text = StringRegExpReplace(StringregexpReplace(WinGetText($title), _ "(?s)^([\S\s]{0,25})((?s)|.*)$","\1"),"(\r\n|\r|\n)",'" & @CRLF & "') It may give you some ideas. Link to comment Share on other sites More sharing options...
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