C# - Sending messages to Google Chrome from C# application

后端 未结 4 708
北恋
北恋 2020-12-14 18:00

I\'ve been searching around, and I haven\'t found how I would do this from C#.

I was wanting to make it so I could tell Google Chrome to go Forward,

4条回答
  •  抹茶落季
    2020-12-14 18:40

    You can get the window name easily using Visual Studio's Spy++ and pressing CTRL+F, then finding chrome. I tried it and got

    "Chrome_VistaFrame" for the out window. The actual window with the webpage in is "Chrome_RenderWidgetHostHWND".

    As far as WM_COMMAND goes - you'll need to experiment. You'll obviously want to send button clicks (WM_MOUSEDOWN of the top off my head). As the back,forward buttons aren't their own windows, you'll need to figure out how to do this with simulating a mouse click at a certain x,y position so chrome knows what you're doing. Or you could send the keyboard shortcut equivalent for back/forward and so on.

    An example I wrote a while ago does this with trillian and winamp: sending messages to windows via c# and winapi

    There's also tools out there to macro out this kind of thing already, using a scripting language - autoit is one I've used: autoit.com

提交回复
热议问题