Get Text of Option Highlighted in Context Menu

Get help with using AutoHotkey and its commands and hotkeys
Shotdox
Posts: 1
Joined: 20 Jun 2018, 09:42

Get Text of Option Highlighted in Context Menu

20 Jun 2018, 10:01

Hi,

I have been trying to write a simple script that opens up the windows sound settings and Disables/Enables my speakers, so that I can switch between my headphones and speakers with a key press.

So far I have:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Which disables my speakers as I want, but I want the same key to enable my speakers as well so I want something more like this:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



I have no idea how to get what the highlighted option is though, I have tried ControlGetFocus and ControlGetText, but they give "SysListView321" and "Select a playback device below to modify its settings:"

I have not used ahk before and any help would be appreciated!

Thanks
User avatar
TLM
Posts: 1323
Joined: 01 Oct 2013, 07:52

Re: Get Text of Option Highlighted in Context Menu

20 Jun 2018, 14:30

You have to loop through the listview's items to get each rows text.
Here's an example of such a loop

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

You just have to replace the Msgbox blocks with your code.
hth

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 78 guests