jammz Posted May 19, 2012 Share Posted May 19, 2012 (edited) Is it possible to validate an Input entry to two variables (can't really explain it properly) 7e.g. comparing an entry from an input to John and Jane. If they are John or Jane, it does something while if it's Derek or Bill, it does something else;WLM/CAD Player Name If GuiCtrlRead($PlayerEnter) = ("WLM" OR "CAD") Then $WLM1 = IniWrite( "UserVariables.inc","Variables","Name","#AltPlayer#") $WLM2 = IniWrite( "UserVariables.inc","Variables","AltPlayer", GUICtrlRead($CadEnter)) Else $WLM3 = IniWrite( "UserVariables.inc","Variables","Name","#Player#") EndIf Edited May 19, 2012 by jammz Link to comment Share on other sites More sharing options...
Zedna Posted May 19, 2012 Share Posted May 19, 2012 ;WLM/CAD Player Name $value = GuiCtrlRead($PlayerEnter) If $value = "WLM" OR $value = "CAD" Then $WLM1 = IniWrite( "UserVariables.inc","Variables","Name","#AltPlayer#") $WLM2 = IniWrite( "UserVariables.inc","Variables","AltPlayer", GUICtrlRead($CadEnter)) Else $WLM3 = IniWrite( "UserVariables.inc","Variables","Name","#Player#") EndIf Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
jammz Posted May 19, 2012 Author Share Posted May 19, 2012 Thanks Link to comment Share on other sites More sharing options...
PhoenixXL Posted May 19, 2012 Share Posted May 19, 2012 Try Switch Its Faster than the If....... $value = GuiCtrlRead($PlayerEnter) Switch $value Case 'WLM','CAD' IniWrite('x.ini','help','data',$value) Case Else ;You can do it EndSwitch My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
jammz Posted May 19, 2012 Author Share Posted May 19, 2012 (edited) Thanks, I tried it and it worked.(I actually need a bit more help. I'm trying to make the second input and label of the following code ($cadlabel and $CadEnter respectively) but it won't work) expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ScrollBarConstants.au3> #include <array.au3> #include <GuiStatusBar.au3> #include <GuiEdit.au3> #include <GuiButton.au3> #include <Misc.au3> #include <String.au3> #Include <File.au3> #include <SliderConstants.au3> #Include <GuiScrollBars.au3> Opt("TrayIconHide", 1) opt("GUIOnEventMode", 1) $Var1 = IniRead("UserVariables.inc", "Variables", "Player", "") $Var2 = IniRead("UserVariables.inc", "Variables", "AltPlayer", "") $GUI = GUICreate("Settings", 250, 155) $PlayerLabel = GUICtrlCreateLabel("Player (Rainmeter Variable)" , 10, 10) $PlayerEnter = GUICtrlCreateInput("" ,10 ,30, 230, 20) $CADLabel = GUICtrlCreateLabel("Please enter real player name here" , 10, 70, 230, 15, $GUI_DISABLE) $CadEnter = GUICtrlCreateInput("" ,10 ,90, 230, 20, $GUI_DISABLE) $Apply = GUICtrlCreateButton("Apply and Close", 140, 120, 100, 25) GUICtrlSetOnEvent ( $Apply, "_Apply" ) GUISetOnEvent ( $GUI_EVENT_CLOSE, "_Close" ) GUISetState(@SW_SHOW) While 1 Sleep ( 20 ) WEnd Func _Switch() While GuiCtrlRead($PlayerEnter) = "WLM" OR GuiCtrlRead($PlayerEnter) = "CAD" GUICtrlSetState ( $CADLabel, $GUI_ENABLE) GUICtrlSetState ( $CADEnter, $GUI_ENABLE) WEnd EndFunc Func _Apply ( ) IniWrite("UserVariables.inc","Variables","Player",GUICtrlRead($PlayerEnter)) ;Spotify Time Hide If GuiCtrlRead($PlayerEnter) = "Spotify" Then IniWrite( "UserVariables.inc","Variables","UnsupportedHidden","1") Else IniWrite( "UserVariables.inc","Variables","UnsupportedHidden","0") EndIf ;WLM/CAD Player Name $value = GuiCtrlRead($PlayerEnter) Switch $value Case 'WLM','CAD' IniWrite( "UserVariables.inc","Variables","Name","#AltPlayer#") IniWrite( "UserVariables.inc","Variables","AltPlayer", GUICtrlRead($CadEnter)) Case Else IniWrite( "UserVariables.inc","Variables","Name","#Player#") EndSwitch ;$value = GuiCtrlRead($PlayerEnter) ;If $Value = "WLM" OR $value = "CAD" Then ;IniWrite( "UserVariables.inc","Variables","Name","#AltPlayer#") ;IniWrite( "UserVariables.inc","Variables","AltPlayer", GUICtrlRead($CadEnter)) ;Else ;IniWrite( "UserVariables.inc","Variables","Name","#Player#") ;EndIf Exit EndFunc Func _Close ( ) Exit EndFunc Edited May 19, 2012 by jammz Link to comment Share on other sites More sharing options...
PhoenixXL Posted May 19, 2012 Share Posted May 19, 2012 (edited) On Creating a Control U are actually Defining its Styes and Ex_Styles not States Coz $GUI_DISABLE represents State it has to be called using GUICtrlSetState() Your _Switch Funtion was first of all not being called and also a little Buggy ......... I wrote your Code again correcting the _Switch Function and the using GUICtrlSetState() Code:expandcollapse popupGlobal Const $GUI_ENABLE = 64 Global Const $GUI_DISABLE = 128 ;#include <WindowsConstants.au3> Opt("TrayIconHide", 1) opt("GUIOnEventMode", 1) AdlibRegister('_Switch') $Var1 = IniRead("UserVariables.inc", "Variables", "Player", "") $Var2 = IniRead("UserVariables.inc", "Variables", "AltPlayer", "") $GUI = GUICreate("Settings", 250, 155) $PlayerLabel = GUICtrlCreateLabel("Player (Rainmeter Variable)" , 10, 10) $PlayerEnter = GUICtrlCreateInput("" ,10 ,30, 230, 20) $CADLabel = GUICtrlCreateLabel("Please enter real player name here" , 10, 70, 230, 15) GUICtrlSetState(-1, $GUI_DISABLE) $CadEnter = GUICtrlCreateInput("" ,10 ,90, 230, 20) GUICtrlSetState(-1, $GUI_DISABLE) $Apply = GUICtrlCreateButton("Apply and Close", 140, 120, 100, 25) GUICtrlSetOnEvent ( $Apply, "_Apply" ) GUISetOnEvent ( $GUI_EVENT_CLOSE, "_Close" ) GUISetState(@SW_SHOW) While 1 Sleep ( 20 ) WEnd Func _Switch() If BitAND(GUICtrlGetState ($CADEnter),$GUI_DISABLE) And GuiCtrlRead($PlayerEnter) = "WLM" OR GuiCtrlRead($PlayerEnter) = "CAD" Then GUICtrlSetState ( $CADLabel, $GUI_ENABLE) GUICtrlSetState ( $CADEnter, $GUI_ENABLE) ElseIf BitAND(GUICtrlGetState ($CADLabel),$GUI_ENABLE) And GuiCtrlRead($PlayerEnter) <> "WLM" Then If GuiCtrlRead($PlayerEnter) ="CAD" Then Return GUICtrlSetState ( $CADLabel, $GUI_DISABLE) GUICtrlSetState ( $CADEnter, $GUI_DISABLE) EndIf EndFunc Func _Apply ( ) IniWrite("UserVariables.inc","Variables","Player",GUICtrlRead($PlayerEnter)) ;Spotify Time Hide If GuiCtrlRead($PlayerEnter) = "Spotify" Then IniWrite( "UserVariables.inc","Variables","UnsupportedHidden","1") Else IniWrite( "UserVariables.inc","Variables","UnsupportedHidden","0") EndIf ;WLM/CAD Player Name $value = GuiCtrlRead($PlayerEnter) Switch $value Case 'WLM','CAD' IniWrite( "UserVariables.inc","Variables","Name","#AltPlayer#") IniWrite( "UserVariables.inc","Variables","AltPlayer", GUICtrlRead($CadEnter)) Case Else IniWrite( "UserVariables.inc","Variables","Name","#Player#") EndSwitch ;$value = GuiCtrlRead($PlayerEnter) ;If $Value = "WLM" OR $value = "CAD" Then ;IniWrite( "UserVariables.inc","Variables","Name","#AltPlayer#") ;IniWrite( "UserVariables.inc","Variables","AltPlayer", GUICtrlRead($CadEnter)) ;Else ;IniWrite( "UserVariables.inc","Variables","Name","#Player#") ;EndIf Exit EndFunc Func _Close ( ) Exit EndFunc I always Use to Remove the Includes and Embedd the Functions or Global Constants Directly in the Script......... It Reduces the Size of the Script............. N good to see that U used Switch in place of if statements......... Regards Phoenix XL Edited May 19, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
Zedna Posted May 19, 2012 Share Posted May 19, 2012 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ScrollBarConstants.au3> #include <array.au3> #include <GuiStatusBar.au3> #include <GuiEdit.au3> #include <GuiButton.au3> #include <Misc.au3> #include <String.au3> #Include <File.au3> #include <SliderConstants.au3> #Include <GuiScrollBars.au3> #NoTrayIcon opt("GUIOnEventMode", 1) $Var1 = IniRead("UserVariables.inc", "Variables", "Player", "") $Var2 = IniRead("UserVariables.inc", "Variables", "AltPlayer", "") $GUI = GUICreate("Settings", 250, 155) $PlayerLabel = GUICtrlCreateLabel("Player (Rainmeter Variable)" , 10, 10) $PlayerEnter = GUICtrlCreateInput("" ,10 ,30, 230, 20) $CADLabel = GUICtrlCreateLabel("Please enter real player name here" , 10, 70, 230, 15, $GUI_DISABLE) $CadEnter = GUICtrlCreateInput("" ,10 ,90, 230, 20, $GUI_DISABLE) GUICtrlSetState($CADEnter, $GUI_DISABLE) $Apply = GUICtrlCreateButton("Apply and Close", 140, 120, 100, 25) GUICtrlSetOnEvent ( $Apply, "_Apply" ) GUISetOnEvent ( $GUI_EVENT_CLOSE, "_Close" ) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 Sleep ( 20 ) WEnd Func WM_COMMAND($hWnd, $MsgID, $wParam, $lParam) Local $nID = BitAND($wParam, 0xFFFF) Local $nNotifyCode = BitShift($wParam, 16) If $nNotifyCode = $EN_CHANGE Then If $nID = $PlayerEnter Then $value = GuiCtrlRead($PlayerEnter) If $value = "WLM" OR $value = "CAD" Then GUICtrlSetState($CADEnter, $GUI_ENABLE) Else GUICtrlSetState($CADEnter, $GUI_DISABLE) EndIf EndIf EndIf Return $GUI_RUNDEFMSG EndFunc Func _Apply ( ) IniWrite("UserVariables.inc","Variables","Player",GUICtrlRead($PlayerEnter)) ;Spotify Time Hide If GuiCtrlRead($PlayerEnter) = "Spotify" Then IniWrite( "UserVariables.inc","Variables","UnsupportedHidden","1") Else IniWrite( "UserVariables.inc","Variables","UnsupportedHidden","0") EndIf ;WLM/CAD Player Name $value = GuiCtrlRead($PlayerEnter) Switch $value Case 'WLM','CAD' IniWrite( "UserVariables.inc","Variables","Name","#AltPlayer#") IniWrite( "UserVariables.inc","Variables","AltPlayer", GUICtrlRead($CadEnter)) Case Else IniWrite( "UserVariables.inc","Variables","Name","#Player#") EndSwitch ;$value = GuiCtrlRead($PlayerEnter) ;If $Value = "WLM" OR $value = "CAD" Then ;IniWrite( "UserVariables.inc","Variables","Name","#AltPlayer#") ;IniWrite( "UserVariables.inc","Variables","AltPlayer", GUICtrlRead($CadEnter)) ;Else ;IniWrite( "UserVariables.inc","Variables","Name","#Player#") ;EndIf Exit EndFunc Func _Close ( ) Exit EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
PhoenixXL Posted May 19, 2012 Share Posted May 19, 2012 Zedna's Style has Nothing to do with the Timer of AdlibRegister................ A good Way............. I'm learning a lot from Zedna..... My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
jammz Posted May 19, 2012 Author Share Posted May 19, 2012 Thanks both of youZedna's Style has Nothing to do with the Timer of AdlibRegister................A good Way.............I'm learning a lot from Zedna..... And i'm learning from both of you 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