ahmeddzcom Posted November 3, 2019 Share Posted November 3, 2019 Hi Clicking on Button working But Clicking on label not working expandcollapse popup#include <GUIConstants.au3> #include <Misc.au3> $Blue = "0x0000FF" $Red = "0xFF0000" $FNT = "Comic Sans Ms" GUICreate ("Test") $idButton = GUICtrlCreateButton("Change", 210, 170, 85, 25) If RegRead("HKEY_CURRENT_USER\Software","Dz") = "0" Then $idLabel = GUICtrlCreateLabel ("Label", 122, 74, 100, 18) GUICtrlSetColor($idLabel, $Red) GUICtrlSetFont(-1, 12, $FW_NORMAL, $GUI_FONTITALIC,$FNT) Else $idLabel = GUICtrlCreateLabel ("Label", 122, 74, 100, 18) GUICtrlSetColor($idLabel, $Blue) GUICtrlSetFont(-1, 12, $FW_NORMAL, $GUI_FONTITALIC,$FNT) RegWrite("HKEY_CURRENT_USER\Software","Dz","REG_SZ","1") EndIf GUISetState () While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton , $idLabel If RegRead("HKEY_CURRENT_USER\Software","Dz") = 1 Then $idLabel = GUICtrlCreateLabel ("Label", 122, 74, 100, 18) GUICtrlSetColor($idLabel, $Red) GUICtrlSetFont(-1, 12, $FW_NORMAL, $GUI_FONTITALIC,$FNT) RegWrite("HKEY_CURRENT_USER\Software","Dz","REG_SZ","0") Else $idLabel = GUICtrlCreateLabel ("Label", 122, 74, 100, 18) GUICtrlSetColor($idLabel, $Blue) GUICtrlSetFont(-1, 12, $FW_NORMAL, $GUI_FONTITALIC,$FNT) RegWrite("HKEY_CURRENT_USER\Software","Dz","REG_SZ","1") EndIf EndSwitch Wend Link to comment Share on other sites More sharing options...
water Posted November 3, 2019 Share Posted November 3, 2019 I think you need to set the label style to $SS_RIGHT. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Zedna Posted November 3, 2019 Share Posted November 3, 2019 (edited) This is working fine: - regread/regwrite changed to read/set global variable - removed unnecessary GUICtrlCreateLabel() from main loop - some minor fixes/optimizations expandcollapse popup#include <GUIConstants.au3> #include <Misc.au3> Global $switch = 1 $Blue = "0x0000FF" $Red = "0xFF0000" $FNT = "Comic Sans Ms" GUICreate ("Test") $idButton = GUICtrlCreateButton("Change", 210, 170, 85, 25) $idLabel = GUICtrlCreateLabel ("Label", 122, 74, 100, 18) ;~ If RegRead("HKEY_CURRENT_USER\Software","Dz") = "0" Then If $switch = 0 Then $color = $Red Else $color = $Blue $switch = 1 ;~ RegWrite("HKEY_CURRENT_USER\Software","Dz","REG_SZ","1") EndIf GUICtrlSetColor($idLabel, $color) GUICtrlSetFont(-1, 12, $FW_NORMAL, $GUI_FONTITALIC,$FNT) GUISetState () While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton , $idLabel If $switch = 1 Then ;~ If RegRead("HKEY_CURRENT_USER\Software","Dz") = 1 Then ;~ $idLabel = GUICtrlCreateLabel ("Label", 122, 74, 100, 18) $color = $Red $switch = 0 ;~ RegWrite("HKEY_CURRENT_USER\Software","Dz","REG_SZ","0") Else ;~ $idLabel = GUICtrlCreateLabel ("Label", 122, 74, 100, 18) $color = $Blue $switch = 1 ;~ RegWrite("HKEY_CURRENT_USER\Software","Dz","REG_SZ","1") EndIf GUICtrlSetColor($idLabel, $color) ;~ GUICtrlSetFont(-1, 12, $FW_NORMAL, $GUI_FONTITALIC,$FNT) EndSwitch Wend Edited November 3, 2019 by Zedna ahmeddzcom 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ahmeddzcom Posted November 4, 2019 Author Share Posted November 4, 2019 7 hours ago, Zedna said: This is working fine: ............ expandcollapse popup#include <GUIConstants.au3> #include <Misc.au3> $Blue = "0x0000FF" $Red = "0xFF0000" $FNT = "Comic Sans Ms" GUICreate ("Test") $idButton = GUICtrlCreateButton("Change", 210, 170, 85, 25) $idLabel = GUICtrlCreateLabel ("Label", 122, 74, 100, 18) If RegRead("HKEY_CURRENT_USER\Software","Dz") = "0" Then $color = $Red Else $color = $Blue RegWrite("HKEY_CURRENT_USER\Software","Dz","REG_SZ","1") EndIf GUICtrlSetColor($idLabel, $color) GUICtrlSetFont(-1, 12, $FW_NORMAL, $GUI_FONTITALIC,$FNT) GUISetState () While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton , $idLabel If RegRead("HKEY_CURRENT_USER\Software","Dz") = 1 Then $color = $Red RegWrite("HKEY_CURRENT_USER\Software","Dz","REG_SZ","0") Else $color = $Blue RegWrite("HKEY_CURRENT_USER\Software","Dz","REG_SZ","1") EndIf GUICtrlSetColor($idLabel, $color) EndSwitch Wend Thanks Zenda Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now