Adele Posted December 17, 2016 Posted December 17, 2016 (edited) Hello everyone. I'm preparing a macro program. Users will able to create themselves macros and they will able to use them on games or programs whatever they want. But I'd like to they should be able to run the macro when the window is working in background so I can't use Send() function. I can use ControlSend() function but many programs don't accept keystrokes which sent by ControlSend() because ControlSend() needs a ControlId. Do you know any alternative for ControlSend(). It should work like Send() function but in background. Thank you in advance. Edited December 17, 2016 by Adele
genius257 Posted December 30, 2016 Posted December 30, 2016 Hi @Adele. No, ControlSend does not require a controlID. See my my example below (I just modified line 14 from the ControlSend example) Example() Func Example() ; Run Notepad Run("notepad.exe") ; Wait 10 seconds for the Notepad window to appear. Local $hWnd = WinWait("[CLASS:Notepad]", "", 10) ; Wait for 2 seconds. Sleep(2000) ; Send a string of text to the edit control of Notepad. The handle returned by WinWait is used for the "title" parameter of ControlSend. ControlSend($hWnd, "", "", "This is some text") ; Wait for 2 seconds. Sleep(2000) ; Close the Notepad window using the handle returned by WinWait. WinClose($hWnd) ; Now a screen will pop up and ask to save the changes, the classname of the window is called ; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file" WinWaitActive("[CLASS:#32770]") Sleep(500) Send("{TAB}{ENTER}") EndFunc ;==>Example As you can see, the example still works fine. I believe if no ControlID is specified, the control with focus is the target. To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
alienclone Posted January 3, 2017 Posted January 3, 2017 there may be a ControlID that the window info tool is not showing. try these additional control info sniffer tools... https://www.autoitscript.com/forum/topic/164226-get-all-windows-controls/ https://www.autoitscript.com/forum/topic/126716-control-viewer-autoit-window-info-tool/ If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version
junkew Posted January 3, 2017 Posted January 3, 2017 (edited) See iuiautomation udf i made. Alternatives Setfocus and copy paste Setfocus and send Keybd_event Sendinput Iuiautomaton textpattern Iaccessible patterns In background probably only 5 and 6 but will frequently not be implemented. Edited January 3, 2017 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
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