Sign in to follow this  
Followers 0
bobheart

checkbox check or not ?

15 posts in this topic

How do you set it so if the checkbox is check it will load that command to the

ComSpec

I want to have what checkbox is checked have that send the command to the

ComSpec line .

GuiCreate ("MyGUI", 526, 428, (@DesktopWidth - 526) / 2, (@DesktopHeight - 428) / 2, 0x04CF0000)

$CHECKBOX_1 = GUICtrlCreatecheckbox ("APPEND", 20, 10, 90, 40)
$CHECKBOX_2 = GUICtrlCreatecheckbox ("ARCHIVE=n", 20, 40, 90, 40)
$CHECKBOX_3 = GUICtrlCreatecheckbox ("AUTO", 20, 70, 90, 40)
$CHECKBOX_4 = GUICtrlCreatecheckbox ("BEEP", 20, 100, 90, 40)
$CHECKBOX_5 = GUICtrlCreatecheckbox ("COLLECT", 20, 130, 90, 40)
$CHECKBOX_6 = GUICtrlCreatecheckbox ("DELETE", 20, 160, 90, 40)
$CHECKBOX_7 = GUICtrlCreatecheckbox ("DISINF", 20, 195, 90, 40)
$CHECKBOX_8 = GUICtrlCreatecheckbox ("D/D", 20, 230, 90, 40)
$CHECKBOX_9 = GUICtrlCreatecheckbox ("D/R", 20, 260, 90, 40)
$CHECKBOX_10 = GUICtrlCreatecheckbox ("D/R/D", 20, 290, 100, 40)
$CHECKBOX_11 = GUICtrlCreatecheckbox ("DUMB", 20, 325, 100, 40)
$CHECKBOX_12 = GUICtrlCreatecheckbox ("EXT", 140, 10, 100, 40)
$CHECKBOX_13 = GUICtrlCreatecheckbox ("FREEZE", 140, 40, 100, 40)
$CHECKBOX_14 = GUICtrlCreatecheckbox ("HARD", 140, 70, 100, 40)
$CHECKBOX_15 = GUICtrlCreatecheckbox ("LIST", 140, 100, 100, 40)
$CHECKBOX_16 = GUICtrlCreatecheckbox ("LOADDEF", 140, 130, 100, 40)
$CHECKBOX_17 = GUICtrlCreatecheckbox ("NOBOOT", 140, 160, 100, 40)
$CHECKBOX_18 = GUICtrlCreatecheckbox ("NOBREAK", 140, 195, 100, 40)
$CHECKBOX_19 = GUICtrlCreatecheckbox ("NOFILE", 140, 230, 100, 40)
$CHECKBOX_20 = GUICtrlCreatecheckbox ("NOMEM", 140, 260, 100, 40)
$CHECKBOX_21 = GUICtrlCreatecheckbox ("NOSUB", 140, 290, 100, 40)
$CHECKBOX_22 = GUICtrlCreatecheckbox ("PACKED", 140, 325, 100, 40)
$CHECKBOX_23 = GUICtrlCreatecheckbox ("PAGE", 240, 10, 100, 40)
$CHECKBOX_24 = GUICtrlCreatecheckbox ("REMOVEALL", 240, 40, 100, 40)
$CHECKBOX_25 = GUICtrlCreatecheckbox ("REMOVENEW", 240, 70, 100, 40)
$CHECKBOX_26 = GUICtrlCreatecheckbox ("RENAME", 240, 100, 100, 40)
$CHECKBOX_27 = GUICtrlCreatecheckbox ("REPORT=file", 240, 130, 100, 40)
$CHECKBOX_28 = GUICtrlCreatecheckbox ("SAFEREMOVE", 240, 160, 100, 40)
$CHECKBOX_29 = GUICtrlCreatecheckbox ("SERVER", 240, 195, 100, 40)
$CHECKBOX_30 = GUICtrlCreatecheckbox ("SILENT", 240, 230, 100, 40)
$CHECKBOX_31 = GUICtrlCreatecheckbox ("TYPE", 240, 260, 100, 40)
$CHECKBOX_32 = GUICtrlCreatecheckbox ("VIRLIST", 240, 290, 100, 40)
$CHECKBOX_33 = GUICtrlCreatecheckbox ("VIRNO", 240, 325, 100, 40)
$BUTTON_1 = GUICtrlCreatebutton ("Start Scan", 400, 300, 100, 40)
$PIC_1 = GUICtrlCreatePic ("bug.gif", 370, 30, 140, 200)

