Jump to content
Zag8888

[SOLVED] $GUI_CHECKED Little problem

Recommended Posts

Posted (edited)

Hey folks, I have a little problem with my script.

I have no experience with these things, and I know for¬† sure that my code is not the best, but please be lenient, thanks ūüėÖ

The User should first choose 1 of the 2 Options to actually start the script. If 1 of the 2 Option is choosen then the User should click start again and all should work.

I have already commented the problem, If the button Start is clicked before, the User will select just 1 of the 2 option and the program will start (Without clicking start).How can I set $Start to $GUI_UNCHECKED? I have already tried to use GuiCtrlSetState, but didnt worked.

 

$Start = GuiCtrlCreateButton("Start", 20, 200, 90, 50,bitor($BS_CENTER,0,0))
GUICtrlSetOnEvent($Start,"Startallrun")
Func Startallrun()
   If ((GUICtrlRead($Option1) = $GUI_UNCHECKED) And (GUICtrlRead($Option2) = $GUI_UNCHECKED)) Then
         MsgBox($MB_OK, "Error", "You have to select 1 Option")
         While (GUICtrlRead($Option1) = $GUI_UNCHECKED)
            Sleep(10)
            If (GUICtrlRead($Option1) = $GUI_CHECKED) Or (GUICtrlRead($Option2) = $GUI_CHECKED) Then
            GUICtrlSetState($Start,$GUI_UNCHECKED) ; This doesen't work for Buttons
               While (GUICtrlRead($Start) = $GUI_UNCHECKED)
                  Sleep(10)
                  If ($Start = $GUI_CHECKED) Then ; That's the problem. The script will start if I click one of the 2 options (because start was already checked before)
                     ExitLoop
                  EndIf
               WEnd
               ExitLoop
            EndIf
         WEnd
      Else
         If (GUICtrlRead($Option1) = $GUI_CHECKED) Then
            MsgBox($MB_OK, "Starting", "Start")
            Start()
         EndIf
      EndIf
EndFunc

 

Edited by Zag8888
Solved

Share this post


Link to post
Share on other sites

Zag8888,

Firstly, how about posting some runnable code rather then a snippet. Then, how about explaining what you are trying to do and what is not working so we can see how we might help you. At the moment it is a bit hard to offer suggestions when we have no idea where the problem actually lies.

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Posted (edited)

Hello Melba23, I have added some more info in the thread.

I really don't understand how to Uncheck a button, I have tried to use GUICtrlSetState, but it doesen't worked for me

Edited by Melba23
Merged and quotes removed

Share this post


Link to post
Share on other sites

Zag8888,

I did say "runnable" code - all we have is a function and button creation/assignment. Where are the GUI. the $StoryMode and $Option1 controls, etc?

And what exactly do you mean by "unchecking" a button - you check/uncheck radios and checkboxes, not normal buttons.

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
15 minutes ago, Melba23 said:

Zag8888,

I did say "runnable" code - all we have is a function and button creation/assignment. Where are the GUI. the $StoryMode and $Option1 controls, etc?

And what exactly do you mean by "unchecking" a button - you check/uncheck radios and checkboxes, not normal buttons.

M23

$StoryMode,$Option1 and $Option2 are just Radio.

 

When I click Start the Function Start() will run, but only if 1 of these 3 radio are selected, after I select 1 option the code will start immediately (Without waiting for the click start again).

 

Share this post


Link to post
Share on other sites

Just disable the $Start button, then use an GuiSetOnEvent for $Option1 and $Option2 to enable the start button e.g. this way, they must choose one of the options before pushing the start button.  Also for the Startallrun() function you only need to know which option is checked see example below.
nb: I've prefixed my variables with $id to show that they're control ids.

idOption1 = GUICtrlCreateRadio("Option 1", 10, 10, 120, 20)
    GUICtrlSetOnEvent($idOption1,"_EnableStart")
$idOption2 = GUICtrlCreateRadio("Option 2", 10, 40, 120, 20)
    GUICtrlSetOnEvent($idOption2,"_EnableStart")
