I need help converting a script to run in the Editor

@MenuItem ("Edit/Capture Video")

static function Apply() {

var filePath : String = EditorUtility.OpenFilePanel("Select a record path","","");
//Display dialog with Record and Cancel button
//if Record button is clicked, set recordVideo to true 

var imageIncrement : int = 0;
var sequenceName = "Screenshot";
var filePath : String;

private var recordVideo : boolean = false;

function Update () {
 if (recordVideo == true){
 Application.CaptureScreenshot(filePath + sequenceName + imageIncrement + ".png");
 imageIncrement += 1;
 checkForRecord ();

function checkForRecord (){
if (Input.GetKey ("space")){
	recordVideo = false;
	print ("Recording Stopped");
            imageIncrement = 0;

First, will this work? How would I say display a dialog with a button to click to start recording (and a cancel button). Would pressing the spacebar after that point cancel recording? And, most importantly, when the file dialog opens up, it won't let me choose a folder! Dialog with greyed out button

If you want the user to be able to select a folder, you should use EditorUtility.SaveFolderPanel(...).