noober Posted February 19, 2013 Share Posted February 19, 2013 I've been working on sending keys to windows by "controlsend" instead of send. I am coming upon an odd error that I was hoping someone might be able to help me with. If I use "send" to send a keystroke to the active application it works just fine. If I use "controlsend", however, something unique happens. In the application that I wish to send to I can see that it is sending the keystrokes but not where I want them to go. I assume that the window handle and the handle that I need to send to are different. I've tried sending to all the handles I could find in the app (used winspector spy to find the handles) and that fails entirely. Send works like a charm. I'm curious what the difference between the way controlsend and send are. If I can send keystrokes with the same style as send but with the functionaility of controlsend, I'd be set. I am assuming my limited knowledge of controls is at fault here. Feel free to enlighten me. Link to comment Share on other sites More sharing options...
Trixie Posted February 19, 2013 Share Posted February 19, 2013 What parameters are you using when you use controlsend? Link to comment Share on other sites More sharing options...
noober Posted February 19, 2013 Author Share Posted February 19, 2013 (edited) ControlSend($handle,$text,$controlid,$key) variables provided are passed by "WinList". It is sending the keystrokes to the application, but it isn't working the same way as the "Send" function would. In short, "Send" functions how I want the keystroke to function in the application, while "ControlSend" will only fill a bit of text into one of the elements of the application. I've been investigating this for a bit, reading through every forum I can find to no avail. I think some knowledge about the differences between "Send" and ControlSend" would be very helpful here. I've been trying to discern that myself currently. Edited February 19, 2013 by noober Link to comment Share on other sites More sharing options...
DeltaRocked Posted February 19, 2013 Share Posted February 19, 2013 and which application that might be? Link to comment Share on other sites More sharing options...
noober Posted February 19, 2013 Author Share Posted February 19, 2013 Would the application effect the way that "Send" and "ControlSend" pass keystroke events? Link to comment Share on other sites More sharing options...
noober Posted February 19, 2013 Author Share Posted February 19, 2013 If so, perhaps you could show me an example? Link to comment Share on other sites More sharing options...
jdelaney Posted February 19, 2013 Share Posted February 19, 2013 I think you should show us an example of what you are attempting, so we can give you pointers. Include a printout of the auto info tool's output on the control you are attempting to controlsend to. 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...
Moderators Melba23 Posted February 19, 2013 Moderators Share Posted February 19, 2013 noober,I have lifted your "5 post" restriction so you can continue to post should you find the need. The app to which you "Send/ControlSend" can indeed make a difference to the correct functioning of the commands. We cannot really offer you an example as it is very specific to the app in question. So please tell us the app you are trying to automate and, if possible, the output of the Window Info Tool (C:Program FilesAutoIt3Au3Info.exe if you have a standard install) when used on the control in question. Without that information we are pretty much unable to help you further. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
noober Posted February 19, 2013 Author Share Posted February 19, 2013 Here is the output of Au3info.exe; >>>> Window <<<< Title: Shaiya Class: GAME Position: 436, 75 Size: 816, 638 Style: 0x94CB0000 ExStyle: 0x00000100 Handle: 0x00150268 >>>> Control <<<< Class: Instance: ClassnameNN: Name: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: >>>> Mouse <<<< Position: 257, 178 Cursor ID: 0 Color: 0x866430 >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< >>>> Hidden Text <<<< -crosses fingers- Link to comment Share on other sites More sharing options...
noober Posted February 19, 2013 Author Share Posted February 19, 2013 Here is the code; Opt("SendKeyDownDelay", 55) Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{DEL}", "Terminate") $timeS = 999 $timeL = 1555 $key = "1" $controlid = "" $text = "" $winList = WinList("Shaiya") While 1 For $i = 1 to $winList[0][0] $title = $winList[$i][0] $handle = $winList[$i][1] $slpL = Random($timeS, $timeL) Sleep($slpL) ControlSend($handle,$text,$controlid,$key) Next WEnd Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Standing by..', 0, 0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 19, 2013 Moderators Share Posted February 19, 2013 noober,Title: ShaiyaClass: GAMEAnd this type of app is very likely to mess around with Send/ControlSend - which is why we asked. Unfortunately you appear to have missed the Forum rules when you joined. Please read them now (there is also a link at bottom right of each page) - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. See you soon with a legitimate question I hope. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts