Jump to content

Install different programs, silent..


mobz
 Share

Recommended Posts

Hello, i`m pretty new to AutoIt and i just need a push forward, on how to do things. Se my little example:

$flash = GUICtrlCreateCheckbox("Flash", 22, 160, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$firefox = GUICtrlCreateCheckbox("Firefox", 22, 60, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$foxitreader = GUICtrlCreateCheckbox("Foxit Reader", 22, 80, 137, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$silverlight = GUICtrlCreateCheckbox("Silverlight", 22, 100, 121, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$vlc = GUICtrlCreateCheckbox("VLC", 22, 120, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)

$run = GUICtrlCreateLabel("Kör", 64, 368, 64, 52)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetCursor (-1, 0)

What i wanna know is how do i make it run theese example programs silently by pressing the "kör" button.

I only want to run the programs that are checked, i`m pretty good in bat scripting, but this is totally new :mellow:

What i need is an example code of how do i get the button "kör" just too run whats marked. And where should i put

the filepath to the install files: java/java.exe /silent (just an example).

And is there a way to get a process bar of how much is done etc.

And finally, #requireadmin do i only need to have that in my script that call the install files or do i need to change the UAC in registry

because i don`t wanna press YES on every programs thats install.

It works great now in bat script, but i wanna step it up a little bit, with more application etc.

/Mobz!

Link to comment
Share on other sites

You need to make a loop in the While/Wend Section to tie to the button so it checks whats ticked after you press it

have a look in the helpfile for While and Wend

An eg from one of my scripts doing a similar thing

$CBoxStatMWB = GUICtrlRead($CBoxMWB)
                If $CBoxStatMWB = $GUI_CHECKED Then
                    ShellExecuteWait(@ScriptDir & "\file_includes\down_malware.exe", IniRead(@ScriptDir & "\file_includes\updates.ini", "MWB", "Switch_0", "Not Found"))
                    If @error Then
                        MsgBox(48, "Error", "Malwarbytes Install Failed", 2)
                    EndIf
                EndIf
                Sleep(500)

Obviously mine has extra things involved but im sure you will get the idea, then basically it loops thru the checkboxes and installs the ones that are ticked

Thats a very rough run thru

Edited by Chimaera
Link to comment
Share on other sites

Hmm i don`t get it to work.

Example:

$openoffice = GUICtrlCreateCheckbox("Openoffice", 22, 250, 121, 17)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$office10 = GUICtrlCreateCheckbox("Office 2010", 22, 280, 121, 17)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$officekey = GUICtrlCreateInput("Office 2010 nyckel", 22, 300, 169, 21)
$msse = GUICtrlCreateCheckbox("MS Sec Essential", 22, 360, 193, 17)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$fseckey = GUICtrlCreateInput("F-Secure nyckel", 22, 340, 169, 21)
$run = GUICtrlCreateLabel("Kör", 72, 384, 64, 52)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
GUICtrlSetCursor (-1, 0)
$fsec = GUICtrlCreateCheckbox("F-Secure 2011", 22, 320, 145, 17)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            
        Case $run
            GUICtrlRead($openoffice)
                If $openoffice = $GUI_CHECKED then Run(@WindowsDir & "\Notepad.exe", "", @SW_MAXIMIZE)
            GUICtrlRead($msse)
                If $msse = $GUI_CHECKED then Run(@WindowsDir & "\Notepad.exe", "", @SW_MAXIMIZE)        
                    Exit
            
            
            

    EndSwitch
WEnd

I just want the button $run checking all the buttons if its checked, and if they are run the command. If they aren`t just go to the next...

Link to comment
Share on other sites

mine looks a bit like this

$SubmitButton = GUICtrlCreateButton("Install", 275, 55, 75, 35)

While 1
    $GuiMsg = GUIGetMsg()
    Select

        Case $GuiMsg = $Gui_Event_Close
            Exit

        Case $GuiMsg = $SubmitButton
                 $CBoxStatMWB = GUICtrlRead($CBoxMWB);<<<the first checkbox to check
                If $CBoxStatMWB = $GUI_CHECKED Then;<<<if its checked do this
                    ShellExecuteWait(@ScriptDir & "\file_includes\down_malware.exe", IniRead(@ScriptDir & "\file_includes\updates.ini", "MWB", "Switch_0", "Not Found"))
                    If @error Then
                        MsgBox(48, "Error", "Malwarbytes Install Failed", 2)
                    EndIf
                EndIf
                Sleep(500)
        Case $GuiMsg = $UpdateButton
                                    ;<<<<<<<<<<<<<<<<<<my update instructions go in here
    EndSelect
WEnd

Just looking at your you will need to make $run a button so the press can be recognised, a label wont do it

Edited by Chimaera
Link to comment
Share on other sites

Just looking at your you will need to make $run a button so the press can be recognised, a label wont do it

A label can be used as a button substitute. It makes it very handy to use one to fire off an event sometimes. I used them for a Help> About window in a project once.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Thx BrewManNH, thats a new one to me

Does it trigger when the gui gets drawn then, its not exactly clickable is it?

OP mentions button

by pressing the "kör" button.

so thats why i did Edited by Chimaera
Link to comment
Share on other sites

Here's a simple demo of how to use a label as a button, you can also substitute a pic control in its place to make a button that actually looks good. :mellow:

Global $GUI = GUICreate("Test GUI with clickable label", 100, 100)
$Label = GUICtrlCreateLabel(" Click Me ", 10, 10)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit
        Case $Label
            MsgBox(64, "Clicked", "You clicked the label")
    EndSwitch
WEnd

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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...