Sign in to follow this  
Followers 0
SteveO

GUICtrlSet Problems

7 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Mmmm. Still doesn't work. It still wont change when I press F1 or F2.


Share this post


Link to post
Share on other sites

Mmmm. Still doesn't work. It still wont change when I press F1 or F2.

It works for me, what are you talking about. :P

Share this post


Link to post
Share on other sites

It works for me, what are you talking about. :P

The Status on the GUI Changes from "IDLE..." to "STANDING UP..." when you press F1 and F2?


Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Damnit my PC sucks. I just sent the script to my buddy and it works for him. But for some reason it doesn't work for me. Thanks for the help.

Edited by SteveO

Share this post


Link to post
Share on other sites

The Status on the GUI Changes from "IDLE..." to "STANDING UP..." when you press F1 and F2?

Yes and the color changes as it should. If you want I can take a video and upload it..but it will take some time/work

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  
Followers 0