Jump to content
Sign in to follow this  
meisandy

Button action - Koda FormDesigner

Recommended Posts

meisandy

Hi guys, i actually made a post eariler and took your advice of using Koda FD!

I have found no way of making a button do anything using the application so I have copied a bit of the generated code into AutoIt and edited it to suit my requiurements. But I cannot seem to make the button do anything?

Here is the original generated code:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=\\djdrew-pc\sl500 lenovo - laptop\rshp1.kxf
$Form1_1 = GUICreate("RuneScape Hacker", 343, 195, 192, 124)
GUICtrlCreateInput("", 64, 40, 225, 21)
GUICtrlCreateInput("", 64, 104, 225, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$Label1 = GUICtrlCreateLabel("Enter User Name:", 64, 16, 198, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Goudy Old Style")
GUICtrlSetColor(-1, 0x808000)
$Label3 = GUICtrlCreateLabel("Enter Password", 64, 80, 213, 23)
GUICtrlSetFont(-1, 11, 400, 0, "Goudy Old Style")
GUICtrlSetColor(-1, 0x808000)
$Button1 = GUICtrlCreateButton("Next", 216, 144, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Form1_1
EndSwitch
WEnd

And here is the edited version

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1_1 = GUICreate("RuneScape Hacker", 343, 195, 192, 124)
GUICtrlCreateInput("", 64, 40, 225, 21)
GUICtrlCreateInput("", 64, 104, 225, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$Label1 = GUICtrlCreateLabel("Enter User Name:", 64, 16, 198, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Goudy Old Style")
GUICtrlSetColor(-1, 0x808000)
$Label3 = GUICtrlCreateLabel("Enter Password", 64, 80, 213, 23)
GUICtrlSetFont(-1, 11, 400, 0, "Goudy Old Style")
GUICtrlSetColor(-1, 0x808000)
GUISetState(@SW_SHOW)
$Nextb = GUICtrlCreateButton( "Next", 216, 144, 75, 25)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Form1_1
EndSwitch
WEnd

And they both function the same!

Can someone please just help me bye giving the button a function of bringing up a msgbox? Just so i get the idea.

Thanks

Share this post


Link to post
Share on other sites
frog78

Try this

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1_1 = GUICreate("RuneScape Hacker", 343, 195, 192, 124)
GUICtrlCreateInput("", 64, 40, 225, 21)
GUICtrlCreateInput("", 64, 104, 225, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$Label1 = GUICtrlCreateLabel("Enter User Name:", 64, 16, 198, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Goudy Old Style")
GUICtrlSetColor(-1, 0x808000)
$Label3 = GUICtrlCreateLabel("Enter Password", 64, 80, 213, 23)
GUICtrlSetFont(-1, 11, 400, 0, "Goudy Old Style")
GUICtrlSetColor(-1, 0x808000)
GUISetState(@SW_SHOW)
$Nextb = GUICtrlCreateButton( "Next", 216, 144, 75, 25)

While 1
     $nMsg = GUIGetMsg()
     if $nMsg=$GUI_EVENT_CLOSE then Exit
     if $nMsg=$Nextb Then MsgBox(0, "title", "text")
WEnd

Share this post


Link to post
Share on other sites
ctyankeeinok

Try the code below. I changed it to OnEvent Mode, added a function for your button, added a separate function for closing the form, and simplified the While loop.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)        ; set to On event mode
$Form1_1 = GUICreate("RuneScape Hacker", 343, 195, 192, 124)
GUICtrlCreateInput("", 64, 40, 225, 21)
GUICtrlCreateInput("", 64, 104, 225, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$Label1 = GUICtrlCreateLabel("Enter User Name:", 64, 16, 198, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Goudy Old Style")
GUICtrlSetColor(-1, 0x808000)
$Label3 = GUICtrlCreateLabel("Enter Password", 64, 80, 213, 23)
GUICtrlSetFont(-1, 11, 400, 0, "Goudy Old Style")
GUICtrlSetColor(-1, 0x808000)
$Nextb = GUICtrlCreateButton( "Next", 216, 144, 75, 25)
GUICtrlSetOnEvent($Nextb,"NextClk")             ;  run NextClk if button is clicked
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClk")     ;  run CloseClk if form is closed
GUISetState(@SW_SHOW)

While 1
;~ $nMsg = GUIGetMsg()
;~ Switch $nMsg
;~ Case $GUI_EVENT_CLOSE
;~ Exit

;~ Case $Form1_1
;~ EndSwitch
sleep(100)
WEnd

Func NextClk()
    MsgBox(0,"Hello","Hey, somebody clicked Next!")
EndFunc

Func CloseClk()
    MsgBox(0,"Adios","Adios Amigos!")
    Exit
EndFunc

Share this post


Link to post
Share on other sites
meisandy

Thanks guys, it was really helpful.

But can you just add some script to tell it to open a msgbox AND close the gui box when next is clicked. please?

thanks again

by the way i used ctyankeeinok's script!: So could you add on that please?!

Share this post


Link to post
Share on other sites
ctyankeeinok

Keep in mind that what frog78 posted works just as well, but is MessageLoop Mode and what I posted is OnEvent mode. I am new to AutoIT and not a GUI expert - I would recommend spending a lot of time in the Help files and looking through examples for something similar to what you want to accomplish. With that said, here is some code based on frog78's example that sort of does what you asked. Spend time reading the Help File GUI Reference->GUI MessageLoop Mode. I am not sure that what I have here is the best method, but it works (so far). Perhaps you could explain your overall process (general screen flow and general actions) and someone may chime in on the best approach.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1_1 = GUICreate("RuneScape Hacker", 343, 195, 192, 124)
GUICtrlCreateInput("", 64, 40, 225, 21)
GUICtrlCreateInput("", 64, 104, 225, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$Label1 = GUICtrlCreateLabel("Enter User Name:", 64, 16, 198, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Goudy Old Style")
GUICtrlSetColor(-1, 0x808000)
$Label3 = GUICtrlCreateLabel("Enter Password", 64, 80, 213, 23)
GUICtrlSetFont(-1, 11, 400, 0, "Goudy Old Style")
GUICtrlSetColor(-1, 0x808000)
$Nextb = GUICtrlCreateButton( "Next", 216, 144, 75, 25)

$Form1_2 = GUICreate("RuneScape Hacker", 343, 195, 192, 224)
$input1_2_1 = GUICtrlCreateInput("", 64, 40, 225, 21)
$Label1_2_1 = GUICtrlCreateLabel("Enter something else:", 64, 16, 198, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Goudy Old Style")
GUICtrlSetColor(-1, 0x808000)
$Doneb1_2 = GUICtrlCreateButton( "Done", 216, 144, 75, 25)

GUISwitch($Form1_1)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg(1)

Select
  case $nMsg[0] = $Nextb
   MsgBox(0, "title", "Next Clicked")
   ValidateUser()
   GUISetState(@SW_HIDE)
   GUISwitch($Form1_2)
   GUISetState(@SW_SHOW)
  case $nMsg[0] = $GUI_EVENT_CLOSE and $nMsg[1] = $Form1_1
   MsgBox(0, "title", "You Clicked Close on the First Window")
   ExitLoop
  case $nMsg[0] = $GUI_EVENT_CLOSE and $nMsg[1] = $Form1_2
   MsgBox(0, "title", "You Clicked Close on the Second Window")
   ExitLoop
  case $nMsg[0] = $Doneb1_2
   MsgBox(0, "title", "You Clicked Done on the Second Window")
   ExitLoop
EndSelect
WEnd

Func ValidateUser()
msgBox(0,"","Checking ID and Password")
EndFunc

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  

×