How to set a icon for this right click menu? - contextmenu

I can add a new item for the folders right click menu using registry:
HKEY_CLASSES_ROOT\folder\shell\Your item name
But i don't know how to set a icon for created item like this :
May somebody help me?

To create a custom context menu with an icon when clicking on a folder follow these steps:
Under HKEY_CLASSES_ROOT\folder\shell\ create a new key: "MyContextMenu"
Under HKEY_CLASSES_ROOT\folder\shell\MyContextMenu edit the (Default) key to specify the text to show in the context menu: MyMenu
To execute a command when the menu is chosen add a new key name "Command" and set the commmand to execute in it's (Default) value. For instance: cmd.exe
Now to set the icon you add a new string value name Icon and set it's value to the *.ico you want to show or you can reference an ico that is embedded in a dll using [name of the dll],[icon number] A lot of the default windows icons are in imageres.dll. So for this example set the value to: c:\windows\system32\imageres.dll,10
There is a nice tool called iconviewer that you can use to examine icons in dlls. After you install it you can right click a dll, open it's properties and an extra tab with it's icons will be added to the propery pages

You should to add iconpath in this key for showing when the user clicked right button.
Try to write key OpenWithProgIds, and then create value with name (path) of your application.
Example for recycle:
TRegistry *key=new TRegistry(KEY_ALL_ACCESS);
key->RootKey=HKEY_LOCAL_MACHINE;
key->OpenKey("Software\\Classes\\CLSID\\{645FF040-5081-101B-9F08-00AA002F954E}\\shell", false);
key->OpenKey("Prog_name", true);
key->WriteString("Icon", ExtractFileDir(Application->ExeName)+"\\icon_prog.ico");
key->OpenKey("command", true);
key->WriteString("", ExtractFileDir(Application->ExeName)+"\\Program.exe");
key->CloseKey();

Related

How to run an Applescript that will click and open all links on a web page?

