Hello,

I suck at programming, so I'd like some help on createing a .vbs script to disable right mouse clicking on the entirely

Is this even possible? Google searching yeilded me nothing usefull...

javanoob101

I know there is a way by using javascript. Have a look at this link...

Or this link...

Hi AndreRet, yes those probably would work with java in a browser, but i need this to work by double clicking a .vbs script file...

What about disabling ALL mouse buttons? would there be a way to make a .vbs script for that?
javanoob101

I am not that efficient in vb scripts, more a php, java guy. :)

Run through the document's anchors collection and set the onclick handler of each to a common handler that cancels the event by setting the window.event.returnValue to false. You could attach all the handlers in the window onload event and control the handler's behavior with a page level true/false flag.
Of course this is an IE solution not sure if this will work in other browsers...

JYes but I know that there are vbs scripts that can say, open the cd drive open windows and such. I read about calling some sort of "block intercept" funtion or something, but I'm not sure how to get it to run in the Windows enviroment...

Let me know if you know anything about that...

Javanoob101

Something I found, let me know if it works...

<Script Language="VBScript">
sub fOnMouseDown()
if Window.event.button = 2 Then
Alert("Sorry ,but right click is not allowed.")
End If
End sub
</Script>

Also, something I tried in Javascript that works ok -

<script language=JavaScript>
<!--

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Function Disabled!";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

// --> 
</script>

Hey AndreRet, thanks for the codes I wasn't really able to find such coding, but even still, they both throw "expected statment" errors.
However, this code does not give errors but it also doen't do anything...

sub fOnMouseDown()
if Window.event.button = 2 Then
Alert("Sorry ,but right click is not allowed.")
End If
End sub

I'm simply copying and pasting the codes into a text file then changing the extention to ".vbs" should i be using a programming language? or is that suffcient?

Thanks,
Javanoob101

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.