Trying to click on a Craig's List control

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
CraigM
Posts: 17
Joined: 21 Sep 2017, 13:07

Trying to click on a Craig's List control

21 Sep 2017, 14:08

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
Attachments
Spy2.jpg
Spy2.jpg (7.39 KiB) Viewed 520 times
Spy1.jpg
Spy1.jpg (85.11 KiB) Viewed 520 times
CraigM
Posts: 17
Joined: 21 Sep 2017, 13:07

Re: Trying to click on a Craig's List control

01 May 2022, 15:18

Below is the function I use to center the passed window. Just pass in the Craigslist window (raleigh free stuff - craigslist) name as ctrwin.

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
[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
gregster
Posts: 9002
Joined: 30 Sep 2013, 06:48

Re: Trying to click on a Craig's List control

01 May 2022, 15:36

CraigM wrote:
01 May 2022, 15:18
PS. It is poor form to post a new issue inside someones request for help. Start a new post, please.
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)
There is no space allowed between function name and parameters in parentheses: CenterWindow(ctrwin)

PS: This also doesn't make syntax-wise:

Code: Select all

ctrwin := raleigh free stuff - craigslist
If you assign smth to a variable with the := operator, the right side needs to be an expression.
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.
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Trying to click on a Craig's List control

01 May 2022, 15:47

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.

Code: Select all

Run, https://charleston.craigslist.org/search/
Sleep, 2000
Send {Tab 4}!{Down}tt`n
Simpler:

Code: Select all

Run, https://charleston.craigslist.org/search/tla

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Holarctic, mikeyww, robnicholson, Rohwedder, Swiftly9767 and 351 guests