Showing posts with label Powershell GUI. Show all posts
Showing posts with label Powershell GUI. Show all posts

Tuesday, February 18, 2014

Powershell and GUI : Button element

 

 Buttons

18-02-2014 16-25-39

 

One of the main component of any GUI application are buttons. Without Buttons, no GUI applications seems completed.

In my GUI application I use button a lot.

In today’s post we are going to see the basic functionality of the Button element.

Today we are going to cover only the “Click” event of the button. These “Click” event triggers when user press the button.

Let’s get started.

 

Note: I am using “Sapien PowerShell Studio 2012”   for creating GUI’s, you can also download the trial version of it for use and testing. It doesn’t matter which IDE you have used, concept are same everywhere.

1.       Open PowerShell studio 2012.

2.       Click on “New” and click on “New Form”

3.       18-02-2014 16-17-18

4.       Choose Empty Form and “Click on Select”.

5.       18-02-2014 16-17-31

6.       Now from the “Toolbox Panel”, click on “Label” and drop it on the blank form.

7.       18-02-2014 16-18-13

8.       Click on “Label” properties and change the following.

a.       Label’s Text to = “This is  a label”

b.      Design to = “labelmy”

9.       18-02-2014 16-19-55

10.   Now drag “Button” from the control pane and drop it on a form.

11.   18-02-2014 16-19-55

12.   Now  double click on “Button” and it will open the script pane,

13.   And you can see the Button name and a click method

14.   18-02-2014 16-20-32

$button1_Click={

       #TODO: Place custom script here

      

      

      

15.               }

18-02-2014 16-42-21

16.   $button1 is the name of our button and Click is a click method.

17.   Now let’s make this button do something.

18.    I have added the below line in the button click method

a.       $labelmy.Text = 'Oh my God!! Button is pressesd.'

19.   18-02-2014 16-22-03

20.   So when we press the button, our label text “This is a Label” will be changed to “'Oh my God!! Button is pressesd.'

21.   Let’s see that.

22.   Go back to form and click on “Run File” or press “Ctrl + F5”

23.   18-02-2014 16-22-19

24.   And when the form run, click on the button. And you will see that text of label is changed.

25.   18-02-2014 16-22-54

26.   Now let’s add some more fun.

27.   I have added the one more line of code and change the text for the label.

 

 

28.   18-02-2014 16-23-58

$button1_Click={

       #TODO: Place custom script here

      

       $labelmy.Text = 'Notepad! will be opened.'

       Start-Process 'notepad.exe'

      

29.               }

30.   Now, when we click on our button, the text of our label will change and it will open a notepad too.

31.   Run the form again and click on “button”

32.   And you can see that text is changed and a new notepad window is opened.

33.   18-02-2014 16-24-41

 

That’s all for now.

See you in my next blog posts.

 

Regards

clip_image017 clip_image018 clip_image019 clip_image020  clip_image021Aman Dhally

 

Thursday, February 6, 2014

PowerShell Application : Numerology Application created using PowerShell

 

clip_image002

 

Don’t call me insane, and please don’t use the words “WTF!”, “Shit” etc. I knew, PowerShell and numerology sound very insane.

I know, I know, PowerShell is for IT guys, Admins , developers, but, it is scripting language, we can use is to easy and other life.

Download Link : https://dl.dropboxusercontent.com/u/17858935/Numerology.zip

 

Background

 

One of my friend is a numerologist, he was facing some problem and asked me if I am able to help him. The issue which he was facing was to convert the name of his clients to numbers, he has to do the manually . That’s what he use to do.

For example you name is Aman and you want to know about your ruling number and planet

Alphabet

Position of Alphabet in English Letter

A

1

M

4

A

1

N

5

 

So the Number for Aman is = 1+4+1+5 = 11 as we have only 9 planets, we have to add 11 to 1+1 again and we got the ruling number 2.

Now if you name is more complex than mine, he is going to spent a decent amount of time to add it.

Solution

 

I have created a simple PowerShell GUI for him, so that he just need to type the name of the user it to it and click on calculate button, and he got the ruling number of the user along with him ruling planet.

 

How to use it

Download the zip file from this link : https://dl.dropboxusercontent.com/u/17858935/Numerology.zip

This zip file contain, Images those are used in the GUI, a PowerShell source file and an executable file.

To open the numerology PowerShell application.

Double click on “Numerology.exe”

 

clip_image003

Type you name and click on calculate. That’s all.

clip_image005

 

 

I learned

Open the PowerShell file,  and you can see a good example of using arrays and the if logic.

 

Special thanks

To all “PowerShell MVPs” who helped me when I stuck at a small script logic.

 

I hope you will enjoy this.

 

Regards

Aman Dhally

 

clip_image017 clip_image018 clip_image019 clip_image020  clip_image021

 

 

Monday, September 23, 2013

Powershell Tools : Windows Login Screen Changer GUI application.

 

Hi,

In my previous post, i described about, how to change login screen using Powershell.

In weekend I thought about to create a small Powershell GUI application to set a Login screen for us.

How to use it.

Run the script as Administrator and in a –Sta mode.

0

 

Click on Change Login Screen to choose the picture which you wan to set as login screen, make sure that the picture should be less then 254 kb in size.

You can click on Test button to test the current set Login screen.

If you want to set your login screen to default then click on “set to default button”.

1

 

Set a Lon screen:

  1. Click on “Change Login screen”
  2. Then choose you image and click on Open.

 

2

This will show you which pic you has chose as a login screen. Click on Test to test the login screen pictures which we has just choose.

3 

and here is the result :) .

IMG-20130919-00495

Download Link : http://gallery.technet.microsoft.com/Powershell-Application-303a17cb

 

I hope that you find is useful.

Aman Dhally

clip_image001 clip_image002 clip_image003 clip_image005clip_image007