Jump to content

run with or without gui


wfbeck
 Share

Recommended Posts

I have been working on a launch app that lets users select different licenses they would want to run. I now have users that feel the gui is too much and want to click to the app icon and run the default license. I would like to control the gui with a flag. Give the user two app icons one with the flag and one without. The one with would use all the default values. The one without would pop the gui like I have now. Any help would be great.

Thanks,

Link to comment
Share on other sites

  • Moderators

wfbeck,

Welcome to the AutoIt forum. :graduated:

Immediate thought: use a command line parameter so that the script can decide whether to open the GUI or not. Look at <Using AutoIt - Command Line Parameters> to see how to use the internal $CmdLine array to detect an eventual parameter.

Then use 2 icons to run your app - one with the parameter and one without. FileCreateShortcut will let you make the additonal icons with the required argument. :D

I hope this helps. :(

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

 

Link to comment
Share on other sites

wfbeck,

Welcome to the AutoIt forum. :graduated:

Immediate thought: use a command line parameter so that the script can decide whether to open the GUI or not. Look at <Using AutoIt - Command Line Parameters> to see how to use the internal $CmdLine array to detect an eventual parameter.

Then use 2 icons to run your app - one with the parameter and one without. FileCreateShortcut will let you make the additonal icons with the required argument. :D

I hope this helps. :(

M23

Thanks for the reply. This looks like it would work, but I am very new to Autoit and working off of a file that was done prior. I will post my code. Again any help would be great. I would like the parameter to press the start button. But do not know where to place the $cmdline parameter info.ProStartUp2.au3
Link to comment
Share on other sites

  • Moderators

wfbeck,

A bit difficult to work directly on your file as I have none of the registry keys required! So I have made a short demo script which I hope will let you see how you need to modify your script: :graduated:

#include <GUIConstantsEx.au3>

; Do all the gathering data section here

; We start this new bit just before the ;GENERATE THE UI section

; Check we have a command line to read and that the parameter is the correct one 
; We need to check both because the script will crash if we try to read [1] and it does not exist

If $CmdLine[0] <> 0 And $CmdLine[1] = "-direct" Then ; You can obviously choose whatever parameter you wish here

    LaunchProE(1) ; Note the use of a flag to show we are launching directly

Else

    ; Launch the GUI as before if no parameter or it is not what we have set
    $hGUI = GUICreate("Test", 500, 500)

    $hButton = GUICtrlCreateButton("Go!", 10, 10, 80, 30)

    GUISetState()

    While 1

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $hButton
                ; And here we launch the app as before
                LaunchProE(0) ; And here the flag says we are going via the GUI
        EndSwitch

    WEnd

EndIf

Func LaunchProE($iFlag) ; You will need to add the flag variable here

    ; So let us look at the flag and see how we got here
    Switch $iFlag
        Case 1 ; We came directly

            MsgBox(0, "Starting", "Going directly to the default version")
            #cs
            ; Set all these to reflect the version you want to run automatically
            $SelVersionExecutable = $PRO_VERSIONS_FILES[$i + 1]
            RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "pro_ver", "reg_sz", $version[$i + 1])
            RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "pro_date", "reg_sz", $code[$i + 1])
            ;RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "proe_work_dir", "reg_sz", "d:\HOME\users\%username%")
            RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "ptc_wf_root", "reg_sz", "d:\HOME\users\%username%")
            EnvSet("pro_ver", $version[$i + 1])
            EnvSet("pro_date", $code[$i + 1])
            EnvUpdate()
            #ce
        Case Else ; We came via the GUI

            MsgBox(0, "Starting", "Reading the GUI radios to detect the version required")
            #cs
            ;Figure out which version is selected
            $SelVersionExecutable = "proe"
            For $i = 0 To $PRO_VERSIONS_IDs[0] - 1
                If BitAND(GUICtrlRead($VERSION_RADIOS[$i]), $GUI_CHECKED) = $GUI_CHECKED Then
                    $SelVersionExecutable = $PRO_VERSIONS_FILES[$i + 1]
                    RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "pro_ver", "reg_sz", $version[$i + 1])
                    RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "pro_date", "reg_sz", $code[$i + 1])
                    ;RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "proe_work_dir", "reg_sz", "d:\HOME\users\%username%")
                    RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "ptc_wf_root", "reg_sz", "d:\HOME\users\%username%")
                    EnvSet("pro_ver", $version[$i + 1])
                    EnvSet("pro_date", $code[$i + 1])
                    EnvUpdate()
                    ExitLoop
                EndIf
            Next
            #ce
    EndSwitch

    ; carry on with the function until you reach this line
    MsgBox(0, '', 'Please wait for Pro/E to run')

    ; No wwe check the flag again
    ; If it was a direct start then we exit the script here
    If $iFlag = 1 Then
        MsgBox(0, "Exiting", "Started in direct mode")
        Exit
    EndIf

    ;If it was not we return to the GUI

EndFunc

You can test this in SciTE by setting the required parameter (or not) in the dialog that you find under <View - Parameters>. Obviously you will need to remove the MsgBoxes and the #cs/#ce pairs - they are just there so you can see how the demo runs. :D

I think the comments are clear enough, but please ask if you have any questions. :(

M23

P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :D

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

 

Link to comment
Share on other sites

Thanks so much. I see what you are doing but have run into an issue that I am trying to fix. Without loading my gui I am running into variable errors that get filled in from my xml file. my xml file sets what the default selections should be. What would be the best way to deal with this. Pop the gui and with a command line param click start after 1 sec then close? I would like to keep from having to change this file everytime we change date codes of our software, so working off the xml file works best for me. I am open to ideas.

Thanks,

Link to comment
Share on other sites

  • Moderators

wfbeck,

Glad that the demo gave you a good idea of the way to go - do come back if you run into any integration problems. :graduated:

Without loading my gui I am running into variable errors that get filled in from my xml file

Sorry, never worked with the _XMLDomWrapper.au3 UDF, so I cannot offer any help there. I suggest a new topic is the way to go now - making sure you put the UDF name in the title to attract those who know about such things. :(

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

 

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