Jump to content

[Powershell] Can't figure out how to run a comand based on gui button press

Helpful Tech Witch

 

Im trying to learn how to program gui based apps in PowerShell.

Unfortuatly, all I can do so far is show text on a backround, or in other pretty ways.

But I cant get a button to DO ANYTHING AT ALL when pressed.

ive tried everything under the sun, the only thing i can think of now is looking at the mouse position and waiting for a click.

ive tried

$button_click = {write-host "hey it all worked"}
$Button.Add_Click($Button_Click)

but i cant figure it out.

Right now, my code is like this:

#Button
$info = New-Object system.Windows.Forms.Button
$info.text = 'version info'

#Size/pos
$info.width = 100
$info.height = 35
$info.location = New-Object System.Drawing.Point(482,750)

#Other Atributes
$info.font = 'Microsoft Sans Serif,12'
$info.ForeColor = '#343434'
$info.BackColor = '#e3e3e3'

#action

for the button.

I could use some help with this!

please, pm me if you would like to contribute to my gpu bios database (includes overclocking bios, stock bios, and upgrades to gpus via modding)

Bios database

My beautiful, but not that powerful, main PC:

prior build:

Spoiler

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Maybe I am misunderstanding what you currently are trying to achieve...as the code mostly works for me.

 

Just as a note though

#Your bit
$Button.Add_Click($Button_Click)

#My bit
$info.Add_Click($Button_Click)

since your button is under the $info instead of $Button variable

 

Or were you talking about how to call functions and such on clicks of a button?

3735928559 - Beware of the dead beef

Link to comment
Share on other sites

Link to post
Share on other sites

7 hours ago, wanderingfool2 said:

Maybe I am misunderstanding what you currently are trying to achieve...as the code mostly works for me.

 

Just as a note though


#Your bit
$Button.Add_Click($Button_Click)

#My bit
$info.Add_Click($Button_Click)

since your button is under the $info instead of $Button variable

 

Or were you talking about how to call functions and such on clicks of a button?

oh, yeah, i have to call the button that exists there.

My fault lol

I could use some help with this!

please, pm me if you would like to contribute to my gpu bios database (includes overclocking bios, stock bios, and upgrades to gpus via modding)

Bios database

My beautiful, but not that powerful, main PC:

prior build:

Spoiler

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×