shortcut

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2022 License: MIT Imports: 4 Imported by: 2

README

Shortcut

Shortcut is Go (golang) lib for create windows shortcut with a specified name, icon and target directory.

Install

go get github.com/jxeng/shortcut

Usage

  // Common useage
	sc := Shortcut{
		ShortcutPath:     "./google.lnk",
		Target:           "https://google.com",
		IconLocation:     "%SystemRoot%\\System32\\SHELL32.dll,0",
		Arguments:        "",
		Description:      "",
		Hotkey:           "",
		WindowStyle:      "1",
		WorkingDirectory: "",
	}
	err := Create(sc)

  // Create a shortcut on desktop
  shortcut.CreateDesktopShortcut("google", "https://google.com", "/path/to/logo.ico", ".")

Documentation

Rendered for windows/amd64

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(shortcut Shortcut) error

CreateShortcut create with a shortcut object

func CreateDesktopShortcut

func CreateDesktopShortcut(name, target, iconPath string) error

CreateShortcut create a desktop shortcut with name, target and iconPath target is a file or website if iconPath is empty string, icon would be "%SystemRoot%\\System32\\SHELL32.dll,0"

Types

type Shortcut

type Shortcut struct {
	// Shortcut (.lnk file) path
	ShortcutPath string
	// Shortcut target: a file path or a website
	Target string
	// Shortcut icon path, default: "%SystemRoot%\\System32\\SHELL32.dll,0"
	IconLocation string
	// Arguments of shortcut
	Arguments string
	// Description of shortcut
	Description string
	// Hotkey of shortcut
	Hotkey string
	// WindowStyle, "1"(default) for default size and location; "3" for maximized window; "7" for minimized window
	WindowStyle string
	// Working directory of shortcut
	WorkingDirectory string
}

Shortcut the shortcut (.lnk file) property struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL