Jump to content

Button functionality


Kowala
 Share

Recommended Posts

Respected AutoIT Community,

I have a simple GUI (Koda) with two buttons. I would like to take the two stated buttons $Player and $Readme and give them functionality. My end goal is to run a install from the Player button and launch a .pdf from the Readme button. I have spent the afternoon reading AutoIT Help and browsing the forum but have yet to find a clear answer. I believe I need to use OnEvent type commands but have not been able to get it to work thus far. It seems it is a relatively simple task that I am making overly complex. I have only included the Koda script. If someone could send me in the right direction I would be ever grateful!

Thank you,

Kowala

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

#Region ### START Koda GUI section ### Form=c:\temp\koda\forms\secvidmenu.kxf
$Form1_1 = GUICreate("DRCI - Security Videos", 330, 250, 308, 204)
$Label1 = GUICtrlCreateLabel("HikVision Player", 24, 16, 133, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("The Hikvision Player button below launches the", 24, 40, 284, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("software required to view .mp4 security videos.", 24, 56, 279, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Use File/Open to navigate the CD and locate", 24, 72, 269, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("desired video.", 24, 88, 90, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("Readme", 24, 120, 71, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label7 = GUICtrlCreateLabel("The Readme button below launches a basic", 24, 144, 266, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label8 = GUICtrlCreateLabel("step by step tutorial for HikVision Player use.", 24, 160, 267, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Player = GUICtrlCreateButton("HikVision Player", 24, 200, 91, 25, 0)
$Readme = GUICtrlCreateButton("Readme", 176, 200, 91, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

EndSwitch
WEnd
Link to comment
Share on other sites

Example of how to call functions from the message loop in response to control clicks

While 1
  $nMsg = GUIGetMsg()
  Switch $nMsg
    Case $GUI_EVENT_CLOSE
       Exit
    Case $Player
      PlayerFuction()
    Case $Readme
      ReadmeFuction()
  EndSwitch
WEnd

Func PlayerFuction()
;Demo code
MsgBox(0,"Test","You clicked the Player button")

EndFunc

Func ReadmeFuction()
;Demo code
MsgBox(0,"Test","You clicked the Readme button")
EndFunc

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...