Jump to content

[Resolved] My inputbox doesn't perform function.


Diana (Cda)
 Share

Recommended Posts

Here is the inputbox GUI part of my script:

;--------------------------------------------------------------------------------------------------
; 2.  Box that closes chosen app.
;=========================================================================
Global Const $GUI_EVENT_CLOSE = -3     ; by using this constant, could leave out reference to "#include <GUIConstants.au3>", which in turn referenced this variable, with this exact value, from "GUIConstantsEx.au3"
Global Const $WS_EX_TOPMOST    = 0x00000008     ;   put this in so that no need to have UDF present when compiling
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Close application.", 415, 95, 745, 150, -1, $WS_EX_TOPMOST)     ; width, height, left, top, "-1, $WS_EX_TOPMOST" makes GUI topmost
GUISetIcon("Shell32.dll", 28)     ; this changes icon in upper left-hand corner to your chosen one
;----------------------------------------------------------
$Input1 = GUICtrlCreateInput("", 16, 32, 385, 21)     ; left, top, width, height
GUICtrlSetOnEvent(-1, "Input1")
;----------------------------------------------------------
$Label1 = GUICtrlCreateLabel("Type in the name of the application running, in terms of its process name.", 16, 8, 347, 17)     ; left, top, width, height
GUICtrlSetTip(-1, "i.e., type in something like ''coolplayer.exe'' ...")     ; button tooltip
;----------------------------------------------------------
$Button1 = GUICtrlCreateButton("OK", 109, 60, 75, 25, 0)     ; left, top, width, height            [OK button]
GUICtrlSetOnEvent(-1, "OK_click")
GUICtrlSetTip(-1, "Okay, go ahead with the action.")     ; button tooltip
; ---------------------------------------------------------
$Button2 = GUICtrlCreateButton("Cancel", 231, 60, 75, 25, 0)     ; left, top, width, height        [CANCEL button]
GUICtrlSetOnEvent(-1, "Cancel_click")
GUICtrlSetTip(-1, "Cancel closes this box.")     ; button tooltip
; ---------------------------------------------------------
; CLOSE BUTTON on upper right-hand corner:
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")     ; "X" closes app, line "Global Const $GUI_EVENT_CLOSE = -3" above.  / You need to have a "Func Close()" below
GUICtrlSetTip(-1, "Close this GUI.")     ; button tooltip
; ----------------------
GUISetState(@SW_SHOW)
;=========================================================================

While 1
    Sleep(100)
WEnd

Func Input1()
    Beep(1000, 75)
    Sleep(250)
    IF ProcessExists($Input1) Then ProcessClose($Input1)
    Exit     ; finished
EndFunc
Func OK_click()
    Exit     ; finished
EndFunc
Func Cancel_click()
    Exit     ; finished
EndFunc



Func Close()
    Exit     ; finished
EndFunc  ;==>close
;--------------------------------------------------------------------------------------------------

I've obviously done something wrong but after over an hour or coming back to this and studying help file and forums messages, I can't figure out what.

(I'm guessing it's something stupidly simple, too! <sigh>

Help ... ;)

Edited by Diana (Cda)
Link to comment
Share on other sites

  • Developers

To get the value of a control you need to do a GuiCtrlRead() as mentioned, but shouldn't the test for the process be done in the OK_click() Function?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

To get the value of a control you need to do a GuiCtrlRead() as mentioned, but shouldn't the test for the process be done in the OK_click() Function?

Jos

Yeah. But when nothing worked, I thought I had done something wrong elsewhere so tried putting that other item in <g>. Turns out I was just missing that GUICtrlRead thingie <g>.

Anyway, I was able to get this to work!

;--------------------------------------------------------------------------------------------------
; 2.  Box that closes chosen app.
;=========================================================================
Global Const $GUI_EVENT_CLOSE = -3     ; by using this constant, could leave out reference to "#include <GUIConstants.au3>", which in turn referenced this variable, with this exact value, from "GUIConstantsEx.au3"
Global Const $WS_EX_TOPMOST    = 0x00000008     ;   put this in so that no need to have UDF present when compiling
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Close application.", 415, 95, 745, 150, -1, $WS_EX_TOPMOST)     ; width, height, left, top, "-1, $WS_EX_TOPMOST" makes GUI topmost
GUISetIcon("Shell32.dll", 28)     ; this changes icon in upper left-hand corner to your chosen one
;----------------------------------------------------------
$Input1 = GUICtrlCreateInput("", 16, 32, 385, 21)     ; left, top, width, height
;----------------------------------------------------------
$Label1 = GUICtrlCreateLabel("Type in the name of the application running, in terms of its process name.", 16, 8, 347, 17)     ; left, top, width, height
GUICtrlSetTip(-1, "i.e., type in something like ''coolplayer.exe'' ...")     ; button tooltip
;----------------------------------------------------------
$Button1 = GUICtrlCreateButton("OK", 109, 60, 75, 25, 0)     ; left, top, width, height            [OK button]
GUICtrlSetOnEvent(-1, "OK_click")
GUICtrlSetTip(-1, "Okay, go ahead with the action.")     ; button tooltip
; ---------------------------------------------------------
$Button2 = GUICtrlCreateButton("Cancel", 231, 60, 75, 25, 0)     ; left, top, width, height        [CANCEL button]
GUICtrlSetOnEvent(-1, "Cancel_click")
GUICtrlSetTip(-1, "Cancel closes this box.")     ; button tooltip
; ---------------------------------------------------------
; CLOSE BUTTON on upper right-hand corner:
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")     ; "X" closes app, line "Global Const $GUI_EVENT_CLOSE = -3" above.  / You need to have a "Func Close()" below
GUICtrlSetTip(-1, "Close this GUI.")     ; button tooltip
; ----------------------
GUISetState(@SW_SHOW)
;=========================================================================

While 1
    Sleep(100)
WEnd

Func OK_click()
    Beep(1000, 75)
    Sleep(250)
    IF ProcessExists(GUICtrlRead($Input1)) Then ProcessClose(GUICtrlRead($Input1))
    Exit     ; finished
EndFunc
Func Cancel_click()
    Exit     ; finished
EndFunc



Func Close()
    Exit     ; finished
EndFunc  ;==>close
;--------------------------------------------------------------------------------------------------

It's sometimes something so incredible small that trips us up.

Thanks everyone! ;)

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