$idStart = GuiCtrlCreateButton("Select Radio Above", 10, 70, 120, 50,bitor($BS_CENTER,0,0))
    GUICtrlSetOnEvent($idStart,"Startallrun")
    GUICtrlSetState($idStart, $GUI_DISABLE)

Func _EnableStart()
    GUICtrlSetState($idStart, $GUI_ENABLE)
EndFunc

Func Startallrun()
    If GUICtrlRead($idOption1) = $GUI_CHECKED Then
        MsgBox(4096, "Starting", "Running Option 1")
    ElseIf GUICtrlRead($idOption2) = $GUI_CHECKED Then
        MsgBox(4096, "Starting", "Running Option 2")
    EndIf
EndFunc

 

Share this post


Link to post
Share on other sites
3 minutes ago, Subz said:

Just disable the $Start button, then use an GuiSetOnEvent for $Option1 and $Option2 to enable the start button e.g. this way, they must choose one of the options before pushing the start button.  Also for the Startallrun() function you only need to know which option is checked see example below.
nb: I've prefixed my variables with $id to show that they're control ids.

idOption1 = GUICtrlCreateRadio("Option 1", 10, 10, 120, 20)
    GUICtrlSetOnEvent($idOption1,"_EnableStart")
$idOption2 = GUICtrlCreateRadio("Option 2", 10, 40, 120, 20)
    GUICtrlSetOnEvent($idOption2,"_EnableStart")
$idStart = GuiCtrlCreateButton("Select Radio Above", 10, 70, 120, 50,bitor($BS_CENTER,0,0))
    GUICtrlSetOnEvent($idStart,"Startallrun")
    GUICtrlSetState($idStart, $GUI_DISABLE)

Func _EnableStart()
    GUICtrlSetState($idStart, $GUI_ENABLE)
EndFunc

Func Startallrun()
    If GUICtrlRead($idOption1) = $GUI_CHECKED Then
        MsgBox(4096, "Starting", "Running Option 1")
    ElseIf GUICtrlRead($idOption2) = $GUI_CHECKED Then
        MsgBox(4096, "Starting", "Running Option 2")
    EndIf
EndFunc

 

