Jump to content
Sign in to follow this  
ShortShot14

How Do I Enter A Command In a GUI Button?

Recommended Posts

ShortShot14

How do i enter a command like... i made a GUI in Koda and copy and pasted the code into SciTe

and i wanna launch the command

CODE
Send("{Enter}")
But i dont know how??

Share this post


Link to post
Share on other sites
MrMitchell

What are you trying to do? Click a button and make it do something? I don't understand...

Share this post


Link to post
Share on other sites
ShortShot14

Yea thats what im trying to do

Share this post


Link to post
Share on other sites
MrMitchell

First you need to learn GUI Concepts, like the difference between OnEvent and Message modes. When you created a GUI with Koda there was a way to select which type of GUI you want to use. It will even create a function for each action on a control. If you made a button Koda can create a function to run if the button is pressed. If you made a checkbox there should be a function to run when it gets checked or unchecked... I know for sure it does this in OnEvent mode if you tell it to...

Is there a "Opt("GUIOnEventMode", 1)" at the top of the code? If it's there and it's a 1 that means you're using OnEvent Mode.

Edit: How to put your GUI into OnEvent mode...

Go to Tools --> Generating Options or Ctrl+F9

Check "Generate OnEvent Code" and "Generate Events for all Controls"

Do that and you'll see what I mean. If you want to see a working example the help file has an OnEvent GUI example. Here's one...

#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode 
$mainwindow = GUICreate("Hello World", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
$okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
GUICtrlSetOnEvent($okbutton, "OKButton")
GUISetState(@SW_SHOW)

While 1
  Sleep(1000)  ; Idle around
WEnd

Func OKButton()
  ;Note: at this point @GUI_CTRLID would equal $okbutton,
  ;and @GUI_WINHANDLE would equal $mainwindow
  MsgBox(0, "GUI Event", "You pressed OK!")
EndFunc

Func CLOSEClicked()
  ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, 
  ;and @GUI_WINHANDLE would equal $mainwindow 
  MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")
  Exit
EndFunc
Edited by MrMitchell

Share this post


Link to post
Share on other sites
ShortShot14

ohh Okay thank you! :)

Edited by ShortShot14

Share this post


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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.