Jump to content

Click on Toolbar icon


Recommended Posts

This is the info of the interface:

Window
Title:    Password Safe
Class:    #32770

Control
Class:    ToolbarWindow32
Instance:    2
ClassnameNN:    ToolbarWindow322
Name:    
Advanced (Class):    [CLASS:ToolbarWindow32; INSTANCE:2]

 ToolsBar
1:    32003    Make New Database
2:    32002    Open Another Database
3:    32004    Close Database
4:    32005    Save Database
5:    0    
6:    32066    Copy Password to Clipboard
7:    32068    Copy Username to Clipboard
8:    32069    Copy Notes to Clipboard
9:    32065    Clear the clipboard contents
10:    0    

 

I wanted to click on 1:    32003    Make New Database. But unfortunately, I'm unable to click on that. Any help is much appreciated. Below are the code I tried:

$Title = "Password Safe"
$Class = "[CLASS:ToolbarWindow32; INSTANCE:2]"
    WinWaitActive($Title)
Sleep(500)
    Dim $hWnd = WinGetHandle($Title,"")
Dim $hToolBar = ControlGetHandle($hWnd, '', $Class)
    ConsoleWrite($hWnd & @TAB & $hToolBar & @LF)
_GUICtrlToolbar_ClickIndex($hToolBar, 32003)

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
Link to comment
Share on other sites

Local $sTitle = "Password Safe"
Local $sClass = "[CLASS:ToolbarWindow32; INSTANCE:2]"
WinWaitActive($sTitle)

Local $hWnd = WinGetHandle($sTitle, "")
Local $hToolBar = ControlGetHandle($hWnd, "", $sClass)
ConsoleWrite($hWnd & @TAB & $hToolBar & @LF)
ControlCommand($hWnd, "", $hToolBar, "SendCommandID", 32003)
; "SendCommandID", Command ID
; Simulates the WM_COMMAND message. Usually used for ToolbarWindow32 controls - use the ToolBar tab of Au3Info to get the Command ID.

 

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

I really appreciate the help, but I tested multiple times with no success. Nothing happen when I run the script.

 

EDIT: I'm not sure what's going on, but after I added:

 

#include <MsgBoxConstants.au3>

it's working now... scratching my head...

Edited by Queener

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
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

×
×
  • Create New...