I am trying to click on a control, and select from the drop down list. Because my browser size and position varies between two monitors, and day to day, I am struggling how to make the selection. Any help will be gratefully accepted. I have been trying ControlFocus and other commands and cannot get any traction.
Relative position has always defeated me. As I move from screen to screen and resize my browser windows it seems that the positions of objects and controls scale and move sightly. Even aiming at the center of them is a hit of miss deal.
For this question I am using Craig's List in Charleston, South Carolina, https://charleston.craigslist.org/search/sss. I would like to select "Tools" from the drop down list which is by default "All".
There are three drop down boxes on this page.
1. Charleston:
2. for sale
3. all (The drop down box I would like to select from.)
For this drill, I am trying to select "Tools" from the "all" drop down list.
Windows Spy only changes the Mouse Position information as I move between the three drop downs. Yes, I have tried this with Windows Spy unfrozen (Win + A).
The ClassNN: Chrome_RenderWidgetHostHWND1
Commands such as ControlFocus suggest I use "ahk_id %ControlHwnd%". However I am unable to devine what "ahk_id %ControlHwnd%" means.
I am lost, please help me out of this swamp or throw me an anchor and finish me off!
Thanks, Craigm
Trying to click on a Craig's List control
Trying to click on a Craig's List control
- Attachments
-
- Spy2.jpg (7.39 KiB) Viewed 518 times
-
- Spy1.jpg (85.11 KiB) Viewed 518 times
Re: Trying to click on a Craig's List control
Below is the function I use to center the passed window. Just pass in the Craigslist window (raleigh free stuff - craigslist) name as ctrwin.
[Mod edit: [code][/code] tags added.]
Then just use AutoHotKey to resize the window to your desired size and the drop downs will be in the same place every time.
PS. It is poor form to post a new issue inside someones request for help. Start a new post, please.
Good Luck, CraigM
Code: Select all
ctrwin := raleigh free stuff - craigslist
CenterWindow (ctrwin) ;Centers the called window on the screen, it does not change its shape or size.
;Function definition
/*
CenterWindow (ctrwin) centers the passed window on the screen, it does not change its
shape or size. Put it anywhere in your script just not in any other functions or key definitions.
*/
CenterWindow(ctrwin)
{
WinGetPos,,, Width, Height, %WinTitle%
WinMove, %WinTitle%,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2)
}
Return
Then just use AutoHotKey to resize the window to your desired size and the drop downs will be in the same place every time.
PS. It is poor form to post a new issue inside someones request for help. Start a new post, please.
Good Luck, CraigM
Re: Trying to click on a Craig's List control
Welcome back after many years! But I am not sure to what or whom you are referring here.
Just a remark re your post above - this is not a valid function call:
Code: Select all
CenterWindow (ctrwin)
PS: This also doesn't make syntax-wise:
Code: Select all
ctrwin := raleigh free stuff - craigslist
In an expression, a literal string needs to be quoted: "..." --> ctrwin := "raleigh free stuff - craigslist"
And finally, the two uses of Wintitle in your function should be replaced with ctrwin, I suppose.
Please have another look at your posted code...
Last edited by gregster on 01 May 2022, 15:42, edited 1 time in total.
Re: Trying to click on a Craig's List control
Since you are targeting a Web browser, you are probably heading down the wrong path with the control.
You might need some sort of JavaScript approach that is beyond me. I did have luck with the following "poor man's" script.
Simpler:
You might need some sort of JavaScript approach that is beyond me. I did have luck with the following "poor man's" script.
Code: Select all
Run, https://charleston.craigslist.org/search/
Sleep, 2000
Send {Tab 4}!{Down}tt`n
Code: Select all
Run, https://charleston.craigslist.org/search/tla
Re: Trying to click on a Craig's List control
RapidAPI offers an (experimental) Craigslist API access as well: https://rapidapi.com/aidangig/api/craigslist-search/
From 2019: https://towardsdatascience.com/web-scraping-craigslist-a-complete-tutorial-c41cea4f4981
From 2019: https://towardsdatascience.com/web-scraping-craigslist-a-complete-tutorial-c41cea4f4981
Who is online
Users browsing this forum: mikeyww and 144 guests