I'm trying to write a script that will automatically open a webpage http://www.legislation.gov.uk/new/uksi and then click on all the links in the table "All New Legislation".
So far I've managed to get it to open the page but no luck with clicking.
Here's my script so far:
activate application "Safari"
open location "http://www.legislation.gov.uk/new/uksi"
to clickID()
do JavaScript "document.getElementById(id=per).click();" in document 1
end tell
The following example AppleScript code will open the targetURL in a new Safari window, wait for the page to finish loading, retrieve all URLs on the target page, search them for URLs pointing the various Statutory Instruments published today, and then open each one in a new tab of the same window the targetURL was opened.
set targetURL to "http://www.legislation.gov.uk/new/uksi"
set theseURLs to {}
set grepSearchPattern to ".*\\.uk/uksi/.*\\|.*\\.uk/ssi/.*\\|.*\\.uk/wsi/.*\\|.*\\.uk/nisi/.*"
set jsStatements to "var a = document.links; var x = ''; var i; for (i = 0; i < a.length; i++) { x = x + a[i].href + '|'; };"
tell application "Safari"
make new document with properties {URL:targetURL}
activate
end tell
tell application "System Events"
repeat until exists ¬
(buttons of UI elements of groups of toolbar 1 of window 1 of ¬
process "Safari" whose name = "Reload this page")
delay 1
end repeat
end tell
tell application "Safari"
set allURLs to (do JavaScript jsStatements in document 1)
end tell
try
set theseURLs to paragraphs of (do shell script "tr '|' '\\12' <<< " & ¬
allURLs's quoted form & " | grep " & grepSearchPattern's quoted form)
end try
if (length of theseURLs) is greater than 0 then
tell application "Safari" to tell front window
repeat with thisURL in theseURLs
set current tab to (make new tab with properties {URL:thisURL})
end repeat
set current tab to first tab
end tell
else
display dialog " Nothing published on this date." buttons {"OK"} ¬
default button 1 with title "All New Legislation" with icon note
end if
Hint: Mouse over and horizontal/vertical scroll to see full code.
Notes:
The do JavaScript1 command create a pipe delimited string of all URLs on the page of the targetURL.
The do shell script command takes the pipe delimited string of all URLs and replaces the pipe characters with newline characters, using tr, so grep can return the URLs that match the grepSearchPattern.
The grepSearchPattern variable currently only searches for Statutory Instruments, as I assume that is all that will show under All New Legislation on the page the targetURL opens to, because of /new/uksi in the targetURL, and what I've observed at that URL since you posted the question. If you also want links for other types of legislation, the grepSearchPattern variable can be adjusted to accommodate.
1 Using the do JavaScript command requires Allow JavaScript from Apple Events to be checked on the Safari > Develop menu, which is hidden by default and can be shown by checking [√] Show Develop menu in menu bar in: Safari > Preferences… > AdvancedIf you are not allowed to enable that setting, the URLs can be collected for processing in another manner, however it uses the lynx third party utility.
Opening the links without the use of the do JavaScript command:
The following example AppleScript code will use lynx to retrieve the URLs from the targetURL, search them for URLs pointing the various Statutory Instruments published today, and if some have been published will open the targetURL in a new Safari window, wait for the page to finish loading, and then open each one in a new tab of the same window the targetURL was opened.
set targetURL to "http://www.legislation.gov.uk/new/uksi"
set theseURLs to {}
set lynxCommand to "/usr/local/bin/lynx --dump -listonly -nonumbers -hiddenlinks=ignore"
set grepSearchPattern to ".*\\.uk/uksi/.*\\|.*\\.uk/ssi/.*\\|.*\\.uk/wsi/.*\\|.*\\.uk/nisi/.*"
try
set theseURLs to paragraphs of ¬
(do shell script lynxCommand & space & targetURL's quoted form & ¬
" | grep " & grepSearchPattern's quoted form)
end try
if (length of theseURLs) is greater than 0 then
tell application "Safari"
make new document with properties {URL:targetURL}
activate
end tell
tell application "System Events"
repeat until exists ¬
(buttons of UI elements of groups of toolbar 1 of window 1 of ¬
process "Safari" whose name = "Reload this page")
delay 1
end repeat
end tell
tell application "Safari" to tell front window
repeat with thisURL in theseURLs
set current tab to (make new tab with properties {URL:thisURL})
end repeat
set current tab to first tab
end tell
else
display dialog " Nothing published on this date." buttons {"OK"} ¬
default button 1 with title "All New Legislation" with icon note
end if
Hint: Mouse over and horizontal/vertical scroll to see full code.
Notes:
In the lynxCommand variable, change /usr/local/bin/lynx to the appropriate /path/to/lynx. lynx can be installed using Homebrew
The grepSearchPattern variable currently only searches for Statutory Instruments, as I assume that is all that will show under All New Legislation on the page the targetURL opens to, because of /new/uksi in the targetURL, and what I've observed at that URL since you posted the question. If you also want links for other types of legislation, the grepSearchPattern variable can be adjusted to accommodate.
Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors.

VSCode: Prevent split editor to open same file left & right

I'm currently using VSCode as my main editor, however, when I split the editor into 2, it opens the same file twice, like left & right (see image below).
Is there any way to prevent it from opening the same file on the next editor? Currently, I have my custom settings and can be copied from here.
command name in Keybindings: workbench.action.moveEditorToNextGroup
command name in Command Palette: View: Move Editor into Next Group
default keybinding: Ctrl+Alt+→
command name in Keybindings:workbench.action.moveEditorToPreviousGroup
command name in Command Palette: View: Move Editor into Previous Group
default keybinding: Ctrl+Alt+←

How to Auto-Alignment Shortcut Key in Keil uVision?

I want to find Auto-Alignment Shortcut Key in Keil uVision. I tried some shortcut keys but I can not find. In Visual Studio I used to: CTRL + K + D , but in keil uVision I don't know how it is work.
For example :
When you type below ( usually copied from another text file which was not tabified correctly):
Use the shortcut key Auto Alignment with this block of code can auto formatting your code as below :
Stop searching. There is no such feature.
Was able to align in uVision5 with Astyle (http://astyle.sourceforge.net/).
File must be saved so that this tool can do its work.
Instructions :
Copy the Astyle.exe file to the Keil installation directory (e.g. D:/Keil_v5/)
Then open Keil and under the Tools menu, open the Customize Tools Menu option.
Create a new Menu Content, the name can be casual .
Command selects the Astyle.exe file in the keil installation directory.
Fill in Arguments !E
You can add a shortcut key for the operation in Edit.
Cheers to this https://www.programmersought.com/article/578892324/

How add context menu item to Windows Explorer for folders [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have found out how to add right-click context menu items to files on Windows Explorer, by adding keys to the registry. I.e. I can right-click on a file in Explorer and run a custom app against that file.
I would like to do the same for a folder and have not found a way to do that (yet). I see articles on creating/writing custom context menu handlers, but I would rather not go there.
I have found an article here on how to add cascading context menu items to the Desktop and to the "Computer" in Explorer, but this does not work for any folder.
I would like to be able to add my custom app to the context menu and have it work on both files and folders. Is there a way to do this without writing a context menu handler?
I found the solution in the below article, which describes how to do this via the registry for files, as well as for folders:
How to Add Any Application Shortcut to Windows Explorer’s Context Menu
The following two articles provided additional info and options:
Ultimate Tutorial to Customize Desktop Context Menu in Windows Vista, 7 and 8
Add Cascading Menus for Your Favorite Programs in Windows 7 Desktop and My Computer Context Menus
In the registration editor (regedit.exe) find:
Context menu for right click on folders in left panel of Windows Explorer or on background of a directory in right panel:
HKEY_CLASSES_ROOT\Directory\Background\shell if you are administrator
HKEY_CURRENT_USER\Software\Classes\directory\Background\shell if you are a normal user
Context menu for right click on folders in right panel of Windows Explorer:
HKEY_CLASSES_ROOT\Directory\shell if you are administrator
HKEY_CURRENT_USER\Software\Classes\directory\shell if you are a normal user
Context menu for any file:
HKEY_CLASSES_ROOT\*\shell if you are administrator
HKEY_CURRENT_USER\Software\Classes\*\shell if you are a normal user
In all cases:
add a new key under shell, naming it as you want to name the
context menu item
add a new key inside this key, named command (mandatory name)
edit the default property in command to
myprogrampath\path\path\executable.exe "%1" to pass the file path and
name of the selected file to your custom program (for .../Directory/Background and .../directory/Background cases use %V instead of %1)
More customization:
Add icon: add a string value named icon for key created at step 1 with value matching an icon resource path. You can also provide an integer arguments to specify which icon to use. Example: %SystemRoot%\System32\shell32.dll,3
Display only on shift-click: add an empty string value named Extended for key created at step 1
Customize menu entry label: change the value of default value for key created at step 1
Change menu entry location: add a string value named Position with one of: Top, Bottom
Found a cleaner, easier and faster solution: create a text file, fill it with these contents, update it to your needs, save with .reg suffix and launch it (it does not need administrator priviliges because it accesses user-part of the registry):
Windows Registry Editor Version 5.00
; Setup context menu item for click on right panel:
[HKEY_CURRENT_USER\Software\Classes\directory\Background\shell\MenuItemNameBackground\command]
#="C:\\yourpath\\executable.exe \"%1\""
; Optional: specify an icon for the item:
; HKEY_CURRENT_USER\Software\Classes\directory\Background\shell\MenuItemNameBackground]
;"icon"="C:\\yourpath\\appicon.ico"
; Optional: specify a position in the menu
; HKEY_CURRENT_USER\Software\Classes\directory\Background\shell\MenuItemNameBackground]
;"position"="Bottom"
; -------------------------------------------------------------------------------------
; Setup context menu item for click on folders tree item:
[HKEY_CURRENT_USER\Software\Classes\directory\shell\MenuItemNamePanel\command]
#="C:\\yourpath\\executable.exe \"%1\""
; Optional: specify an icon for the item:
; [HKEY_CURRENT_USER\Software\Classes\directory\shell\MenuItemNamePanel]
;"icon"="C:\\yourpath\\appicon.ico"
; Optional: specify a position in the menu
; [HKEY_CURRENT_USER\Software\Classes\directory\shell\MenuItemNamePanel]
;"position"="Top"
In this way you can also have a backup of your configuration: just save the .reg file in a safe place. If you manually edit the registry after launching the file, right-click and slect "export".
Beware of double backspaces in path: \\
I went back and also answered this in another topic since there doesn't appear to be much on this question specifically.
I found the simplest way was to add a String Value to the key called "AppliesTo" and set its value to "under:{path}"
In my example, I want it to only look in the T Drive, so my String value is "AppliesTo":"under:T:".
In C#, this is easily accomplished with the following:
RegistryKey _key = Registry.ClassesRoot.OpenSubKey("Folder\\Shell", true);
RegistryKey newkey = _key.CreateSubKey("My Menu Item");
newkey.SetValue("AppliesTo", "under:T:");
RegistryKey subNewkey = newkey.CreateSubKey("Command");
subNewkey.SetValue("", "C:\\yourApplication.exe");
subNewkey.Close();
newkey.Close();
_key.Close();
The only good solution I found a really working is : https://superuser.com/questions/1097054/shell-context-menu-registry-extension-doesnt-work-when-default-program-is-other
Add keys in HKEY_CLASSES_ROOT\SystemFileAssociations\your.extension\shell\command
Modify the last key with the command you wanna do.
For my purpose it was :
"C:\Program Files (x86)\GPSBabel\gpsbabel.exe" -r -i gpx -f "%1" -x simplify,count=1000 -o gpx -F "%1.gpx"
If I export the it I get a .reg :
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\SystemFileAssociations\.gpx\shell\Simplify gpx\command]
#="\"C:\\Program Files (x86)\\GPSBabel\\gpsbabel.exe\" -r -i gpx -f \"%1\" -x simplify,count=1000 -o gpx -F \"%1.gpx\""
Open command prompt [run as administrator] and execute this command
reg add "HKEY_CLASSES_ROOT\Directory\shell\Refi2\command" /d "powershell.exe -noexit -command Set-Location -literalPath '%V'"
-d : value to execute[app name exe].
-v : creates a new subkey inside the command key.
-f : to forcefully override the key if already exists.
powershell.exe -noexit -command Set-Location -literalPath '%V' instead of this you can specify path of your exe.
For more details about more features run:-
reg add /?

Advance new file in sublime text 2

I have beed using Advance new file package in Sublime Text 2 and when I press shortcut for creating new file is in my main directory C\users\%name\.
Is it possible (or with another package) to set path to be in folder that I'm currently at.
Example, if I'm at
C:\Users\%user\Desktop\Notebook\Ruby programs\Ruby\test.rb
to set the path to
C:\Users\Bane\Desktop\Notebook\Ruby programs\Ruby\
Open Preferences -> Package Settings -> AdvancedNewFile -> Settings - User and add the following to the file.
{"default_root": "current"}
You can see more about settings on the GitHub page.

Resources