New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double click handler on Windows #24

Closed
hugbug opened this Issue Jun 21, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@hugbug
Member

hugbug commented Jun 21, 2015

When clicking on nzb-files in Windows Explorer the files must be enqueued in NZBGet.

Current solution requires users to manually add a registry entry (with command nzbget.exe -A %1) and works only if NZBGet is currently running.

@hugbug hugbug added the feature label Jun 21, 2015

@hugbug hugbug added the help wanted label Jun 30, 2015

@brosoft-dev

This comment has been minimized.

Show comment
Hide comment
@brosoft-dev

brosoft-dev Feb 4, 2016

The "NZBGet must be running" clause can be solved by hijacking the RemoteClient::RequestServerDownload() which (if I'm not mistaken) is where the "-A " command line args end up... If InitConnection() fails to connect to the server, then we have the option to simply copy the NZB file to $(NzbDir) where it'll be picked up by Scanner:: once the daemon starts.

In the meantime (and having never seen NSI script before) - this is my attempt to give users double-click functionality for local installations... May need some work; but if you insert this somewhere in the Main section...

; Ask if we should add shell shortcuts
MessageBox MB_YESNO "Add NZB file actions to shell?" \
  IDNO noshell

; Are nzb files already defined? Hijack the regkey...
ReadRegStr $R3 HKCR ".nzb" ""
${If} $R3 == ""
  ; else, define our own
  StrCpy $R3 "nzbfile"
${EndIf}

; Set the file description type
WriteRegStr HKCU "$R3" "" "NZBGet File"

;; Add an action

; (only if other commands are present) this forces our command to be the default double-click action
;WriteRegStr HKCU "$R3\shell" "" "queue"
; Gives the file a default icon
WriteRegStr HKCU "$R3\DefaultIcon" "" "$INSTDIR\nzbget.exe,1"
; This defines the text you see on right-click
WriteRegStr HKCU "$R3\shell\queue" "" "Queue in NZBGet"
; This is the actual command the system runs when actioned...
WriteRegStr HKCU "$R3\shell\queue\command" "" "$\"$INSTDIR\nzbget.exe$\" -A $\"%1$\""

; Add a "Queue first in NZBGet" command (add to top of queue)
;WriteRegStr HKCU "$R3\shell\queue1st" "" "Queue first in NZBGet"
;
;WriteRegStr HKCU "$R3\shell\queue1st\command" "" "$\"$INSTDIR\nzbget.exe$\" -A T $\"%1$\""

noshell:

brosoft-dev commented Feb 4, 2016

The "NZBGet must be running" clause can be solved by hijacking the RemoteClient::RequestServerDownload() which (if I'm not mistaken) is where the "-A " command line args end up... If InitConnection() fails to connect to the server, then we have the option to simply copy the NZB file to $(NzbDir) where it'll be picked up by Scanner:: once the daemon starts.

In the meantime (and having never seen NSI script before) - this is my attempt to give users double-click functionality for local installations... May need some work; but if you insert this somewhere in the Main section...

; Ask if we should add shell shortcuts
MessageBox MB_YESNO "Add NZB file actions to shell?" \
  IDNO noshell

; Are nzb files already defined? Hijack the regkey...
ReadRegStr $R3 HKCR ".nzb" ""
${If} $R3 == ""
  ; else, define our own
  StrCpy $R3 "nzbfile"
${EndIf}

; Set the file description type
WriteRegStr HKCU "$R3" "" "NZBGet File"

;; Add an action

; (only if other commands are present) this forces our command to be the default double-click action
;WriteRegStr HKCU "$R3\shell" "" "queue"
; Gives the file a default icon
WriteRegStr HKCU "$R3\DefaultIcon" "" "$INSTDIR\nzbget.exe,1"
; This defines the text you see on right-click
WriteRegStr HKCU "$R3\shell\queue" "" "Queue in NZBGet"
; This is the actual command the system runs when actioned...
WriteRegStr HKCU "$R3\shell\queue\command" "" "$\"$INSTDIR\nzbget.exe$\" -A $\"%1$\""

; Add a "Queue first in NZBGet" command (add to top of queue)
;WriteRegStr HKCU "$R3\shell\queue1st" "" "Queue first in NZBGet"
;
;WriteRegStr HKCU "$R3\shell\queue1st\command" "" "$\"$INSTDIR\nzbget.exe$\" -A T $\"%1$\""

noshell:
@hugbug

This comment has been minimized.

Show comment
Hide comment
@hugbug

hugbug Feb 4, 2016

Member

Thank you for your contribution.

  1. I would happily merge it if you could make a proper pull request out of it. Provided it is fully functional and you have tested it of course 😉.
  2. Instead of message box add a checkbox to finish page similar to "Create Shortcut". See http://stackoverflow.com/questions/6531115/customizing-an-exsisting-nsis-mui2-page.

Another improvement (not required for the first pull request)

  1. If there are no running NZBGet instance, NZBGet must start as usual in application mode, similar to when started via desktop shortcut. For that you need to add switch -app:

    nzbget.exe -app -A /path/to/nzb

    And the processing of -A must be extended.

Member

hugbug commented Feb 4, 2016

Thank you for your contribution.

  1. I would happily merge it if you could make a proper pull request out of it. Provided it is fully functional and you have tested it of course 😉.
  2. Instead of message box add a checkbox to finish page similar to "Create Shortcut". See http://stackoverflow.com/questions/6531115/customizing-an-exsisting-nsis-mui2-page.

Another improvement (not required for the first pull request)

  1. If there are no running NZBGet instance, NZBGet must start as usual in application mode, similar to when started via desktop shortcut. For that you need to add switch -app:

    nzbget.exe -app -A /path/to/nzb

    And the processing of -A must be extended.

@wtf911

This comment has been minimized.

Show comment
Hide comment
@wtf911

wtf911 Apr 22, 2017

Contributor

This works if NZBGet is already running but not if it isn't, we'll still have to figure that one out. Also, I will have to add an if statement to the uninstall so it will only remove it if it was set during the install (only remove if the key value exists)

This is tried and working with Windows 10.

Contributor

wtf911 commented Apr 22, 2017

This works if NZBGet is already running but not if it isn't, we'll still have to figure that one out. Also, I will have to add an if statement to the uninstall so it will only remove it if it was set during the install (only remove if the key value exists)

This is tried and working with Windows 10.

hugbug added a commit that referenced this issue Apr 24, 2017

#365, #24: option for file association in windows installer
This will add a checkbox so after installation finishes there will be an option to associate .nzb files with NZBGet. It will also remove the association if NZBGet is uninstalled.

hugbug added a commit that referenced this issue Apr 25, 2017

@hugbug hugbug added this to the v19 milestone Apr 25, 2017

@hugbug hugbug closed this Apr 25, 2017

hugbug added a commit that referenced this issue Oct 9, 2017

#365, #24: option for file association in windows installer
This will add a checkbox so after installation finishes there will be an option to associate .nzb files with NZBGet. It will also remove the association if NZBGet is uninstalled.

hugbug added a commit that referenced this issue Oct 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment