Algotek Posted August 17, 2012 Share Posted August 17, 2012 (edited) Hi, first use of AutoIt. I have the following info: -the main application handle (hwnd1) -the dialog handle (hwnd2) (the dialog is already opened and belongs to hwnd1) -the dialog text control (hwnd3) (this is where I want to write) How can I call SetControlText with this information ? Edited August 17, 2012 by Algotek Link to comment Share on other sites More sharing options...
Danyfirex Posted August 17, 2012 Share Posted August 17, 2012 (edited) Put your code.did you mean GUICtrlSetData? Edited August 17, 2012 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Algotek Posted August 17, 2012 Author Share Posted August 17, 2012 Sorry, the exact name is ControlSetText ( "title", "text", controlID, "new text" [, flag] ) I would like to directly take advantage of the windows handles (which are easily available from my program), instead of specifying class, titles, or controlid. Or translte the handles to whatever parameter this ControlSetText takes. Link to comment Share on other sites More sharing options...
Danyfirex Posted August 17, 2012 Share Posted August 17, 2012 did you look into help file? A good example Run("notepad.exe") WinWait("[CLASS:Notepad]") ControlSetText("[CLASS:Notepad]", "", "Edit1", "New Text Here") Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Algotek Posted August 17, 2012 Author Share Posted August 17, 2012 Sure, I did look to documentation. I would like to directly take advantage of the windows handles (which are easily available from my program), instead of specifying class, titles, or controlid. Or translate somehow the handles to whatever parameter this ControlSetText takes. The following does not work, although every single variable is OK according to the AutoIt Window Info sub settext(hwnd2 as long,hwnd3 as long, stext as string) Dim theclass As String theclass = getmywindowclass(hwnd2) 'some routine that returns the class based on hwnd2 Dim thetitle As String thetitle = getwindowtext(hwnd2) 'some routine that returns the caption of hwnd2 Dim ctrl_id As Long ctrl_id = GetDlgCtrlID(hwnd3) .some Win api routine that return the ctrl id Dim bsuccess As Boolean 'first try, as documented bsuccess = (ai.ControlSetText("[CLASS:" + theclass + "]", thetitle, ctrl_id, stext) = 1) 'no success !! 'second try (usage not documented, and does not work) bsuccess = (ai.ControlSetText(hwnd2, "", hwnd3, stext) = 1) 'no success !! Link to comment Share on other sites More sharing options...
Danyfirex Posted August 17, 2012 Share Posted August 17, 2012 Can you show your whole code? Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
BrewManNH Posted August 17, 2012 Share Posted August 17, 2012 Your script isn't in the AutoIt language format, so it's not going to work with AutoIt. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Algotek Posted August 20, 2012 Author Share Posted August 20, 2012 @brewman: I'm using the AutoIt com object (ai) my code is in vbIn documentation, I found the following helpful topic Window Titles and Text (Advanced)At the end, it saysWhen you use a window handle for the title parameter then the text parameter is completely ignored.The problem was that the hwnd2 I was using was a long.AutoIt expects a pointer to the window (a variant)Still not clear if ControlSetText 3rd parameter can be a hwnd. 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