Jump to content

Recommended Posts

Posted

Hi,

I have an VB interface that has toolstrip. I need autoit to click a particular button in the toolstrip but the window info window shows same class ID for all the button in the toolstrip. Can you please let me know what should be done in this particular situation?

Awaiting your response!

Thanks!

Posted

;where $x and $y are the coordinates of the button from the top-left of the control... put AU3Info in Client mode
_MouseClick(ControlGetHandle("TITLE OF VB APP", "", "CLASSNAME OR CONTROL ID"), "left", $x, $y)

Func _MakeLong($LoWord, $HiWord)
    Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

Func _MouseClick($hWnd, $button, $x, $y, $times=1, $delay=250)
    If $hWnd = 0 Then
        SetError(-1)
        Return
    EndIf
    
    Local $ix
    Local $lParam = _MakeLong($x, $y)
    Local $user32 = DllOpen("user32.dll")
    
    $button = StringLower($button)
    
    If $button = "left" Then
        For $ix = 1 To $times
            DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", $lParam)
            DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 1, "long", $lParam)
            DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", $lParam)
            
            If $ix < $times Then Sleep($delay)
        Next
    ElseIf $button = "right" Then
        For $ix = 1 To $times
            DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", $lParam)
            DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x204, "int", 2, "long", $lParam)
            DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x205, "int", 0, "long", $lParam)
            
            If $ix < $times Then Sleep($delay)
        Next
    Else
        SetError(-2)
        If $user32 <> -1 Then DllClose($user32)
        Return
    EndIf
    If $user32 <> -1 Then DllClose($user32)
EndFunc

  • 2 weeks later...
Posted

  Outshynd said:

;where $x and $y are the coordinates of the button from the top-left of the control... put AU3Info in Client mode
_MouseClick(ControlGetHandle("TITLE OF VB APP", "", "CLASSNAME OR CONTROL ID"), "left", $x, $y)
Thanks..but where is user32.dll where does this call from? i don't hve that dll file with me?

all I added was this for example:

Run("outlook.Exe")

Opt("WinWaitDelay",5000)

Opt("WinTitleMatchMode", 2)

WinWait("Outlook")

$x = 190

$y = 30

_MouseClick(ControlGetHandle("Outlook", "", "Menu Bar"), "left", $x, $y)

..... (your code)

but didn't work please let me know asap!

Awaiting your response!

Thanks!

Posted (edited)

Is "Menu Bar" the ClassNameNN of Outlook? I don't know but it sure doesn't look right.

Also, if AutoIt runs, you have user32.dll. It comes with Windows.

Edited by Outshynd
Posted

  Outshynd said:

Is "Menu Bar" the ClassNameNN of Outlook? I don't know but it sure doesn't look right.

Also, if AutoIt runs, you have user32.dll. It comes with Windows.

My Mistake... it is MsoCommandBar1...Anyways, I changed that but didn't work

THis is Active Window Info!

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: Inbox - Microsoft Outlook

Class: rctrl_renwnd32

Size: X: 1 Y: 1 W: 1023 H: 767

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Client: X: 187 Y: 16

Cursor ID: 2

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0x00025C Dec: 604

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 0 Y: 0 W: 1015 H: 27

Control ID:

ClassNameNN: MsoCommandBar1

Text: Menu Bar

Style: 0x56000000

ExStyle: 0x00000000

And I changed the code to

Run("C:\Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE" )

WinWait("Outlook")

$x = 187

$y = 16

_MouseClick(ControlGetHandle("Outlook", "", "MsoCommandBar1"), "left", $x, $y)

... and your code down here..

but still I don't see it working...!! :P

Do you have user32.dll file.. if so please send it..!! let me try it out because I don't see user32.dll in my computer!!??

  • Moderators
Posted

  Ram said:

My Mistake... it is MsoCommandBar1...Anyways, I changed that but didn't work

THis is Active Window Info!

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: Inbox - Microsoft Outlook

Class: rctrl_renwnd32

Size: X: 1 Y: 1 W: 1023 H: 767

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Client: X: 187 Y: 16

Cursor ID: 2

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0x00025C Dec: 604

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 0 Y: 0 W: 1015 H: 27

Control ID:

ClassNameNN: MsoCommandBar1

Text: Menu Bar

Style: 0x56000000

ExStyle: 0x00000000

And I changed the code to

Run("C:\Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE" )

WinWait("Outlook")

$x = 187

$y = 16

_MouseClick(ControlGetHandle("Outlook", "", "MsoCommandBar1"), "left", $x, $y)

... and your code down here..

but still I don't see it working...!! :P

Do you have user32.dll file.. if so please send it..!! let me try it out because I don't see user32.dll in my computer!!??

Start >> Search >> All Files >> User32.dll

Cool that you have one too huh?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted (edited)

  Outshynd said:

Also, if AutoIt runs, you have user32.dll. It comes with Windows.

^

Are you getting any error? You may want to do something like MsgBox(64, "ControlHandle", ControlGetHandle("Outlook", "", "MsoCommandBar1")) to make sure it's not returning zero.

Edited by Outshynd
Posted

  Outshynd said:

^

Are you getting any error? You may want to do something like MsgBox(64, "ControlHandle", ControlGetHandle("Outlook", "", "MsoCommandBar1")) to make sure it's not returning zero.

When I put the above I get a msg box with (0x002b037c) and the numbers keep changing everytime....Not sure what to do??

Posted

It seems like I'm having the exact same problem as Ram; I am trying to work with a program that has a bar of tabs all of which have the same ID and classname. I posted a topic in support but so far no one has responded... I have some pics of the toolbar and autoit info maybe it will help someone shed some light on this for us.

Heres my topic http://www.autoitscript.com/forum/index.php?showtopic=39075

Also I used LxPs _ControlGetHandleByPos and I get a number like what Ram got (0x00B00592).

Thanks,

Andrew

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

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
  • Recently Browsing   0 members

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