BackHomeAgain Posted January 14, 2022 Share Posted January 14, 2022 I have disabled the desktop context menu by editing the "Registry". It requires a computer restart. A mouse right click then shows no menu. Below is my code to do this in a script. $key3 = "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" $val3 = "NoViewContextMenu" $ContextMenu = RegRead($key3, $val3) ; Save 0 = Menu is available $ctxMenu = 1 RegWrite($key3, $val3, "REG_DWORD", $ctxMenu) ; 1 = Menu is not available ; Do something here ; Restore to previous RegWrite($key3, $val3, "REG_DWORD", $ContextMenu) ; 0 = Menu now available Is there a DLLCALL function to set the parameters to do this? I have modified "wallpaper" setting in similar code. However, there was DLL example found in the forums. Is there a list out there of all DLL functions? I found partial list. Most of the information was about modifying the context menu. Link to comment Share on other sites More sharing options...
spudw2k Posted January 18, 2022 Share Posted January 18, 2022 I'm failing to find a DLL or API call to do this. It does appear though that just restarting Explorer.exe takes care of it, in lieu of a full reboot. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
BackHomeAgain Posted January 19, 2022 Author Share Posted January 19, 2022 spudw2k, Run("explorer.exe", "", @SW_HIDE) doesn't hide the window and the context menu remains after setting the RegWrite to "1" Is this a possible candidate for a new function? My work around is to create a full screen invisible window where a mouse right click prevents the desktop context menu from appearing. I use right click to do other things and I don't want the menu to keep popping up. Link to comment Share on other sites More sharing options...
Nine Posted January 19, 2022 Share Posted January 19, 2022 I think the solution would reside in hooking the right click and check the context of it. If it is on desktop, then stop it, otherwise let it go... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
spudw2k Posted January 19, 2022 Share Posted January 19, 2022 @BackHomeAgain What I meant was is if you set the NoViewContextMenu value to 1, then terminate and restart explorer.exe (no need for @SW_HIDE), than the context menu is disabled. I like the way @Nine thinks. If the intent is just to temporarily block the Desktop contextmenu, then hooking could be an ideal solution. Nine 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
jguinch Posted January 22, 2022 Share Posted January 22, 2022 (edited) There is a way to do what you want, without having to close the session or the explorer, through the Local Group Policies. The Local Group Policies are stored in .pol format. The good new is that Microsoft provides a command line tool called "LGPO.EXE", which can interact with this kind of file. Download LGPO.exe : https://www.microsoft.com/en-us/download/details.aspx?id=55319 (LGPO.zip) Create a NoViewContextMenu.txt file, as indicated bellow Build a policy file from the text file, using the following command : LGPO.exe /r NoViewContextMenu.txt /w NoViewContextMenu.pol Import the policy in the Local Group Policy (it's a user policy, so use /u) with that command : LGPO.exe /u NoViewContextMenu.pol (you will need Admin rights) That's all. The next step is to automate it using AutoIt (the steps 1 to 3 have to be done just one time) NoViewContextMenu.txt ; Disable the context menu User SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer NoViewContextMenu DWORD:1 Warning : since the Home edition of Windows does not support the Local Group Policy editor, I don't know if it works with this tool Edit : I didn't try to execute the script using a different account, but in this case you will probably need to execute the gpupdate command to apply the change Edited January 22, 2022 by jguinch argumentum 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Deye Posted January 22, 2022 Share Posted January 22, 2022 On 1/19/2022 at 10:53 PM, BackHomeAgain said: I use right click to do other things and I don't want the menu to keep popping up. You can probably close them menus on the fly before you continue "things" ControlSend("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]", "{RCTRL}{ALT}") Link to comment Share on other sites More sharing options...
BackHomeAgain Posted January 30, 2022 Author Share Posted January 30, 2022 The following works for me. ;Create full screen window to block desktop context menu. ;The "1" in WinSetTrans function is important. Also hides the task bar. ;The right mouse click is used to pause and continue the script. ;Left mouse click stops the script and all settings restored. $hGUI = GUICreate("", @DesktopWidth+10, @DesktopHeight+10, -1, -1, 0x80000000) GuiSetState() WinSetTrans($hGUI, "", 1) ;Make window invisible. The GUI is deleted and the screen is back to normal. Link to comment Share on other sites More sharing options...
junkew Posted January 30, 2022 Share Posted January 30, 2022 So no need to block windows+d to show desktop and then still use the contextmenu (or ctrl+esc and probably some other windows shortcut keys) ? FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Nine Posted January 30, 2022 Share Posted January 30, 2022 Agree with @junkew. That is not a robust solution. But overall, nobody asked why OP would need it only on partial situations. Seems to me there is something underlying there. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now