Jump to content

Recommended Posts

Posted

Hi Guys

I wrote a script and produced a gui within koda to automate various tasks within a PC rollout

I want to do a little streamlining and have some hotkeys that group some tasks together

for example 2 buttons on the gui that release the ip address then shut down the PC

is there a way within a custom function in my script i can simulate clicking the 2 buttons?

Thanks

Grant

Posted

Clicking those buttons triggers calls to functions in your script. Why not just call the functions without bothering with the buttons?

:)

Because its a bit of a bodge job the button actions were written directly in the switch statement rather than calling functions. I guess its fairly simple to copy and paste each button into its own function then just write separate functions for the hot keys

just wanted to see if there was another way before carving up my code and potentially breaking it lol

Posted

Maybe like this?

#include <WindowsConstants.au3>
HotKeySet("{esc}", "_Button")
$hGui = GUICreate("Test", 300, 300, 200, 100, -1)
$hButton1 = GUICtrlCreateButton("MSGBox", 100, 100, 150, 25)
$hButton2 = GUICtrlCreateButton("InputBox", 100, 150, 150, 25)
Global $hButton = GUICtrlCreateButton("FileOpenDialog", 20, 220, 120, 25)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit
        Case $hButton1
            MsgBox(0, 'Button One', 'Hi', .5)
        Case $hButton2
            InputBox("Title", "What you want?")
        Case $hButton
            FileOpenDialog("", "", "(*)", Default, "", $hGui)
    EndSwitch
WEnd
Func _Button()
    $msg = $hButton1
EndFunc   ;==>_Button

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
×
×
  • Create New...