GuiSetState (@SW_SHOW)

While 1
  Sleep(10)
  $MSG = GuiGetMsg ()
  Select
     Case $MSG = -3
        Exit
     Case $MSG = 1
      ;;;
     Case $MSG = $CHECKBOX_1
      ;;;
     Case $MSG = $CHECKBOX_2
      ;;;
     Case $MSG = $CHECKBOX_3
      ;;;
     Case $MSG = $CHECKBOX_4
      ;;;
     Case $MSG = $CHECKBOX_5
      ;;;
     Case $MSG = $CHECKBOX_6
      ;;;
     Case $MSG = $CHECKBOX_7
      ;;;
     Case $MSG = $CHECKBOX_8
      ;;;
     Case $MSG = $CHECKBOX_9
      ;;;
     Case $MSG = $CHECKBOX_10
      ;;;
     Case $MSG = $CHECKBOX_11
      ;;;
    Case $MSG = $CHECKBOX_12
      ;;;
       Case $MSG = $CHECKBOX_13
      ;;;
     Case $MSG = $CHECKBOX_14
      ;;;
     Case $MSG = $CHECKBOX_15
      ;;;
     Case $MSG = $CHECKBOX_16
      ;;;
     Case $MSG = $CHECKBOX_17
      ;;;
     Case $MSG = $CHECKBOX_18
      ;;;
     Case $MSG = $CHECKBOX_19
      ;;;
     Case $MSG = $CHECKBOX_20
      ;;;
     Case $MSG = $CHECKBOX_21
      ;;;
     Case $MSG = $CHECKBOX_22
      ;;;
     Case $MSG = $CHECKBOX_23
      ;;;
    Case $MSG = $CHECKBOX_24
      ;;;
       Case $MSG = $CHECKBOX_25
      ;;;
     Case $MSG = $CHECKBOX_26
      ;;;
     Case $MSG = $CHECKBOX_27
      ;;;
     Case $MSG = $CHECKBOX_28
      ;;;
     Case $MSG = $CHECKBOX_29
      ;;;
     Case $MSG = $CHECKBOX_30
      ;;;
     Case $MSG = $CHECKBOX_31
      ;;;
     Case $MSG = $CHECKBOX_32
      ;;;
     Case $MSG = $CHECKBOX_33
      ;;;
    Case $MSG = $BUTTON_1
       Run(@ComSpec & " /k F-PROT.EXE")
      ;;;
     Case $MSG = $PIC_1
      ;;;
  EndSelect
Wend
Exit

the commands .

The command-line options

F-PROT.EXE is usually run without any parameters and will then enter
interactive mode, but if the /HARD option is used, or a drive, file or
directory is specified, it will enter command-line mode.

Syntax for command-line mode:  F-PROT [drive, file or directory] [options]

The available command-line options are

/APPEND
Appends the report to an existing file (Only used with /REPORT).

/ARCHIVE=n
Scans inside .ARJ, .CAB, .LZH and .ZIP archives.  F-PROT currently
supports only RAR archives created by RAR 2.5 and older - support for
RAR 3.0 will be added soon.  The parameter n specifies how many levels
(archives inside archives) to scan.

/AUTO
May be specified with /DISINF, /DELETE or /RENAME so F-PROT will not
request permission before rremoving each virus.

/BEEP
Produces an annoying beep when a virus is found.  NOT recommended when
scanning a virus collection.

/COLLECT
Assumes what is being scanned is a virus collection, where viruses might be
found in "abnormal" locations.  In particular, selecting this option will
enable detection of file images of boot sector viruses.  This switch also 
provides the same features as the old /GURU option.  Note that using /COLLECT
will slow down the scan.

/DELETE
Deletes infected files.

/DISINF
Disinfects whenever possible.  It is possible to specify the following
combinations of switches:

    /DISINF /DELETE
        Disinfects when possible, otherwise deletes infected files.

    /DISINF /RENAME
        Disinfects when possible, otherwise attempts to rename infected COM/EXE 
        files to VOM/VXE.

    /DISINF /RENAME /DELETE
        Disinfects when possible, otherwise attempts to rename infected COM/EXE
        files to VOM/VXE, but if that fails the files are deleted.

/DUMB
Does a "dumb" scan of all files.  This option is often not necessary, 
and /TYPE can be used instead.  The only cases where it might be needed are 
the following:

    If you are scanning a virus collection, where infected files have
    non-standard extensions, such as .VOM instead of .COM, they will not
    be scanned for viruses, unless this switch is specified.

    If you are cleaning up a virus infection you should use this
    switch.

/EXT
By default F-PROT will open every file and try to determine its type,
so it will for example scan Word files, even if they do not use a DOC/DOT
extension.  By using /EXT the scanning can be speeded up slightly as F-PROT
will then only scan files with "default" extensions.

/FREEZE
"Freezes" the program if a virus is found anywhere.

/HARD
Scans all files on all hard disks in the computer.

/HELP
Displays the list of command-line options.

/INTER
Forces the program to enter interactive mode, even when a path, directory
or file name is given on the command line.

/LIST
Lists all files that are scanned.

/LOADDEF
Load the DEF files into memory.

/NOBOOT
Does not scan boot sectors.

/NOBREAK
Disables ESC and ^C during scanning.

/NOFILE
Does not scan files.  Only useful if you cleaning up a boot sector infection
and do not want to spend unnecessary time scanning files.

/NOFLOPPY
For use on systems without floppy drives.

/NOHEUR
Version 3 has a smaller, more reliable set of heuristics than version 2,
but they are enabled by default, unlike version 2.  This option allows
you to turn the heuristics off.

/NOMEM
Does not scan memory for viruses.  Not recommended, unless you are
absolutely certain that no viruses are present in memory.

/NOSUB
Does not scan subdirectories.

/PACKED
Scans "inside" various types of compressed executables (PKLITE for
example), by emulating the execution of the decompressor.  As this option
can slow the scan down significantly, we only recommend using it when
scanning new software before installation.

/PAGE
Pauses after each page (command-line mode only).

/REMOVEALL
Removes all macros from all documents.  Useful if you encounter a new
macro virus, and you know that the document did not contain any macros
before it got infected.

/REMOVENEW
If a new variant of a macro virus is found in a document, all macros are
removed from that particular document.

/RENAME
Renames infected COM/EXE files to VOM/VXE.  If files with those
extensions already exist, .VVV  is used instead.  Infected document files
are not renamed, as that would be pointless - they would be equally
infectious afterwards.

/REPORT=file
Sends the output to a file, in addition to displaying it on the screen.

/SAFEREMOVE
Removes all macros from documents, if a known virus is found.

/SERVER
Enable mail-server heuristics.  Will for example complain about encrypted
executables inside archives.

/SILENT
Does not generate any screen output (command-line mode only).

/TYPE
Scan every file, but skip those which do not seem to contain executable 
code.  This is faster than /DUMB but less thorough.

/VIRLIST
Produces a list of known viruses, as well as information on whether they
can be disinfected.

/VIRNO
Counts the known viruses and reports the total.

/WRAP
Wraps text so the report fits in 78 columns.


The program uses the following exit codes, which can be checked with the
ERRORLEVEL command from a BAT file.

    0 - Normal exit - nothing found
    1 - Abnormal termination - unrecoverable error.  This can mean any of
        the following:
            Internal error in the program.
            DOS version prior to 3.0 was used.
            ENGLISH.TX0, SIGN.DEF or MACRO.DEF corrupted or not present.
    2 - Selftest failed - program has been modified.
    3 - A Boot/File virus infection found.
    4 - Virus found in memory.
    5 - Program terminated with ^C or ESC.
    6 - A virus was removed.  This code is only meaningful if
        the program is used to scan just a single file.
    7 - Insufficient memory to run the program.
    8 - At least one suspicious file was found, but no infections.

Share this post


Link to post
Share on other sites



Not sure if that's what you want.

GuiCreate ("MyGUI", 526, 428, (@DesktopWidth - 526) / 2, (@DesktopHeight - 428) / 2, 0x04CF0000)

$CHECKBOX_1 = GUICtrlCreatecheckbox ("APPEND", 20, 10, 90, 40)
$CHECKBOX_2 = GUICtrlCreatecheckbox ("ARCHIVE=n", 20, 40, 90, 40)
$BUTTON_1 = GUICtrlCreatebutton ("Start Scan", 400, 300, 100, 40)
GuiSetState (@SW_SHOW)

While 1
 Sleep(10)
 $MSG = GuiGetMsg ()
 Select
    Case $MSG = -3
       Exit
    Case $MSG = 1
    ;;;
    Case $MSG = $CHECKBOX_1
    $arguments = "/APPEND "
    ;;;
    Case $MSG = $CHECKBOX_2
    $arguments = $arguments & "/ARCHIVE=n "
    ;;;
    Case $MSG = $BUTTON_1
     msgbox(0,"", $arguments)
    ;Run(@ComSpec & " /k F-PROT.EXE " & $arguments)
    ;;;
   ;Case $MSG = $PIC_1
    ;;;
 EndSelect
Wend
Exit

CheersNobby

Share this post


Link to post
Share on other sites

That will help me a lot . thanks a bunch .

Share this post


Link to post
Share on other sites

Do I keep adding $arguments to each time I add a

Case $MSG = $CHECKBOX_2

$arguments = $arguments &

Share this post


Link to post
Share on other sites

Yes,

Case $MSG = $CHECKBOX_1
   $arguments = "/APPEND "
  ;;;
   Case $MSG = $CHECKBOX_2
   $arguments = $arguments & "/ARCHIVE=n "
  ;;;
Case $MSG = $CHECKBOX_3
   $arguments = $arguments & "/AUTO "
  ;;;
   Case $MSG = $CHECKBOX_4
   $arguments = $arguments & "/BEEP "
  ;;;

etc...

So if check box 1,2 and 4 are checked the $arguments value will be

/APPEND /ARCHIVE=n /BEEP


CheersNobby

Share this post


Link to post
Share on other sites

And then if they are unchecked, then rechecked, you suddenly have two copies in $arguments, not to mention unchecking won't remove any argument.

Share this post


Link to post
Share on other sites

And then if they are unchecked, then rechecked, you suddenly have two copies in $arguments, not to mention unchecking won't remove any argument.

<{POST_SNAPBACK}>

So what to do ?

Share this post


Link to post
Share on other sites

If you feel like writing a lot of lines, you could:

GuiCreate ("MyGUI", 526, 428, (@DesktopWidth - 526) / 2, (@DesktopHeight - 428) / 2, 0x04CF0000)

$CHECKBOX_1 = GUICtrlCreatecheckbox ("APPEND", 20, 10, 90, 40)
$CHECKBOX_2 = GUICtrlCreatecheckbox ("ARCHIVE=n", 20, 40, 90, 40)
$BUTTON_1 = GUICtrlCreatebutton ("Start Scan", 400, 300, 100, 40)
GuiSetState (@SW_SHOW)
$msg = 0
While $msg <> -3
   $msg = GuiGetMsg()
Select

case $msg = $button_1
    $state1 = GuiRead($CHECKBOX_1)
    $state2 = GuiRead($CHECKBOX_2)

     
   if $state1 = 1 Then 
      $arg1 = "/APPEND "
   Else
      $arg1 = ""
   EndIf
   
   If $state2 = 1 Then
      $arg2 = "/ARCHIVE=n "
   Else
      $arg2 = ""
   EndIf
   
   $arguments = $arg1 & $arg2
   
   MsgBox(0, "The arguments are", $arguments)
   
    ;Run(@ComSpec & " /k F-PROT.EXE " & $arguments)
    ;;;
   ;Case $MSG = $PIC_1
    ;;;
 EndSelect
Wend
Exit

CheersNobby

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

;Based on nobby's example

Just to save all the Else-lines and not to type to much at '$arguments = $arg1 & $arg2 ...' you could use an array

Dim $i[15]
Dim $cmdline

$state1 = 1
$state2 = 1

For $j = 0 To (UBound($i)-1)
    $i[$j] = ""
Next


if $state1 = 1 Then
     $i[0] = "/APPEND "
EndIf
 
If $state2 = 1 Then
     $i[1] = "/ARCHIVE=n "
EndIf

; ...


For $j = 0 To (UBound($i)-1)
    $cmdline = $cmdline & $i[$j]
Next

MsgBox(0,"",$cmdline)

or use sth. like

;inspired by CyberSlug's Checkboxes-Treeview

Dim $i[5]
Dim $box[UBound($i)]

Dim $cmdline

$i[0] = "/APPEND"
$i[1] = "/ARCHIVE=n"
$i[2] = "/AUTO"
$i[3] = "/BEEP"
$i[4] = "/COLLECT"


GuiCreate ("MyGUI", 526, 428, (@DesktopWidth - 526) / 2, (@DesktopHeight - 428) / 2, 0x04CF0000)


$tv = GuiCtrlCreateTreeView(10, 10, 200, 150, 0x100);$TVS_CHECKBOXES

For $j = 0 To (UBound($i)-1)
    $box[$j] = GUICtrlCreateTreeViewItem($i[$j],$tv)
Next

$BUTTON_1 = GUICtrlCreatebutton ("Start Scan", 400, 300, 100, 40)


GuiSetState (@SW_SHOW)
$msg = 0

While $msg <> -3
  $msg = GuiGetMsg()

Select

case $msg = $button_1
    
    $cmdline = ""

    For $k = 0 To (UBound($i)-1)
        If (GuiRead($box[$k])=1) Then 
            $cmdline= $cmdline & $i[$k]
            If ($k <> (UBound($i)-1)) Then $cmdline = $cmdline & " "
        EndIf
    Next

    MsgBox(0,"",$cmdline)

EndSelect

WEnd

You can create another array to difference between checkbox-description and cmdline-parameter

edit : code corrected - forgot to reset $cmdline (see post #10 by SlimShady)

Thank you SlimShady

Edited by sPeziFisH

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

This is in reply to sPeziFisH.

As Valik said:

And then if they are unchecked, then rechecked, you suddenly have two copies in $arguments

So to avoid that, add the following to line 34 (line below case $msg = $button_1)

$cmdline = ""
Edited by SlimShady

Share this post


Link to post
Share on other sites

I havent used the gui for autoit3 but I figured you would only have to check for the state of the check boxes once and that is when you hit the RUN command on your window ( I need to read the help file on this).

oops sPeziFisH gave you the code and answer (it helps if you read the posts)

if you find yourself doing a lot of gui stuff try (for free)

http://guilect.homestead.com/

you could create fancy windows in minutes and autoit works like a charm managing the programs created by guilect.

in fact I now use GAWK for speed PERL for complex tasks GUILECT for my GUIs AND AUTOIT3 TO RULE THEM ALL

Share this post


Link to post
Share on other sites

Did I do this right as it is saying it can't find the exe to run ? have it in the same folder ?

Dim $i[5]
Dim $box[UBound($i)]

Dim $cmdline

$i[0] = "/APPEND"
$i[1] = "/ARCHIVE=n"
$i[2] = "/AUTO"
$i[3] = "/BEEP"
$i[4] = "/COLLECT"


GuiCreate ("MyGUI", 526, 428, (@DesktopWidth - 526) / 2, (@DesktopHeight - 428) / 2, 0x04CF0000)


$tv = GuiCtrlCreateTreeView(10, 10, 200, 150, 0x100);$TVS_CHECKBOXES

For $j = 0 To (UBound($i)-1)
   $box[$j] = GUICtrlCreateTreeViewItem($i[$j],$tv)
Next

$BUTTON_1 = GUICtrlCreatebutton ("Start Scan", 400, 300, 100, 40)


GuiSetState (@SW_SHOW)
$msg = 0

While $msg <> -3
 $msg = GuiGetMsg()

Select

case $msg = $button_1
   
   $cmdline = ""

   For $k = 0 To (UBound($i)-1)
       If (GuiRead($box[$k])=1) Then
           $cmdline= $cmdline & $i[$k]
           If ($k <> (UBound($i)-1)) Then $cmdline = $cmdline & " "
       EndIf
   Next

   run(0,"F-PROT.EXE",$cmdline)

EndSelect

WEnd

Share this post


Link to post
Share on other sites

Unable to execute the external program.:

run("F-PROT.EXE",$cmdline)

The directory name is invalid.

Share this post


Link to post
Share on other sites

Translation of Larry's reply: "What the f*ck????"

To run the FPROT with the arguments, use this:

Run("F-PROT.EXE " & $cmdline)

If it doesn't work, change FPROT.EXE to the full path of the executable.

Share this post


Link to post
Share on other sites

Thank you .

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