deleteItem PageBreakItem in google forms via apps script - forms

I want to use deleteItem in apps script to delete an item from a form.
(I want to use this to clear the form and edit it).
Now, the code I wrote works fine for any item except the PageBreakItem.
I have tried it and as soon as there are PageBreakItems that I want to delete I get a "Failed to edit form" message. The code is here:
function generateOrderForm() {
var orderForm = FormApp.openById('....myformID.....');
// Clears all items after the 10th item.
while(orderForm.getItems().length > 10){
orderForm.deleteItem(10);
}
}
Is this a known issue and if yes is there a solution?
Is there an other way to clear a form or a workaround for what I want?
Thanks for your help!

I got the same question as you met. Your "PageBreakItem" is linked by other questions or other pages. Try to remove the link and run the script again.

Related

Is it possible to add custom command shortcuts in vscode?

I'm curious about the vscode function,
is it possible to add custom command shortcut by any idea including extensions and so on?
For example, I want to put these codes with simple keyboard action like 'Ctrl+Shift+1'.
if (canvas.getContext){
let ctx = canvas.getContext("2d");
//console.log("canvas supported!");
}
else {
//console.log("canvas unsupported.");
}
and when I put 'Ctrl+Shift+1', the code that I saved past appears and able to use it.
If you know the answer, please spare your time.
Thanks a lot in advance.

Issue with setting AutomationElement value

I have an issue with setting value of AutomationElement by using method ValuePattern.SetValue().
Everything works just fine until some dialog appears. When the dialog appears the code execution got stuck. No exception is thrown. After the dialog is confirmed, the code exection continues. Bellow is a sample of the code:
BasePattern basePattern = null;
ValuePattern valuePattern = null;
AutomationElement elementA = Window.GetElement(SearchCriteria.ByText(propertyName));
object patternObjectA = null;
elementA.TryGetCurrentPattern(ValuePattern.Pattern, out patternObjectA);
basePattern = (BasePattern)patternObjectA;
valuePattern = (ValuePattern)patternObjectA;
valuePattern.SetValue(optionToSet);
// Window.GetElement() is a method from TestStack.White framework
// The code execution got stuck on the last line until the dialog is confirmed
Is there any other way to set AutomationElement value?
Is somehow possible to avoid of getting stuck by dialog?
I'll by grateful for any help.
Thanks advance.
It could be that this dialog is not supporting UI Automation correctly or that you simply target the wrong element.
To verify that you may use Inspect.exe from Microsoft or similiar tools.
If it works, check if you really target the correct component with your code again.
If it does not work and:
if you are able to change the application
you can change the so called AutomationPeer of the UI component - here is a link for more infos
Or simply use another UI component that supports UI Automation correctly.
if you are not able to change the application, and also do not need to run in background, parallel, etc.. you might just focus the component (call setFocus() onto the AutomationElement, or expand it (via IsExpandCollapsePatternAvailable or simulated MouseClick onto the components coordinates)) and then use the SendKeys.SendWait("test") method.
EDIT: There is one more thing you should have a look at, and I wonder why I didn't mentioned it in the first place: Register to UI Automation Events
For example you could register a callback for the Structure change event type, and check if the dialog you talk about appeared.
If so --> click the confirmed button of the dialog.
Probably you will have to synchronize your execution, so that every further action in the UI Automation script waits until the registered callback got executed and the confirmed button got clicked.

TinyMCE get form content without using submit button

I'm trying to put TinyMCE on my website. I figured out how to get it to show up, but I'm lost on how to process the content. In their example, they just have a link that references the top of the page and clicking on it somehow magically causes their dump.php script to execute. I don't understand what's going on here. Here is the link:
http://www.tinymce.com/tryit/basic.php
The "Submit" button at the bottom is really a link in a span element with href="#". The form action is dump.php. I want to know how they configured this to run without an actual submit button. Any help in understanding this is greatly appreciated!
To Get Content From Tinymce You Can Use GetContent Method of Currently ActiveEditor Instance
tinyMCE.activeEditor.getContent();
method is used to getting Content .. to Set The Content
tinyMCE.activeEditor.setContent("I Want Text To Be in Tinymce");
to find a perticular element in tinymce get body and find element
var body = tinyMCE.activeEditor.getBody();
$(body).find("#elem_id")
to get a full html
tinyMCE.activeEditor.getDoc().documentElement.innerHTML
hope that helps ..
Since I use PHP, I found this which is also useful:
http://www.tinymce.com/wiki.php/TinyMCE3x:How-to_implement_TinyMCE_in_PHP

mousedown event on options in select with jquery .on

I was reading the documentation of the .on event handler of jQuery and I started playing around with it.
I have a simple <select> element with the multiple attribute set to true.
However, I want the user to be able to select multiple items without having to press the ctrl or shift key(s)
According to the .on documentation, if you specify a selector it will automatically add those event handlers to any new items added inside that container that match the selector specified.
So in my case, I could for example decide to replace the <option> elements available in the listbox, but I still want to have the same functionality for those options without having to rebind those events etc.
One might think that the following snippet should do the trick (atleast, I did):
$('#dropdownlist').on('mousedown', 'option', function(e){
e.preventDefault();
$(this).prop('selected', $(this).prop('selected') ? false : true);
return false;
});
So when a users clicks on an option in that listbox, the default action will be cancelled and depending wether the item is already selected or not, it will invert that selection.
I have created a small fiddle demonstrating this behaviour: fiddle
In that fiddle, the first dropdownlist is behaving as expected, but the functionality is lost when replacing the items. This only works in FF & Chrome.
The second dropdownlist is how I thought it should've been (event handling wise), but that doesn't seem to work besides in Chrome -.-
The functionality is kept when replacing items, because the console will still log '2' when clicking on an item after replacing them.
Can someone explain me why this is happening? Am I doing something wrong?
Please point me in the right direction!
Thanks!
~ Dirk
IE doesn't respect the mousedown event on the option tag itself. You've got to use the OnChange event of the select tag, which is not what you (nor I) want. I was trying to do the exact same thing as you and was stopped at every attempt. I finally gave up and made it a list of checkboxes because I can get the same behavior out of mine that you are trying to do here.
You can see this question for some options, but I never did get it to work the way you are describing.

Dragging and dropping something onto an xna window?

I have an XNA4 wndow set up and was wondering if I could get it to accept drag+drop actions, what I envision is someone grabs a jpeg and drags it into the window, upon release of the mouse an event is fired off with a string pointing to the jpeg.
Is this doable and if so how?
First, here is a link to a tutorial on doing this with a windows form:
http://support.microsoft.com/kb/307966
and here is a link to a post about doing just this (answer is past a few posts saying that it's impossible):
http://forums.create.msdn.com/forums/p/4020/20419.aspx
finally here is some code for ease of access (you need a reference to the System.Windows.Forms namespace):
protected override void Initialize()
{
Form gameForm = (Form)Form.FromHandle(Window.Handle);
gameForm.AllowDrop = true;
gameForm.DragEnter += new DragEventHandler(gameForm_DragEnter);
gameForm.DragDrop += new DragEventHandler(gameForm_DragDrop);
}
Also, it seems it's possible to run a game inside a Form control as of XNA 2
While I recognise that this is many years too late here is a direct link to a working demo.
The SLN might not want to autoload but you can just drop it into VS2013 and it will update it. I was getting a "licencing" popup when I tried to just run the SLN.
Hope this helps anyone who might still be working on this.
http://geekswithblogs.net/mikebmcl/archive/2011/03/27/drag-and-drop-in-a-windows-xna-game.aspx