Jump to content

Data Switch in one Control


Kalin
 Share

Recommended Posts

So I'm trying to make where when I press a button it switches data in the control with a different event.

Any pointers, code example(s), or help on this?

Example

Button here... [Title: Go] [Functionality: When you press go it sends raw keys]

User presses button...

Button here... [Title: Stop] [Functionality: When you press stop it stops sending the keys raw]

;)

Link to comment
Share on other sites

So I'm trying to make where when I press a button it switches data in the control with a different event.

Any pointers, code example(s), or help on this?

Example

Button here... [Title: Go] [Functionality: When you press go it sends raw keys]

User presses button...

Button here... [Title: Stop] [Functionality: When you press stop it stops sending the keys raw]

;)

Define 'raw keys'..?

Here's something to get you started. Hopefully it's what you wanted.

#include <GUIConstants.au3>

;GUI creation
$gui = GUICreate("", 175, 50)
$button = GUICtrlCreateButton("", 0, 0, 175, 50)
GUISetState()

Global $tog, $color[2][2]
;button colors
$color[0][0] = 0xff0000;False
$color[0][1] = 0x00ff00;True
;text colors
$color[1][0] = 0xffffff;False
$color[1][1] = 0x000000;True

;Set the GUI elements to False
update("False")

While 1
    $msg = GUIGetMsg($gui)
    If $msg = $GUI_Event_Close Then
        Exit
    ElseIf $msg = $button Then
        tog()
    EndIf
WEnd

;Toggle the truth of $tog (True <-> False)
Func tog()
    $tog = Not $tog
    rawKeys($tog)
EndFunc

;Update the GUI and do something based on the setting of $raw
Func rawKeys($raw)
    update($raw)
    setRawKeys($raw)
EndFunc

;Update the GUI elements to match the state of $text
Func update($text)
    WinSetTitle($gui, "", $text)
    GUICtrlSetData($button, $text)
    GUICtrlSetBkColor($button, $color[0][$text])
    GUICtrlSetColor($button, $color[1][$text])
EndFunc

;This can be changed to do whatever you need it to do when enabled or disabled
Func setRawKeys($set)
    If $set Then
        MsgBox(262144, $set, "Raw keys enabled.", 2)
    Else
;       MsgBox(262144, $set, "Raw keys disabled.", 2)
    EndIf
EndFunc
Edited by cembry90

AutoIt Stuff:

 

UDFs: {Grow}

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...