Neutron.ahk icon indicating copy to clipboard operation
Neutron.ahk copied to clipboard

how to disable right click context menu?

Open gittyup2018 opened this issue 3 years ago • 4 comments
trafficstars

Is there a way to disable right click context menu in Neutron? I noticed it has some disabled_shortcuts array but not sure how to use that or if that's relevant in this case?

gittyup2018 avatar Feb 26 '22 00:02 gittyup2018

You should be able to register the appropriate event handler on the body element and direct it to call an AHK function

G33kDude avatar Feb 26 '22 00:02 G33kDude

when you say body element, do you mean javascript? I'm trying to avoid javascript/html methods and do it using AHK or Neutron WM_whatever events. I tried adding

WM_RBUTTONDOWN := 0x204 , WM_NCRBUTTONDOWN :=0xA4 , WM_CONTEXTMENU := 0x7B

	0: {
		this.WM_CONTEXTMENU: true
        
	},
    1: {
       this.WM_BUTTONDOWN: true
    },

but nothing happens and I'm not even sure how to test these events. I don't know what pressing f5 does in IE as I normally use Firefox but it's not triggering anything in the message box:

			; Block disabled key combinations

msgbox % this.modifiers wParam if (this.disabled_shortcuts[this.modifiers, wParam]) msgbox disabled return 0

gittyup2018 avatar Feb 26 '22 01:02 gittyup2018

RButton:: if !WinActive("file.ahk"){ SendInput ^{RButton} } Return

Or u can do it with js

  $(document).ready(function() {
      $("html").on("contextmenu", function(e) {
          return false;
        });
    });

alvaropike avatar Mar 03 '23 12:03 alvaropike

here:


#include %A_ScriptDir%/lib/Neutron.ahk
#NoEnv
nGUI := new NeutronWindow("index.html")
nGUI.Show("w1390 h470")
winSetTitle, myTitle

 Roff = 0                                                            ;initiate Rbutton off as disabled
settimer, mousePOSCheck, 10                          ;settimer to label that checks mouse pos
return

 mousePOSCheck:
 mousegetpos,,,mID
 wingetTitle, mTitle, % "ahk_ID" mID
If (mTitle = "myTitle")  ; is app under mouse position? (quotes are necessary)
Roff = 1                          ; if yes rbutton disabled
else
Roff = 0                          ; if no rbutton enabled
  return

#if Roff = 1      ; context-sensitive hotkey below. 
 rbutton::                                       ; rbutton will not perform mousedown event while off = 1
send {rbutton up}
return
#if

G6NK avatar Mar 06 '23 00:03 G6NK