Michiel Posted December 4, 2014 Share Posted December 4, 2014 This works: ControlClick($hWnd, "", "[TEXT:J'accepte/I Agree]") But this does not: Local $hBtn = ControlGetHandle($hWnd, '', "[TEXT:J'accepte/I Agree]") ControlClick($hWnd, "", $hBtn) (When checking if a handle is correctly returned by dumping it to the screen MsgBox, it is indeed.) Is it possible in the first place to click a control using a handle to a control rather than an id? Just curious. Link to comment Share on other sites More sharing options...
MikahS Posted December 4, 2014 Share Posted December 4, 2014 This is because ControlClick works with The control to interact with, not the handle. So, you must use a control as such: ID - The internal control ID. The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of identifying controls. In addition to the AutoIt Window Info Tool, other applications such as screen readers for the blind and Microsoft tools/APIs may allow you to get this Control ID TEXT - The text on a control, for example "&Next" on a button CLASS - The internal control classname such as "Edit" or "Button" CLASSNN - The ClassnameNN value as used in previous versions of AutoIt, such as "Edit1" NAME - The internal .NET Framework WinForms name (if available) REGEXPCLASS - Control classname using a regular expression X \ Y \ W \ H - The position and size of a control. INSTANCE - The 1-based instance when all given properties match. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
jguinch Posted December 4, 2014 Share Posted December 4, 2014 (edited) The handle can be used, of course Run ("notepad") $hNotepad = WinWait("[CLASS:Notepad]") $hEdit = ControlGetHandle($hNotepad, "", "[CLASS:Edit]") WinActivate($hNotepad) ; ControlSend($hNotepad, "", "[CLASS:Edit; INSTANCE:1]", "text") ControlSend($hNotepad, "", $hEdit, "text") Edit : $hEdit instead of "[CLASS:Edit; INSTANCE:1]" (i wrote to fast) Edited December 4, 2014 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
MikahS Posted December 4, 2014 Share Posted December 4, 2014 (edited) jguinch I think you are a little confused. you haven't even used a handle to do anything in that example. EDIT: You were correct about it working though, as this works. Run ("notepad") $hNotepad = WinWait("[CLASS:Notepad]") $hEdit = ControlGetHandle($hNotepad, "", "[CLASS:Edit]") WinActivate($hNotepad) ControlSend($hNotepad, "", $hEdit, "text") Edited December 4, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
MikahS Posted December 4, 2014 Share Posted December 4, 2014 Some controls will resist clicking unless they are the active window. Use the WinActivate() function to force the control's window to the top before using ControlClick(). Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Michiel Posted December 5, 2014 Author Share Posted December 5, 2014 These are about sending text though, not a click. Link to comment Share on other sites More sharing options...
MikahS Posted December 5, 2014 Share Posted December 5, 2014 Your first post is about ControlClick ControlClick($hWnd, "", "[TEXT:J'accepte/I Agree]") Local $hBtn = ControlGetHandle($hWnd, '', "[TEXT:J'accepte/I Agree]") ControlClick($hWnd, "", $hBtn) So, anything else we were misinformed on? Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
JohnOne Posted December 5, 2014 Share Posted December 5, 2014 Change it to ControlSend then. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jdelaney Posted December 5, 2014 Share Posted December 5, 2014 I prefer ControlSetText where I can get away with it. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
JohnOne Posted December 5, 2014 Share Posted December 5, 2014 Yes, that's probably better. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Michiel Posted December 6, 2014 Author Share Posted December 6, 2014 Your first post is about ControlClick So, anything else we were misinformed on? I don't understand... Link to comment Share on other sites More sharing options...
computergroove Posted December 6, 2014 Share Posted December 6, 2014 (edited) I don't understand... Look at your first post. It says: This works: ControlClick($hWnd, "", "[TEXT:J'accepte/I Agree]") But this does not: Local $hBtn = ControlGetHandle($hWnd, '', "[TEXT:J'accepte/I Agree]") ControlClick($hWnd, "", $hBtn) (When checking if a handle is correctly returned by dumping it to the screen MsgBox, it is indeed.) Is it possible in the first place to click a control using a handle to a control rather than an id? Just curious. Then later you said you wanted to send text not a click. Edited December 6, 2014 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
JohnOne Posted December 6, 2014 Share Posted December 6, 2014 People we're using ControlSend as an example to show yes you can use hwnd of control I also got confused. If it is not working for your particular control, then just use the one that does. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted December 6, 2014 Share Posted December 6, 2014 Look at your first post. It says: Then later you said you wanted to send text not a click. I thought that too, but the OP never said anything of the sort. We were wrong. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Michiel Posted December 6, 2014 Author Share Posted December 6, 2014 Ah ... a misunderstanding Link to comment Share on other sites More sharing options...
JohnOne Posted December 6, 2014 Share Posted December 6, 2014 Ah ... a misunderstanding Yes, sorry about that. Your code should work... Local $hBtn = ControlGetHandle($hWnd, '', "[TEXT:J'accepte/I Agree]") ControlClick($hWnd, "", $hBtn) Provided that you have the correct $hWnd. If it does not then you really should just use your first example that does. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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