Sign in to follow this  
Followers 0
Apixen

Exit Notepad via Button

16 posts in this topic

#1 ·  Posted (edited)

5char

Edited by Apixen

Share this post


Link to post
Share on other sites



check out "Welcome to Autoit 1-2-3" in my signature below

... there are numerous examples of just what you are looking for

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

5char

Edited by Apixen

Share this post


Link to post
Share on other sites

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Close Notepad", 168, 48, 243, 124)
$Button1 = GUICtrlCreateButton("Close Notepad", 40, 8, 83, 25, $WS_GROUP)
GUICtrlSetOnEvent($Button1, "NotepadClose")
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
GUISetState(@SW_SHOW)


Func NotepadClose()
    If ProcessExists("Notepad.exe") Then
        ProcessClose("Notepad.exe")
    Else
        MsgBox(0, "Close Notepad", "Notepad is not open!") ; You can take out MsgBox if undeeded.
    EndIf
EndFunc


Func Close()
    Exit
EndFunc


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Hope this might help. :)

Share this post


Link to post
Share on other sites

Design is very specific. We are not mind readers. are you using on event mode? are you using a child GUI??... for the button ? or the notepad UI?

any code to start from?

maybe...

http://www.autoitscript.com/forum/index.php?showtopic=111872&view=findpost&p=784283

?

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Close Notepad", 168, 48, 243, 124)
$Button1 = GUICtrlCreateButton("Close Notepad", 40, 8, 83, 25, $WS_GROUP)
GUICtrlSetOnEvent($Button1, "NotepadClose")
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
GUISetState(@SW_SHOW)


Func NotepadClose()
    If ProcessExists("Notepad.exe") Then
        ProcessClose("Notepad.exe")
    Else
        MsgBox(0, "Close Notepad", "Notepad is not open!") ; You can take out MsgBox if undeeded.
    EndIf
EndFunc


Func Close()
    Exit
EndFunc


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Hope this might help. :)

You can not use GUIGetMsg() with On-Event() mode

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

You can not use GUIGetMsg() with On-Event() mode

8)

It still does what you'd like it to do, correct?

If there's a problem then it can be taken out and replaced with:

While 1
    Sleep(1000)
WEnd

So it doesn't close till you want it to.

Edited by Penisaurus

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

5char

Edited by Apixen

Share this post


Link to post
Share on other sites

FileOpenDialog()

see help

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

5char

Edited by Apixen

Share this post


Link to post
Share on other sites

Apixen,

Did you look at FileOpenDialog in the Help file as Valuater suggested? As stated in the help file it:

"Returns the full path of the file(s) chosen"

Your question earlier referred to:

Client.exe

Folder Path:

Input here

With FileOpenDialog you get the folder for free! :( If you wanted to select a different folder for some reason then FileSelectFolder will allow to do so.

Get it?

M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

5char

Edited by Apixen

Share this post


Link to post
Share on other sites

K, How does the "button" React? Example please. (Functions)

No, Im not an expert to this stuff, I'm just learning.

No, I don't think you are.

Do you make your own bed?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

5char

Edited by Apixen

Share this post


Link to post
Share on other sites

Demand it? What position are you in that you can make demands. I am frankly shocked anyone has chosen to help you never mind three MVPs.

Ask politely, show some effort and you will not have retorts such as mine and Martin's.

Share this post


Link to post
Share on other sites

Apixen,

Answer the problems given, That's the purpose of this topic, and section

That is most definitely NOT the way to get help here. :(

Let me explain. This forum is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. We also expect that when you post here you have had a go at solving your problems beforehand. Having some code to work on is a great help - it saves us having to write something from scratch - and no-one here is too keen to help the "code it for me" brigade.

So arriving here with a very peremptory manner demanding examples (as you have also done in previous topics) is not going to make you many friends. There is a wonderful Help file crammed full fo examples for you to try. There are excellent tutorials here and here and you will find other tutorials in the Wiki (the link is at the top of the page). There are even video tutorials on YouTube if you prefer watching to reading.

Now go and write some code yourself using the command suggestions that you have been given above and see if you can get some way towards doing what you want. You know where we are when you run into difficulties - but I would strongly recommend a more consilatory posting style if you want any real help. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

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