Jump to content

GUICtrlSet Problems


SteveO
 Share

Recommended Posts

Okay, all this program does is repetitively press 8 when the hotkey F1 is pressed, and it stops when F2 is pressed. Now what I want to do is change the message in the GUI from Idle... to Standing Up... and also change the color of the message when F1 or F2 is pressed. But for some reason, the GUICtrlSetData and GUICtrlSetColor do not want to work.

#include <GUIConstants.au3>

;HotKey Settings
HotKeySet("{F1}", "Revive") ;Starts Revival Function
HotKeySet("{F2}", "EndRevive") ;Ends Revival Function

;Variable Sets
$Rev = 0
$message = "IDLE..."


$Form1 = GUICreate("STAND UP!", 248, 80, 211, 376)
$Group1 = GUICtrlCreateGroup("Status", 8, 32, 145, 41)
$Label1 = GUICtrlCreateLabel("IDLE...", 16, 48, 127, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label2 = GUICtrlCreateLabel("STAND UP v1.0", 8, 8, 96, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000080)
$Label3 = GUICtrlCreateLabel("F1 : STAND UP!", 160, 40, 83, 17)
GUICtrlSetColor(-1, 0x008000)
$Label4 = GUICtrlCreateLabel("F2 : Stop", 160, 56, 47, 17)
GUICtrlSetColor(-1, 0xFF0000)
GUISetState(@SW_SHOW)


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

    EndSwitch
WEnd


;Revive Function - Starts Pressing 8
Func Revive($Rev)

$Rev = 1
GUICtrlSetData($Label1, "STANDING UP...")
GUICtrlSetColor($Label1, 0x008000)  

While $Rev == 1
Send(8)
WEnd

EndFunc

;EndRevival Function - Sets $Rev variable to 0 so 8 will stop being pressed
Func EndRevive($Rev)

$Rev = 0
GUICtrlSetData($Label1, "IDLE...")
GUICtrlSetColor($Label1,0xFF0000)  


EndFunc
Link to comment
Share on other sites

Problems were

You were calling the function with a variable but you shouldn't have been :P

also

You used While $Rev == 1 , this isn't C++ should be While $Rev = 1

#include <GUIConstants.au3>

;HotKey Settings
HotKeySet("{F1}", "Revive") ;Starts Revival Function
HotKeySet("{F2}", "EndRevive") ;Ends Revival Function

;Variable Sets
Global $Rev = 0
$message = "IDLE..."


$Form1 = GUICreate("STAND UP!", 248, 80, 211, 376)
$Group1 = GUICtrlCreateGroup("Status", 8, 32, 145, 41)
$Label1 = GUICtrlCreateLabel("IDLE...", 16, 48, 127, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label2 = GUICtrlCreateLabel("STAND UP v1.0", 8, 8, 96, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000080)
$Label3 = GUICtrlCreateLabel("F1 : STAND UP!", 160, 40, 83, 17)
GUICtrlSetColor(-1, 0x008000)
$Label4 = GUICtrlCreateLabel("F2 : Stop", 160, 56, 47, 17)
GUICtrlSetColor(-1, 0xFF0000)
GUISetState(@SW_SHOW)


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

    EndSwitch
WEnd


;Revive Function - Starts Pressing 8
Func Revive()

$Rev = 1
GUICtrlSetData($Label1, "STANDING UP...")
GUICtrlSetColor($Label1, 0x008000) 

While $Rev = 1
Send(8)
WEnd

EndFunc

;EndRevival Function - Sets $Rev variable to 0 so 8 will stop being pressed
Func EndRevive()

$Rev = 0
GUICtrlSetData($Label1, "IDLE...")
GUICtrlSetColor($Label1,0xFF0000) 


EndFunc
Edited by Thatsgreat2345
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...