Jump to content

Simple GUI - Help?


Zari
 Share

Recommended Posts

I'm trying to create a simple GUI with one button that performs this action. When you click the button, it checks if IE is running. If IE is running it prompts them to close it, if it is not running, the GUI closes.

$ProcessName = "iexplore.exe"

If ProcessExists($ProcessName) Then

MsgBox(0,"Running","Internet Explorer is open, please close.")

Else

Exit

EndIf

Link to comment
Share on other sites

  • Moderators

Zari,

First, welcome to the AutoIt forums. :)

Congratulations, you have written exactly what you wanted!

If you want to compile this script into an .exe file, you will need to do one of 2 things:

1. If you are using SciTE to write your code, use the <Tools - Compile> menu to open a dialog which will enable you compile.

2. Otherwise, use Aut2Exe (which you will find in "C:\Program Files\AutoIt3\Aut2Exe" if you have a standard install) which opens another dialog to compile.

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

I have compiled it, but I still need help. I can't figure out the part I posted about, one button that closes on click if IE is closed and message box if IE is open

******************************************************************************************

Zari,

First, welcome to the AutoIt forums. :)

Congratulations, you have written exactly what you wanted!

If you want to compile this script into an .exe file, you will need to do one of 2 things:

1. If you are using SciTE to write your code, use the <Tools - Compile> menu to open a dialog which will enable you compile.

2. Otherwise, use Aut2Exe (which you will find in "C:\Program Files\AutoIt3\Aut2Exe" if you have a standard install) which opens another dialog to compile.

M23

Link to comment
Share on other sites

  • Moderators

Zari,

The code you posted works like this:

; What are we looking for?
$ProcessName = "iexplore.exe"

; See if it is running
If ProcessExists($ProcessName) Then
    ; It is running so show a MsgBox which will wait until the user presses the OK button and then continue the script after the EndIf (i.e.Exit!)
    MsgBox(0,"Running","Internet Explorer is open, please close.")
Else
    ; IE is not running, exit immediately
    Exit
EndIf

; If we arrive here from the MsgBox, the script exits because there is no more code!

If you are having trouble understanding how the code works, could I suggest reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) which will help you enormously. You should also look at the excellent tutorials that you will find here and here. There are even video tutorials on YouTube if you do not like reading. :)

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

try this code

#Include <GUIConstants.au3>
#Include <WindowsConstants.au3>

$GUI = GUICreate("", 200, 50, -1, -1)
$Button = GUICtrlCreateButton("click me", 10, 10, 50, 20)
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
    Select
        Case $msg = $Button
            Click_Func()
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Func Click_Func()
    $ProcessName = "iexplore.exe"

    If ProcessExists($ProcessName) Then
        MsgBox(0,"Running","Internet Explorer is open, please close.")
    Else
        Exit
    EndIf 
EndFunc
Edited by Tomb
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...