Page 1 of 1
I'd be grateful were someone to convert this 'ComObject' code
Posted: 19 Apr 2022, 11:18
by UserNameForAH_Board
Dear all
This forum thread discusses ways of 'refreshing' file explorer windows. One of those ways is as follows. I'd be grateful were someone to convert it to the new syntax.
Code: Select all
Windows := ComObjCreate("Shell.Application").Windows
Windows.Item(ComObject(0x13, 8)).Refresh()
for Window in Windows
if (Window.Name !== "Internet Explorer")
Window.Refresh()
Re: I'd be grateful were someone to convert this 'ComObject' code
Posted: 19 Apr 2022, 16:38
by boiler
It seems that it can be this simple:
Code: Select all
for Window in ComObject("Shell.Application").Windows
if (Window.Name != "Internet Explorer")
Window.Refresh()
If someone can explain why that's not adequate, please do.
Re: I'd be grateful were someone to convert this 'ComObject' code
Posted: 16 Sep 2022, 15:24
by neogna2
boiler wrote: ↑19 Apr 2022, 16:38
If someone can explain why that's not adequate, please do.
Adequate depends on the goal. Your code refreshes all open Explorer windows but not the desktop.
To refresh both Explorer windows and desktop use
iseahound's v2 version posted today. The line that contains
(0x13, 8) is for desktop refresh. (Background on that
here.)
Re: I'd be grateful were someone to convert this 'ComObject' code
Posted: 16 Sep 2022, 20:18
by lexikos
For anyone who finds this topic while looking for help "to convert this 'ComObject' code" and not necessarily to refresh Explorer windows, the answers can easily be found by searching
v2-changes for the function names.
ComValue(vt, value) creates a wrapper object. ... This replaces
ComObjParameter(vt, value),
ComObject(vt, value) and any other names that were used with a
variant type and
value as parameters.
Source: Changes from v1.1 | AutoHotkey v2
That is all you need to do; rename the functions. You do not even need to change
!==, which was originally a typo but is now case-sensitive not-equal.
Re: I'd be grateful were someone to convert this 'ComObject' code
Posted: 02 Jul 2023, 19:22
by iseahound
Ooh I never posted these then?
Code: Select all
UpdateWindows()
{
_ttm := A_TitleMatchMode
SetTitleMatchMode 'RegEx'
for window in WinGetList("ahk_class ExploreWClass|CabinetWClass|Progman")
PostMessage 0x111 , 41504 ,,, window
SetTitleMatchMode _ttm
}
RefreshExplorer() { ; by teadrinker on D437 @ tiny.cc/refreshexplorer
local Windows := ComObject("Shell.Application").Windows
Windows.Item(ComValue(0x13, 8)).Refresh()
for Window in Windows
if (Window.Name != "Internet Explorer")
Window.Refresh()
}
Re: I'd be grateful were someone to convert this 'ComObject' code
Posted: 16 Apr 2024, 15:50
by zabbn
Thank you. Unfortunately, both of these give me
Error: Unexpected reserved word.
Text: in Windows if (Window.Name != "Internet Explorer") Window.Refresh() regKeyPath:=…
Line: 1643
File: C:\Users\XXX\global_V2.ahk
The program will exit.
But only if I #include this file 'global_V2.ahk' in the script of question.
If I use your code in a separate file (without #include), it works. How can one explain that?
Re: I'd be grateful were someone to convert this 'ComObject' code
Posted: 16 Apr 2024, 16:42
by gregster
zabbn wrote: ↑16 Apr 2024, 15:50
Thank you. Unfortunately, both of these give me
Error: Unexpected reserved word.
Text: in Windows if (Window.Name != "Internet Explorer") Window.Refresh() regKeyPath:=…
Line: 1643
File: C:\Users\XXX\global_V2.ahk
The program will exit.
But only if I #include this file 'global_V2.ahk' in the script of question.
If I use your code in a separate file (without #include), it works. How can one explain that?
Where is that file coming from?
Looks strange that
in Windows if (Window.Name != "Internet Explorer") Window.Refresh() regKeyPath:=… seems to be seen as a single line - but it would explain the error message, I guess.
I would check the contents of the file for missing line breaks.
Re: I'd be grateful were someone to convert this 'ComObject' code
Posted: 17 Apr 2024, 06:54
by zabbn
Absolutely, why didn't I think of that... Thank you very much for your response and sorry for the now obviously off-topic bump.