upperelo Posted November 9, 2014 Share Posted November 9, 2014 (edited) I'm trying to open Google Chrome, send the F6 key (to focus on the omnibox), enter a link, hit enter, send tab X amount of times, and then hit enter again. So far I have not been able to get ControlSend to properly send these keys to Chrome. I'm assuming my problem lies in ControlSend's controID parameter. I've used the Window Info Tool and found that the omnibox itself does not have a control ID or any information I can use to access it. ControlSend($hwnd, "", "", "{F6}") ; does not work ControlSend($hwnd, "", 192770240, "{F6}") ; does not work, 192770240 is the control ID of Chrome_RenderWidgetHostHWND I've tried many different ways of approaching this but I still cannot get this work. I'm pretty sure my error is in the control ID but I'm not sure what I should pass into that parameter. Edited November 9, 2014 by upperelo Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 9, 2014 Moderators Share Posted November 9, 2014 Sounds like you may benefit more from this: Than using ControlSend/Send methods. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
upperelo Posted November 9, 2014 Author Share Posted November 9, 2014 Sounds like you may benefit more from this: Than using ControlSend/Send methods. I would really like to avoid having to install an extension on Chrome just for something as simple as this. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 9, 2014 Moderators Share Posted November 9, 2014 Saying "simple" implies you've found the solution or feel the solution is simple? Using "Control" functions without the ability of getting the hwnds/id's the "control" function requires, doesn't seem "simple" to me. In fact it seems it could ultimately produce unwanted results. Unless you're intending on using this on separate machines, I don't see what the issue is installing an extension if its solution is readily made available to you. But I digress, give the url, what we do to get to the position you're in, and maybe someone can show you a "control" themed solution. All the same, this seems to do what you've stated specifically on my machine, understandings windows and their possible layers helps. #include <winapi.au3> Local $gh_chrome = _chrome_getFirstVisibleWithTitle() If @error Then MsgBox(16 + 262144, "Error", "No window found") Exit 1 EndIf _WinAPI_SetFocus($gh_chrome) ControlSend($gh_chrome, "", 0, "{F6}") Func _chrome_getFirstVisibleWithTitle() Local $ah_wlist = WinList("[CLASS:Chrome_WidgetWin_1]") If Not IsArray($ah_wlist) Then Return SetError(1, 0, 0) For $i = 1 To UBound($ah_wlist) - 1 If String($ah_wlist[$i][0]) <> "" Then Return $ah_wlist[$i][1] Next Return SetError(2, 0, 0) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
upperelo Posted November 9, 2014 Author Share Posted November 9, 2014 (edited) Saying "simple" implies you've found the solution or feel the solution is simple? Using "Control" functions without the ability of getting the hwnds/id's the "control" function requires, doesn't seem "simple" to me. In fact it seems it could ultimately produce unwanted results. Unless you're intending on using this on separate machines, I don't see what the issue is installing an extension if its solution is readily made available to you. But I digress, give the url, what we do to get to the position you're in, and maybe someone can show you a "control" themed solution. All the same, this seems to do what you've stated specifically on my machine, understandings windows and their possible layers helps. #include <winapi.au3> Local $gh_chrome = _chrome_getFirstVisibleWithTitle() If @error Then MsgBox(16 + 262144, "Error", "No window found") Exit 1 EndIf _WinAPI_SetFocus($gh_chrome) ControlSend($gh_chrome, "", 0, "{F6}") Func _chrome_getFirstVisibleWithTitle() Local $ah_wlist = WinList("[CLASS:Chrome_WidgetWin_1]") If Not IsArray($ah_wlist) Then Return SetError(1, 0, 0) For $i = 1 To UBound($ah_wlist) - 1 If String($ah_wlist[$i][0]) <> "" Then Return $ah_wlist[$i][1] Next Return SetError(2, 0, 0) EndFunc Well by simple I just meant that but what I have to do with Chrome is simple. Navigate to a URL and click a link only once. The idea itself is simple but the solution may not. Yes, I intend to use this on separate machines so I would have to install the extension on all the systems beforehand. The problem isn't getting the window handle as I'm able to get that, the problem for me (I think) is the control ID. I just ran the script you provided and it only sends the keys if the Chrome window is focused (which I have to manually do because _WinAPI_SetFocus() doesn't seem to work). However, I know ControlSend can send to a window even if the window isn't focused, minimized, or even hidden. So why in this case does the window need to be focused? Is this because of the lack of control ID? Edited November 9, 2014 by upperelo Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 9, 2014 Moderators Share Posted November 9, 2014 Indeed. Out of curiosity. Why chrome when there is an entire IE udf available for you within AutoIt, as wells as Mozilla udfs within the example forums? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
upperelo Posted November 9, 2014 Author Share Posted November 9, 2014 Indeed. Out of curiosity. Why chrome when there is an entire IE udf available for you within AutoIt, as wells as Mozilla udfs within the example forums? I'm very familiar with the IE and FF udfs. This is a small part of a larger script that is very Chrome-specific. Either way I've gotten this for the most part to work by just focusing the window before sending any keys via WinActivate($hwnd). Thanks for your help. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 9, 2014 Share Posted November 9, 2014 Did you check that pinned thread in the examples forum that mentions Chrome? Sounds like it would be your best bet. Real automation with no extensions. But I have no idea if what you are specifically doing is supported, you will have to find that out yourself or wait for someone that have used it before. >IUIAutomation MS framework automate chrome, FF, IE, .... .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface 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