Jump to content

ControlClick not working as expected


doonyakka
 Share

Recommended Posts

Hi,

I'm trying to get Windows Desktop Search to mimic a behaviour of Google Desktop, whereby the search box is hidden until you press a key combination, which shows the box, focuses it and lets you start typing straight away. I've got as far as hiding and making the box visible, but I can't get ControlClick to place the cursor in the right place. I've used the Window Info Tool to get the correct title, class and ID for the combo box, but I'm not having any luck with it. MouseClick will do it, but it's an ugly solution.

Here's the Info Tool summary:

>>>> Window <<<<

Title: Deskbar

Class: BaseBar

Position: 455, 328

Size: 296, 71

Style: 0x16CC0000

ExStyle: 0x00000180

Handle: 0x001900F2

>>>> Control <<<<

Class: ComboBoxEx32

Instance: 1

ClassnameNN: ComboBoxEx321

Name:

Advanced (Class): [CLASS:ComboBoxEx32; INSTANCE:1]

ID: 2

Text: MSNTB_Window

Position: 0, 5

Size: 288, 22

ControlClick Coords: 38, 12

Style: 0x56010041

ExStyle: 0x00000004

Handle: 0x0029009E

>>>> Mouse <<<<

Position: 497, 367

Cursor ID: 0

Color: 0xF3FFFF

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<

MSN Toolbar

>>>> Hidden Text <<<<

MSNTB_Window

and here's the code I've written (I commented the solution using MouseClick. I've also tried all sorts of combinations of title, class, ID and coords with ControlClick):

#include <Misc.au3>

WinSetState("Deskbar", "", @SW_HIDE)

HotKeySet("^{down}", "deskbarShow")

While 1
    Sleep(10)
WEnd

Func deskbarShow()
    WinSetState("Deskbar", "", @SW_SHOW)
    WinActivate("Deskbar")
    ControlClick("Deskbar", "", "[ID:2]")
    ;MouseClick("left", 500, 365)
    WinWaitNotActive("Deskbar")
    WinSetState("Deskbar", "", @SW_HIDE)
EndFunc   ;==>deskbarShow

I also tried the following instead of ControlClick:

$handle = ControlGetHandle("Deskbar", "", 2)
_WinAPI_SetFocus($handle)

which didn't work either.

Any idea where I've gone wrong?

Thanks!

doonyakka

Edited by doonyakka
Link to comment
Share on other sites

I can't get ControlClick to place the cursor in the right place

Have you try this ?

Func deskbarShow()
    WinSetState("Deskbar", "MSN Toolbar", @SW_SHOW)
    WinActivate("Deskbar", 'MSN Toolbar')
    WinWaitActive ("Deskbar", 'MSN Toolbar')
    GUICtrlSetCursor ( 'ComboBoxEx321', 4 )
    ControlFocus ( 'Deskbar', 'MSN Toolbar', 'ComboBoxEx321' )
    WinWaitNotActive("Deskbar", 'MSN Toolbar')
    WinSetState("Deskbar", "MSN Toolbar", @SW_HIDE)
EndFunc   ;==>deskbarShow

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Have you try this ?

Func deskbarShow()
    WinSetState("Deskbar", "MSN Toolbar", @SW_SHOW)
    WinActivate("Deskbar", 'MSN Toolbar')
    WinWaitActive ("Deskbar", 'MSN Toolbar')
    GUICtrlSetCursor ( 'ComboBoxEx321', 4 )
    ControlFocus ( 'Deskbar', 'MSN Toolbar', 'ComboBoxEx321' )
    WinWaitNotActive("Deskbar", 'MSN Toolbar')
    WinSetState("Deskbar", "MSN Toolbar", @SW_HIDE)
EndFunc   ;==>deskbarShow

I hadn't tried that, but it worked perfectly! Thanks! Any idea why ControlClick doesn't work here?

Cheers,

doonyakka

PS. If anyone wants to use this, note that the single quotes needs to be changed to double quotes.

Link to comment
Share on other sites

Try

ControlClick("Deskbar", "", "2")

or

ControlClick("Deskbar", "", "[CLASS:ComboBoxEx32; INSTANCE:1]")

I did try both of those before posting my original question. They should work, right? But they don't ;)

Anyway, wakillion's solution worked fine.

Edited by doonyakka
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...