Jump to content

Recommended Posts

Hey everyone, new at visual basic. trying to write a program that checks to see which checkboxes are checked and then opens the programs associated with said boxes. I dont really have much to show for here, except that I was using a command similar to

if not ProcessExists ("firefox.exe") then Run("C:\Program Files\Mozilla Firefox\firefox.exe", "")

that i want to incorporate.

 

Link to comment
Share on other sites

  • Moderators

@Em4gdn1m, first off this forum is for AutoIt not Visual Basic. Secondly, you will find that when you provide nothing, nothing is what you get in return for assistance. Everyone was on Day 1 at one point, and we are here to help, but you also need to put in some effort. It sounds as though you want a GUI with some check boxes on it, and want code to run when you select the check box; something like this:

GUI.png

To get you started, here is the basic framework for a GUI:

#include <GUIConstantsEx.au3>

GUICreate("My Script", 300, 300)
GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

GUIDelete()

Why don't you spend some time looking at the help file, specifically GUICtrlCreateCheckBox and GUICtrlCreateButton, and the examples for each, and see what you can come up with. Once you have the GUI looking the way you want it, we can assist you with the logic behind your check boxes.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

wow. alright, sorry didn't think I needed to give you everything for you to understand my question.

I wasn't asking how to make a GUI or how to make checkboxes. I was asking how to check the state of those checkboxes and then running the programs that are associated with the checked boxes.

I know how to use the help file and look at the examples, i just cant seem to incorporate the checkboxes with the button. thanks for that though.

#include <GUIConstantsEx.au3>

MainGUI()

Func MainGUI()
  
  Local $kV, $mA, $ms, $setbutton, $closebutton, $kvplus, $kvminus, $maminus, $maplus, $pwplus, $pwminus, $pulsed, $resettime, $stime
  Local $CurrentMA, $CurrentCounts, $WantCount, $CalculateMA, $NewCount, $ResultmA, $CMA, $CCS, $WC
  Local $msg, $Firefox, $AAT601, $AAT602, $L0742, $L07502, $GenComm, $MCT, $FinalCopy, $SNSearch, $PanelSearch, $RunBtn, $CloseBtn, $Templates, $Notepad, $DImagers, $ColCalc
  
    GUICreate("Final Test Tools", 500, 300)
    GUISetState(@SW_SHOW)
    
    ;Generator Interface
    GuiCtrlCreateGroup("Generator Controller", 10, 10, 125, 250)
    GUICtrlCreateLabel("kV", 30, 30)
    $kV = GUICtrlCreateInput ("", 30, 45, 80, 20)
    GUICtrlCreateLabel("mA", 30, 80)
    $mA = GUICtrlCreateInput ("", 30, 95, 80, 20)
    GUICtrlCreateLabel("ms", 30, 130)
    $ms = GUICtrlCreateInput ("", 30, 145, 80, 20)
    $setbutton = GUICtrlCreateButton("SET ALL", 25, 220, 95)
    $pulsed = GUICtrlCreateButton("Pulsed", 25, 180, 95)
    ;$stime = 250
    
    ;mA Calulator
    GuiCtrlCreateGroup("mA Calculator", 145, 10, 150, 230)
    $CurrentMA = GUICtrlCreateinput("", 245, 25, 40, 25)
    $CurrentCounts = GUICtrlCreateInput("", 245, 55, 40,25)
    $WantCount = GUICtrlCreateInput("", 245, 85, 40,25)
    $CalculateMA = GUICtrlCreateButton("Calculate New mA", 170, 120, 100)
    GUICtrlCreateLabel("Current mA", 155, 30)
    GUICtrlCreateLabel("Current Counts", 155, 60)
    GUICtrlCreateLabel("Desired Counts", 155, 90)
    GUICtrlCreateGroup("New mA", 170, 160, 100, 60)
    $NewCount = GUISetFont(25)
    $NewCount = 0.0
    $ResultmA = GUICtrlCreateLabel($NewCount, 200, 175, 60, 40)
    
    
    ;Tool Boxes
    GUISetFont (8.5)
    $Firefox = GUICtrlCreateCheckbox("Firefox", 310, 55, 100)
    $DImagers = GUICtrlCreateCheckbox("D:\IMAGERs", 410, 55, 100)
    $AAT601 = GUICtrlCreateCheckbox("AAT 6.0.1", 310, 85, 100)
    $AAT602 = GUICtrlCreateCheckbox("AAT 6.0.2", 410, 85, 100)
    $GenComm = GUICtrlCreateCheckbox("GenComm", 310, 115, 100)
    $FinalCopy = GUICtrlCreateCheckbox("Final Copy", 410, 115, 100)
    $L0742 = GUICtrlCreateCheckbox("L07 4.2", 310, 145, 100)
    $L07502 = GUICtrlCreateCheckbox("L07 5.0.2", 410, 145, 100)
    $Templates = GUICtrlCreateCheckbox("Test Templates", 310, 175, 100)
    $MCT = GUICtrlCreateCheckbox("MCT", 410, 175, 100)
    $SNSearch = GUICtrlCreateCheckbox("S/N Search", 310, 205, 100)
    $PanelSearch = GUICtrlCreateCheckbox("Panel Search", 410, 205, 100)
    $ColCalc = GUICtrlCreateCheckbox("Column Calc.", 310, 235, 100)
    $Notepad = GUICtrlCreateCheckbox("Notepad++", 410, 235, 100) 
    $RunBtn = GUICtrlCreateButton("Run Programs", 330, 15, 130, 25)
    $CloseBtn = GUICtrlCreateButton("Close Programs", 330, 265, 130, 25)

  ; Run the GUI until the dialog is closed
  While 1
    $msg = GUIGetMsg()
    Select
        
        ;mA Calculator
        Case $msg = $CalculateMA
            $CMA = GUICtrlRead($CurrentMA)
            $CCS = GUICtrlRead($CurrentCounts)
            $WC = GUICtrlRead($WantCount)
            $NewCount = (($CMA * $WC) / $CCS)
            if $CMA <= 0.0 Then
                $NewCount = 0.0
            EndIf
            if $CCS <= 0.0 Then
                $NewCount = 0.0
            EndIf
            $NewCount = round($NewCount, 1)
            GUICtrlSetData($resultmA,$NewCount)
        
        ;Run Programs
        Case $msg = $RunBtn
            ;this is where im struggling. I want to open firefox and L074.2 by hitting the run program button etc etc if those are              ;the ones checked
        
        Case $msg = $GUI_EVENT_CLOSE
       ExitLoop
    EndSelect
  WEnd
EndFunc

 

 

 

 

 

Link to comment
Share on other sites

  • Moderators

I am a bit confused by your answers:

Quote

wow. alright, sorry didn't think I needed to give you everything for you to understand my question.

Not sure how, aside from giving an accurate description, you expect us to divine what you are after. When you start with stating that you are new to the language, and then stating you have nothing to show, what are we to conclude other than you need assistance from the start. That said:

Quote

I know how to use the help file and look at the examples, i just cant seem to incorporate the checkboxes with the button. thanks for that though.

I'm glad to hear this, as it will make your coding journey easier. Since you know how to use the help file and look at examples, searching the forum should be a piece of cake for you. A quick Google search of site:autoitscript.com checkbox active returned over 1300 topics that you should be able to use to easily glean the information you're after. Google is your friend ;)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

To narrow down what you want, you'll use GUICtrlRead to see if the checkbox is checked. You might want to store the id of the checkbox in a 2d array with the corresponding path of the program associated with it. That way, when you press the button to start the programs you just loop through the array instead of checking each individual checkbox.

Edited by InunoTaishou
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...