Skip to content

Latest commit

 

History

History
94 lines (69 loc) · 3.48 KB

WinForms.md

File metadata and controls

94 lines (69 loc) · 3.48 KB

Developing WinForms in O2

So I'm assuming you have followed the Web Automation guide and you're getting more ambitious with your scripting. You may be at the point now then where you want to interact with the user before, or during the time that the script is running. An example of this is my Google hacking tool. Note this that this tool does not "hack" Google, it uses the operators Google offers to refine your searches and ultimately return much more relevant results. When I first created it, the user had to hard code into the script the Google search they wanted to run. OK for one off hacks, but not great if you want to use the tool more and more for different purposes. I also have an appalling memory when it comes to things I know are available on Google. I needed some drop down boxes.....

Some of this stuff was touched on in the web automation guide, but only to aid in the examples. I may take it out of there when these guides start to come together. Here I'll try and go into more detail.

#Contents#

##The UI Area Go to Contents

When beginning a new script the first thing you need to do is bring inject an instance of a web browser into O2. To do this we create a panel within O2, then insert an instance of Internet Explorer into that:

var topPanel = panel.clear().add_Panel();
var ie = topPanel.add_IE();

##Labels Go to Contents

Labels are what they say on the tin. They can't be edited by the user but they can give a user an idea of what they are supposed to do:

actionPanel.add_Label("I am a label...");

Absolute location of any element can be set with the top(), left(), right(), bottom() methods:

actionPanel.add_Label("OP1:").top(20).left(100);

Will set the label 20 pixels from the top and 100 from the left. It can be quite fiddly laying out UI's so as time goes on its worth building seperate scripts for them and calling them, or building C# classes to handle it. Also setting locations to variables that can be called on is a neater way of dealing with the layout issue.

##Text Boxes Go to Contents

##Buttons Go to Contents

##CheckBoxes Go to Contents

Checkboxes are pretty straight forward to use. This snippet will pop an alert up each time the checkbox changes state. Its slightly confusing because onChecked() sounds like when its set to true, but its whenever it changes state....

actionPanel.add_CheckBox(0, 0,"!").onChecked((value)=> {
																value.str().alert();
                                                       });

You can set a global to the value to use it elsewhere....

##DropDown Boxes Go to Contents

##Mix And Match!! Go to Contents

##Alert Boxes Go to Contents

##Ask The User Go to Contents

##DataGrid Views Go to Contents

##Examples Go to Contents

##Appendix Go to Contents