I have already resolved my problem using $GUI_DISABLE, but thanks for the help, I appreciate :)

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

  • Similar Content

    • By hendrikhe
      Hello,
      I am wondering how to "scroll" to left and right  (till the end ) on a webpage .
      Sending Arrow left/right only moves a bit, I wan to move isntaly to the end
      Up and down is easily done sending Page Up and Page Down.
      Any ideas?
      Greetings
      Hendrik
    • By Silas
      Hello Internet,
      I am trying to create 10 labels, which all show a history of transactions, in order.
      Problem is, it get's confused when I try to use [$i] to create different variables. How can I create different labels and thus variables with this?
      For $i=1 to 10 Assign("PayH_" & $i, 20) ;Creates the variables for the values Global $PayHLabel_[$i] = GUICtrlCreateLabel($PayH_[$i], 30, 30) ;Creates the labels which show the values Next I know I can do this without a For Loop, but I am trying to learn how to keep my script short.
      Thanks in advance.
    • By Zag8888
      $x1 = InputBox("xx", "xxxx?")
      if ($x1 = 1) Then
         MouseClick(132,393,1)
         Sleep(5000)
      EndIf
       
      So if I input 1 the if statement should work but it won't, what I wrong?
    • By Docfxit
      I'm getting an error in this script:
      Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) TrayTip("clears any tray tip","",0) AutoItSetOption("TrayIconDebug", 1) ;0-off #include "OSVersion.au3" Run('C:\Dnload\9xAddons\TestThis.exe') MsgBox("","Test","$ProgramFiles - " & $ProgramFiles & @CRLF & "_OSVersion() - " & _OSVersion()) Exit This is the error I am getting:

      The variables should be defined in the #include "OSVersion.au3"
      Func _OSVersion() Global $OSVersion Local $sWinVer = FileGetVersion('winver.exe') $OS_Version = @OSVersion $servicepack_version = StringReplace(@OSServicePack, "Service Pack ", "SP") If @error = -1 Then $servicepack_version = "" ConsoleWrite($OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') & @CRLF) ConsoleWrite(@OSArch & @CRLF) If $OSVersion = 'Win7' Or $OSVersion = 'Win7SP1' Or $OSVersion = 'Win7X64' Or $OSVersion = 'Win7SP1x64' Then $ProgramFiles = "C:\Programs\" Else $ProgramFiles = "C:\Program Files\" EndIf Return $OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') EndFunc ;==>_OSVersion What do I need to do to resolve the error?
      Thanks,
      Docfxit
    • By coles
      Hi All,
      Need a help with Autoit task, I am trying to copy an XML file and edit that XML file and copy it back
      The script i have attached if the script we use to copy files to client from server, so basically what it does is
      Going through a Set of IP address and 
      Map the drive Copy the file Write copy process was success Goes on a loop through IP's to check all machines have updated files   #include <File.au3> #include <iNet.au3> #include <_XMLDomWrapper.au3> func latestUpdate($address, $name) Local $result Local $hFileIndexHTML DriveMapDel ( "G:" ) ConsoleWrite('Trying: ' & $address & "/" & $name & @CRLF); $result = DriveMapAdd ( "G:", "\\" & $address & "\C$", 0, $name & "\adminname","adminpswd") ;Copying the file from Mapped drive to local if $result = 1 Then FileCopy( "G:\Program Files\test.xml", "C:\sample\test.xml", 1); ConsoleWrite('Copying Updated File: ' & $address & @CRLF); $hFileIndexHTML = FileOpen("C:\sample\test.txt", 1) FileWrite($hFileIndexHTML, $address & @CRLF) FileClose($hFileIndexHTML) EndIf EndFunc func done($file, $address) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) if ( $address = $line ) Then ConsoleWrite('Already done: ' & $file & " " & $address & @CRLF); return true EndIf Next return false EndFunc func getMachineName($ipaddress) return _TCPIpToName($ipaddress) EndFunc func process($address) local $machineName $machineName = getMachineName($address) if ($machineName = "") Then ConsoleWrite("No machine found at:" & $address & @CRLF) Else ConsoleWrite("Machine found at:" & $address & " - " & $machineName & @CRLF) if ( done( "C:\sample\test.txt", $address) = false ) then if ( $machineName <> "" ) then latestUpdate($address, $machineName) else endif endif EndIf EndFunc TCPStartup() while 1=1 PROCESS("10.10.1.1") sleep( 1000 * 60 * 10) wend The XML file i am trying to copy is unique and different in all machines (Machine name,ID's etc), But whole structure is the same (ie, the num of lines ) [That's the reason i can't copy a single file to all the machines].
      I was thinking of using _FileWriteToLine  to replace 3 lines with new data 
      eg:
      _FileWriteToLine("c:\sample\test.xml", 71,  "<RIA>"http://goog.html"</RIA>", True) 
      _FileWriteToLine("c:\sample\test.xml", 350,  "<col header="Status" width="7%" dataFld="status_code" style="" preprocesser="processES" template="" hidden="0"/>", True) 
      _FileWriteToLine("c:\sample\test.xml", 650,  "<col header="Units" width="11%" dataFld="units" style="" preprocesser="" template="fU(units)" hidden="0"/>", True) 
      These lines inside XML  
      340<em>
      341<gd
      342-360 is similar as blah blah <col header="Status" width="7%" dataFld="status_code" style="" preprocesser="processES" template="" hidden="0"/>
      same goes for 650th line also
       
      I would like to get opinion of copying this file as this is a highly critical file needed to keep machines running
       
      Do you think using _file write to line is risky?. Do you think i have to copy the file from parent folder to another folder after replacing the lines and then copy from there back to client system. This is all what i can think now, Any comments/suggestions will be much appreciated.
       
       
       
       
       
×
×
  • Create New...