Skip to content
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

how to disable right click context menu? #24

Open
gittyup2018 opened this issue Feb 26, 2022 · 4 comments
Open

how to disable right click context menu? #24

gittyup2018 opened this issue Feb 26, 2022 · 4 comments

Comments

@gittyup2018
Copy link

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?

@G33kDude
Copy link
Owner

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

@gittyup2018
Copy link
Author

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

@alvaropike
Copy link

alvaropike commented Mar 3, 2023

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;
        });
    });

@G6NK
Copy link

G6NK commented Mar 6, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants