Jump to content

[Solved] Using Winspector with AutoIt


Zohar
 Share

Recommended Posts

Hello

In an old post, a user asked "What is winspector?",

and got this reply:

Very handy for working out how to programmatically get a piece of software to do something.

I use it to figure out what Windows Message is sent when I select a menu item from a tray icon (for instance).

After that, if I ever want to automate that selection within an AutoIt script, I just need to know the code that Winspector showed me.

And my question is:

If I use Winspector, what Windows Message should I capture, in order to find out what is the appropriate code for the MenuItem I Selected?

I asume it should be WM_COMMAND with a wparam that contains the MenuItem's ID,

however, If I try it on Windows Live Messenger for example, I don't seem to capture any such message.

If to take a specific example that we can learn this on,

Let's say I want to make a HotKey that will Set my Windows Live Messenger to "Away", and another HotKey to Set to "Available".

Thank you

Edited by Zohar
Link to comment
Share on other sites

Hello

In an old post, a user asked "What is winspector?",

and got this reply:

And my question is:

If I use Winspector, what Message should I capture, in order to find out what is the appropriate code for the MenuItem I Selected?

If to take a specific example that we can learn this on,

Let's say I want to make a HotKey that will Set my Windows Live Messenger to "Away", and another HotKey to Set to "Available".

Thank you

Use the AutoIt Window Info in the AutoIt v3 start menu folder, or use the au3recorder available in scite (Alt+F6)

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Hello FireFox

Use it for what?

It cannot capture Windows Messages..

Then you won't be able to get what you want with Control functions.

What you need is to call user32 dll with _SendMessage function to get what you want but it will be more difficult :D

Cheers, FireFox.

Link to comment
Share on other sites

Hello FireFox.

Yes, I know I need to SendMessage,

but as I wrote in the first post here, I need to know what Message is sent when I click a specific MenuItem.

That's what I am asking about..

and I know AutoIt Info Tool will not help me with this, because it does not capture Windows Messages.

That's why I mentioned Winspector.

Edited by Zohar
Link to comment
Share on other sites

Hello FireFox.

Yes, I know I need to SendMessage,

but as I wrote in the first post here, I need to know what Message is sent when I click a specific MenuItem.

That's what I am asking about..

and I know AutoIt Info Tool will not help me with this, because it does not capture Windows Messages.

That's why I mentioned Winspector.

Ops :D, sorry; i'm not english so you can understand that sometimes I don't understand really what's the subject :D

Cheers, FireFox.

Link to comment
Share on other sites

Hi PsaltyDS

Thank you very much for your reply.

I was told about that message, however when I try to capture such one, when RightClicking the Windows Live Messenger Tray Icon,

and Choosing Status\Available, or Status\Away,

I do not catch such message..

:/

Link to comment
Share on other sites

  • Moderators

Hi PsaltyDS

Thank you very much for your reply.

I was told about that message, however when I try to capture such one, when RightClicking the Windows Live Messenger Tray Icon,

and Choosing Status\Available, or Status\Away,

I do not catch such message..

:/

And you won't. Those menus are created dynamically, after use they are destroyed.

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.

Link to comment
Share on other sites

  • Moderators

The fact that the ContextMenu is created dynamically, doesn't mean it doesn't send a Windows Message after a MenuItem is clicked..

So I should somehow get the mesasge no?

I'm confused... so confused.

