Windows 7 - invert selection, set details view/list view (trigger Explorer/Internet Explorer menu items) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Windows 7 - invert selection, set details view/list view (trigger Explorer/Internet Explorer menu items)  Topic is solved

31 Jan 2017, 09:43

Windows 7: invert selection and set details/list view programmatically

Code: Select all

q::
ControlGet, hCtl, Hwnd,, SHELLDLL_DefView1, A

PostMessage, 0x111, 28706, 0,, % "ahk_id " hCtl ;edit, invert selection
PostMessage, 0x111, 28747, 0,, % "ahk_id " hCtl ;view, details
PostMessage, 0x111, 28753, 0,, % "ahk_id " hCtl ;view, list
PostMessage, 0x111, 28705, 0,, % "ahk_id " hCtl ;edit, select all
PostMessage, 0x111, 31492, 0,, % "ahk_id " hCtl ;view, sort by, name
return
Internet Explorer 11: save as

Code: Select all

;seems to work on both control types
;change NN in TabWindowClassNN / Shell DocObject ViewNN to refer to other tabs
q::
ControlGet, hCtl, Hwnd,, TabWindowClass1, A
ControlGet, hCtl, Hwnd,, Shell DocObject View1, A

PostMessage, 0x111, 258, 0,, % "ahk_id " hCtl ;file, save as...
return
Well that's what happens when you never ever give up.

Useful link:
[huge ToolTip appears showing menu item IDs for context menu]
Get Info from Context Menu - Scripts and Functions - AutoHotkey Community
https://autohotkey.com/board/topic/1975 ... text-menu/

Btw if there is a window spy that can work on a context menu,
that would be really useful, the spies I came across,
need you to drag cross hairs onto the context menu, but that makes the menu disappear.
Last edited by jeeswg on 16 Jul 2017, 17:07, edited 2 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Windows 7 - invert selection, set details view/list view (Explorer/Internet Explorer PostMessage/SendMessage)

31 Jan 2017, 17:16

Are there any obstacles stopping a PostMessage/SendMessage 32-bit/64-bit spy/detector
program being written in AutoHotkey?
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
qwerty12
Posts: 468
Joined: 04 Mar 2016, 04:33
Contact:

Re: Windows 7 - invert selection, set details view/list view (Explorer/Internet Explorer PostMessage/SendMessage)

31 Jan 2017, 17:56

jeeswg wrote:Are there any obstacles stopping a PostMessage/SendMessage 32-bit/64-bit spy/detector
program being written in AutoHotkey?
Inaccuracies abound, so you'll want a second opinion, but this is the way I see it in theory:

If you mean something like Spy++, kinda. I think Spy++ works by using a WH_CALLWNDPROC hook inside the target process. When the hook procedure is in a DLL, SetWindowsHookEx handles the injection of the DLL into the target process and all works well.

Now, there is a DLL version of AutoHotkey by HotkeyIt, so I don't think it's impossible, but just harder. I would use a host script with InjectAhkDll to inject AutoHotkey_H into the process (SetWindowsHookEx would be out because any function written inside a script loaded by AutoHotkey_H.dll wouldn't actually belong to the DLL proper), load a script that calls SetWindowsHookEx once inside the script and then find a suitable form of IPC to relay the results back to your host...
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Windows 7 - invert selection, set details view/list view (Explorer/Internet Explorer PostMessage/SendMessage)

01 Feb 2017, 13:09

Thanks, this is a really good response.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
sancarn
Posts: 224
Joined: 01 Mar 2016, 14:52

Re: Windows 7 - invert selection, set details view/list view (Explorer/Internet Explorer PostMessage/SendMessage)

20 Jun 2017, 09:29

qwerty12 wrote:Now, there is a DLL version of AutoHotkey by HotkeyIt, so I don't think it's impossible, but just harder. I would use a host script with InjectAhkDll to inject AutoHotkey_H into the process (SetWindowsHookEx would be out because any function written inside a script loaded by AutoHotkey_H.dll wouldn't actually belong to the DLL proper), load a script that calls SetWindowsHookEx once inside the script and then find a suitable form of IPC to relay the results back to your host...
From my own research it seems like you will need to write an own C++ based dll to get this working. I don't think injecting any old DLL into a process will do anything. I think that perhaps one of the best ways to do it would be to send a copy of all messages to a named pipe. AHK can hook onto changes in the pipe fairly easily I'd assume. One would just need that DLL to initiate the process. Another more complicated setup would be to raise COM Events for each hook. It would be significantly more powerful as you could easily filter out the messages you want to see.

@jeeswg did you by any chance figure out how to achieve this?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Windows 7 - invert selection, set details view/list view (trigger Explorer/Internet Explorer menu items)

20 Jun 2017, 09:47

I haven't tried to write a window spy to receive messages in AHK yet. But I did once use AutoHotkey_H to inject an AHK dll (AutoHotkeyMini.dll) into Notepad to set the colour of the Edit control. Setting the colour involved receiving messages, so perhaps that's an approach you could try.
Last edited by jeeswg on 20 Jun 2017, 10:27, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
sancarn
Posts: 224
Joined: 01 Mar 2016, 14:52

Re: Windows 7 - invert selection, set details view/list view (trigger Explorer/Internet Explorer menu items)

20 Jun 2017, 10:12

I too just used Autohotkey_L to inject the AHKMini dlll into notepad (just following Hotkeyit's example linked by qwerty12). It doesn't surprise me that AHK.dll was running code but it surprised me that Hotkeyit has implemented a way to get at the injected object! Crazy stuff!

For the above did you just use a OnMessage() function to call a function to send messages back to the notepad control?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Windows 7 - invert selection, set details view/list view (trigger Explorer/Internet Explorer menu items)

20 Jun 2017, 10:25

Not OnMessage, I used: RegisterCallback function and SetWindowLong via DllCall. I would suppose that AHK sets up each GUI window/control it makes to work with OnMessage, so RegisterCallback would be necessary for windows/controls that AHK didn't itself make. Haha it is pretty crazy.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
sancarn
Posts: 224
Joined: 01 Mar 2016, 14:52

Re: Windows 7 - invert selection, set details view/list view (trigger Explorer/Internet Explorer menu items)

20 Jun 2017, 11:32

jeeswg wrote:Not OnMessage, I used: RegisterCallback function and SetWindowLong via DllCall. I would suppose that AHK sets up each GUI window/control it makes to work with OnMessage, so RegisterCallback would be necessary for windows/controls that AHK didn't itself make. Haha it is pretty crazy.
Hmmm I guess SetWindowLong only has permission to run, if it is called on the same process which the caller belongs to... Because I also tried to use SetWindowLong from AHK_L directly on another program and got access denied no matter which way I tried.

Will definitely try this! It may even be good as a general 'library' for getting messages from other processes...
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Windows 7 - invert selection, set details view/list view (Explorer/Internet Explorer PostMessage/SendMessage)

23 Aug 2017, 16:38

sancarn wrote:@jeeswg did you by any chance figure out how to achieve this?
I've posted a prototype window spy here:
how to dll Inject - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 82#p166682

That's as far as I wanted to go with working on a window spy, although currently it has some problems to do with crashing when you want to either close the target program or close AutoHotkey.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], inseption86, narej, Rohwedder and 190 guests