AutoHotkey recording Topic is solved
AutoHotkey recording
As a first time user, I have a simple question, the answer to which I have been unable to find in the documentation. As a beginning project, I want to be able to toggle the View parameter "Show desktop icons" by using a single key press and release (the right Logo key). This requires that I right-click on the desktop background (not on an icon) and select View/Show..." In order to do this, I need to record the action, in the manner of typical word-processor macros. At first glance, I thought there was a record capability in AutoHotkey, but I can't find it. Also, if there is such a capability, will I be able to encode the requirement that I right-click on ANY location in the background that is not already occupied by an icon or something else? If not, I may have to resort to messing with the registry. Any help with this will be appreciated.
Re: AutoHotkey recording
A recorder can be found here https://autohotkey.com/boards/viewtopic.php?f=6&t=143 - if it will suit your needs I don't know.
Re: AutoHotkey recording Topic is solved
Code: Select all
q:: ;show desktop icons (toggle) (tested on windows 7)
PostMessage, 0x111, 29698, , SHELLDLL_DefView1, ahk_class Progman ;show desktop icons (toggle)
Return
w:: ;show desktop icons (tested on windows 7)
ControlGet, vCtlStyle, Style, , SysListView321, ahk_class Progman
if !(vCtlStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
PostMessage, 0x111, 29698, , SHELLDLL_DefView1, ahk_class Progman ;show desktop icons (toggle)
Return
e:: ;hide desktop icons (tested on windows 7)
ControlGet, vCtlStyle, Style, , SysListView321, ahk_class Progman
if (vCtlStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
PostMessage, 0x111, 29698, , SHELLDLL_DefView1, ahk_class Progman ;show desktop icons (toggle)
Return
Show/hide desktop icons in Windows 7 - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/4352 ... windows-7/
(Although they didn't find a clean solution to this problem.)
Menu item IDs can be found using:
Get Info from Context Menu - Scripts and Functions - AutoHotkey Community
https://autohotkey.com/board/topic/1975 ... text-menu/
The 'Show desktop icons' menu item ID was 30988, but this didn't work as the wParam value.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: AutoHotkey recording
Something different that also works
Code: Select all
#singleinstance force
Esc::
ExitApp
F1::
ShowDesktopIcons(True)
Return
F2::
ShowDesktopIcons(False)
Return
ShowDesktopIcons(bShow := True) {
if(bShow) {
bShow := 5
}
else {
bShow := 0
}
WinGet, theDesktop, ID, ahk_class Progman
theDesktopChilds := DllCall("GetWindow", "Ptr", theDesktop, "Uint", 5) ; GW_CHILD = 5
DllCall("ShowWindow", "Ptr", theDesktopChilds, "Uint", bShow) ; SW_HIDE = 0, SW_SHOW = 5
}
Re: AutoHotkey recording
That method, retrieving the first child,
and showing/hiding it, is probably the same as:
Interesting though, as I'm collecting AHK source code/equivalent methods information!
and showing/hiding it, is probably the same as:
Code: Select all
ControlGet, hCtl, Hwnd, , SysListView321, ahk_class Progman
WinHide, ahk_id %hCtl%
Sleep 2000
ControlGet, hCtl, Hwnd, , SysListView321, ahk_class Progman
WinShow, ahk_id %hCtl%
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: AutoHotkey recording
Nice, I like it better than your sendmessage method.jeeswg wrote:Interesting though, as I'm collecting AHK source code/equivalent methods information!
I just translated some vb code I had, I didn't knew the exact AHK equivalent, I'll keep that in my lib, ty.
Re: AutoHotkey recording
Thank you all; that will give me something to chew on! I want to mark this post as solved, but it's not clear to me how to do this. There is a check mark beside each post which means "Accept this answer", but I'm not sure exactly what that does, and there doesn't appear to be a way to accept them all with one click. I will go now and try out these ideas. Thanks again.
Re: AutoHotkey recording
@ejdewan
If you click the 'Accept this answer' button on a post,
then that post gets a little green box with a white tick.
(The button's name then becomes 'Set topic as unsolved',
if you click it again, that undoes it, the green box is removed.)
You can only choose one post to be the answer.
I have never used a macro record program with AutoHotkey,
although occasionally I have checked 'View, Key history and script info'.
For a method based on key presses/mouse clicks,
this appeared to work:
I don't think there would ever be an icon at (0, 0),
but then I don't know if it is somehow possible!
==================================================
@4GForce
In general, menus work by sending WM_COMMAND := 0x111,
and a menu ID number to a window/control.
So my method is the cleanest I could think of.
If you simply make the listview control shown/hidden directly,
the tick by the 'Show desktop icon' menu item is not updated
(which admittedly isn't the end of the world).
==================================================
spy.exe which comes in the zip with HotkeyP
showed the number (wParam) 29698 (but not 30988, the menu item's ID)
when I ticked/unticked 'View, Show desktop icons'.
HotkeyP:
Freeware programs including Precise Calculator
http://petr.lastovicka.sweb.cz/others.html
==================================================
[EDIT:]
The different methods I've tested seem to work intermittently.
Possibly more likely to work if the desktop is *not* the active window.
This may or may not have something to do with Progman v. WorkerW classes.
If you click the 'Accept this answer' button on a post,
then that post gets a little green box with a white tick.
(The button's name then becomes 'Set topic as unsolved',
if you click it again, that undoes it, the green box is removed.)
You can only choose one post to be the answer.
I have never used a macro record program with AutoHotkey,
although occasionally I have checked 'View, Key history and script info'.
For a method based on key presses/mouse clicks,
this appeared to work:
Code: Select all
q::
ControlClick, x0 y0, ahk_class Progman, , R
WinWait, ahk_class #32768
ControlSend, , vd, ahk_class #32768
Return
but then I don't know if it is somehow possible!
==================================================
@4GForce
In general, menus work by sending WM_COMMAND := 0x111,
and a menu ID number to a window/control.
So my method is the cleanest I could think of.
If you simply make the listview control shown/hidden directly,
the tick by the 'Show desktop icon' menu item is not updated
(which admittedly isn't the end of the world).
==================================================
spy.exe which comes in the zip with HotkeyP
showed the number (wParam) 29698 (but not 30988, the menu item's ID)
when I ticked/unticked 'View, Show desktop icons'.
HotkeyP:
Freeware programs including Precise Calculator
http://petr.lastovicka.sweb.cz/others.html
==================================================
[EDIT:]
The different methods I've tested seem to work intermittently.
Possibly more likely to work if the desktop is *not* the active window.
This may or may not have something to do with Progman v. WorkerW classes.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
<Solved> AutoHotkey recording
q:: ;show desktop icons (toggle) (tested on windows 7)
PostMessage, 0x111, 29698, , SHELLDLL_DefView1, ahk_class Progman ;show desktop icons (toggle)
Return
From jeeswg works like a charm! Thanks for all the good suggestions.
PostMessage, 0x111, 29698, , SHELLDLL_DefView1, ahk_class Progman ;show desktop icons (toggle)
Return
From jeeswg works like a charm! Thanks for all the good suggestions.
Who is online
Users browsing this forum: Bing [Bot], ByronicZero, leothlon and 112 guests