Are you trying to get the message from an external app ( Assuming so since you mentioned Windows Live Messenger)? You can find the hwnd of the tray icon, then do a loop waiting for the pop up menu, but if it is an external app, how are you hooking the windows message ( assuming you are, because you said you're not getting the message)?

If it's an AutoIt app that you wrote, then the Tray* functions should suffice.

I think from this point, you need to clarify much much more, and some code that you're attempting to use would help quite a bit as well.

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.

Link to comment
Share on other sites

I really wasn't clear?

ok.

All I am looking for, is to get the CommandID of a MenuItem,

so that I can then Automate the application(i.e. Messenger) better, without opening the ContextMenu and doing Send(<MenuItem Accelerator>).

I do not need hooks since I do not need to catch it in run time..

only to catch it once, in order to know the CmdID, and then use SendMessage() to send it.

As I wrote in the first post here, I am trying to do what LxP said:

Very handy for working out how to programmatically get a piece of software to do something.

I use it to figure out what Windows Message is sent when I select a menu item from a tray icon (for instance).

After that, if I ever want to automate that selection within an AutoIt script, I just need to know the code that Winspector showed me.

Edited by Zohar
Link to comment
Share on other sites

  • Moderators

I really wasn't clear?

ok.

All I am looking for, is to get the CommandID of a MenuItem,

so that I can then Automate the application(i.e. Messenger) better, without opening the ContextMenu and doing Send(<MenuItem Accelerator>).

I do not need hooks since I do not need to catch it in run time..

only to catch it once, in order to know the CmdID, and then use SendMessage() to send it.

As I wrote in the first post here, I am trying to do what LxP said:

I recently wrote a system tray automation udf for a client.

I searched hi and low for a way to just use SendMessage() to a context menu with a M* command to no avail.

My mention of the dynamics of the menu actually had a point... No matter what message (If you find it) you'll need to know the hwnd of the parent ( to get the hwnd of the menu ) to Use SendMessage() properly.

This requires opening up the tray menu.

If that's indeed what you're trying to do, these are some steps I took to do it programmatically.

Find the tray icon.

Click on it to open it up (using control click or mouseclick) so it creates the menu

Find the parent hwnd to the menu

Get the menu hwnd

Use the _GUICtrlMenu* functions to then Find String

Return the menu id ( if that's what you want, or just take an action )

Now for sub menus... You'll have to click on the menu that opens the sub menu and repeat the last 3.

If I'm way off base, then I'll leave the thread alone.

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.

Link to comment
Share on other sites

Hello SmOke_N and Thank you for your reply!

You perfectly understood me..

and I understand your solution,

but I wonder about one thing:

Instead of the solution you used(finding the CmdID programmatically), wouldn't it be possible to Catch the CmdID via Winspector/Spy++?

(Instead of writing the code you just mentioned).

For some reason, I succeed to catch the WM_COMMAND If I click a MenuItem in the Menu that is inside the Messenger Window,

However, I do not succeed to catch the WM_COMMAND If I click a MenuItem in the Menu that opens for the TaskBar Tray Icon.

And that's where my problem is.

And it's not just in Messenger..

In most applications that I experience with,

Catching the WM_COMMAND succeeds if I play with the Menu inside the Window,

And Fails If I play with the Tray Menu.

Doesn't the Popup Menu of the Tray Icon send a Window Message to the parent application?

Or maybe I should spy on it differently when I am clicking MenuItems in the TaskBar Tray Menu?

I hope someone can help me..

Edited by Zohar
Link to comment
Share on other sites

  • Moderators

Hello SmOke_N and Thank you for your reply!

You perfectly understood me..

and I understand your solution,

but I wonder about one thing:

Instead of the solution you used(finding the CmdID programmatically), wouldn't it be possible to Catch the CmdID via Winspector/Spy++?

(Instead of writing the code you just mentioned).

For some reason, I succeed to catch the WM_COMMAND If I click a MenuItem in the Menu that is inside the Messenger Window,

However, I do not succeed to catch the WM_COMMAND If I click a MenuItem in the Menu that opens for the TaskBar Tray Icon.

And that's where my problem is.

And it's not just in Messenger..

In most applications that I experience with,

Catching the WM_COMMAND succeeds if I play with the Menu inside the Window,

And Fails If I play with the Tray Menu.

Doesn't the Popup Menu of the Tray Icon send a Window Message to the parent application?

Or maybe I should spy on it differently when I am clicking MenuItems in the TaskBar Tray Menu?

I hope someone can help me..

Yes, you seem to have run into the road block I did.

I found that that menu is not created at time of start up, but created when a "PostMessage+KeyMessage" (MouseClick/ControlClick) was sent to it.

That being said... You're kind of SOL, unless someone cares to prove me wrong.

Good luck though (Seriously).

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.

Link to comment
Share on other sites

  • 2 years later...

If anyone comes to this thread, then the solution is pretty simple.

Using Spy++, you just need to press CTRL-M in Spy++,

and then choose there "Windows of the same Thread", or "Windows of the same Process".

That will catch the message.

(I assume there might a way to do it with Winspector too, however I stopped using it, and I use Spy++ only - it does a great job)

Edited by Zohar
Link to comment
Share on other sites

  • 4 years later...
On 9/10/2009 at 5:23 PM, Zohar said:

I really wasn't clear?  
(*I knew what you were after, even though I had no idea of half the under_the_hood autoIt/autoHotKey/winVoodoocmdcntrlyada...)

All I am looking for, is to get the CommandID of a MenuItem,so that I can then Automate the application(i.e. Messenger) better, without opening the ContextMenu and doing Send(<MenuItem Accelerator>).  
(**excellent elaboration: 10/10:)

I do not need hooks since I do not need to catch it in run time..
(***good to know, re hooks)

only to catch it once, in order to know the CmdID, and then use SendMessage() to send it.
(****presumably the same ID as those used by AHK PostMessage() ?

As I wrote in the first post here, I am trying to do what LxP said:
(*****why I'm here, same reason as you I thinkl; thanks for sharing, and persevering! reading on, hopefully not in vain:)

PS thanks to Smoky too!!

 

Edited by JonnyHotchkiss
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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