Jump to content

GuiCtrlRead refresh help...


aarrowh
 Share

Recommended Posts

I'm working on a simple program that will take what you put in an input box and turn off whatever process you type in. I store the input in a Variable equal to GuiCtrlRead ( *variable name here* ) but even when I declare it when the button to turn it off is pressed(b4 saying to close the program of course) it still will not close. I've been trying to get this for a couple of hours now, so any help apprieciated.

Heres some code.

Case $msg = $opt
        
        Select
        Case WinExists ( "PC Optimizer(Alpha)" )
            WinActivate ( "PC Optimizer(Alpha)" )
        Case Not WinExists ( "PC Optimizer(Alpha)" )
            GUICreate ( "PC Optimizer(Alpha)",200,200)
                GUISetState (@sw_show)
            EndSelect
        $text = GUICtrlCreateInput ( "steam.exe",10, 50 )
            $opt2 = GUICtrlCreateButton ( "Optimize", 42,80 )
         
            
    Select
    Case $msg = $opt2
        
$input = GUIctrlread ( $text )
                ProcessClose ( $input )
            EndSelect
            EndSelect
Link to comment
Share on other sites

Here you go this will open a GUI with an input box and a button you type the name of the process and click the button and it ends the process if the process doesnt exist it opens a message box saying so. if you cant figure out the script let me know and ill comment it for you

;;;;;;;;;;;;;;;;;;;
;  By: iHonda     ;
;;;;;;;;;;;;;;;;;;;

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("PC Optimizer Alpha", 455, 65, 723, 432)
$process = GUICtrlCreateInput("", 24, 24, 297, 21)
$kill_button = GUICtrlCreateButton("End", 328, 16, 113, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    EndSwitch
WEnd



Func _ProcessKill(Const $process)
    $fProcess = GUICtrlRead($process)
    If ProcessExists($fProcess) Then
        ProcessClose($fProcess)
        MsgBox(0,"PC Optimizer Alpha","Process " & $fProcess & "has been closed")
    Else
        MsgBox(0,"PC Optimizer Alpah","Process " & $fProcess & "does not exist")
    EndIf
EndFunc

sorry bout the double post wasnt paying attention

Edited by iHonda

A great place to start Autoit 1-2-3

Link to comment
Share on other sites

Sorry, your script works fine but im having trouble implementing. In your script there is only one GUI in mine there is 1 GUI that will constantly be there, and another that will come up with the process removal input on it. I can't get it to read button presses on the close process button because I can't declare it until the GUI is called....

Here's my projects full source.

#include  <WindowsConstants.au3>
#NoTrayIcon
#include <GUIConstantsEx.au3>
#Include <Misc.au3>

MsgBox (0, "Welcome to Gamers Desk!", "Welcome to Gamers Desk, devolped by M.E.D. To view the help file, press Ctrl-h.")

;set hot keys
HotKeySet ( "^p", "HideGUI" )
HotKeySet ( "^n", "rnotes" )
HotKeySet ( "^h", "helpGUI" )

 
 
;State system version Version
$version = "Gamers Desk V.  0.012 (Beta)"
$releaseversion = "Gamers Desk V.  0.012 (Beta) Release notes"
$version2= "New to V.  0.012"


$gd = GUICreate ( $version, 400, 400)
GUISetState (@SW_SHOW)




;game buttons Start

$steam = GUICtrlCreateButton ( "Steam", 0,24 )
$jact = GUICtrlCreateButton ( "Eamonn",0,48 )
$WoW = GUICtrlCreateButton ( "World of Warcraft", 0,72 )

;game buttons end

; other buttons start
 $opt = GUICtrlCreateButton ( "PC Optimize", 0, 168 )
 $Fire = GUICtrlCreateButton ( "Firefox" , 0 , 192 )
$email = GUICtrlCreateButton ( "Windows Mail" , 0, 216 )
$tskmgr = GUICtrlCreateButton ( "Task Manager", 0, 240 )

;other buttons end


;labels
$bar1 = GUICtrlCreateLabel ( "==========Game and related programs==========", 63, 0 )
$bar2 = GUICtrlCreateLabel ( "=============Utilities and items==========", 65, 144)
;end labels


while 1
;if ProcessExists ( "explorer.exe" ) Then
;ProcessClose ( "explorer.exe" )
;EndIf
    

    
    $msg=GUIGetMsg()
    
    Select
        
    Case $msg= $GUI_EVENT_CLOSE
        Select
        Case WinActive ( $gd )
            MsgBox (0, "Thank You", "Thank you for using Gamers Desk.")
;Run ( "explorer.exe" )
        Exit
    Case Not WinActive ( $gd )
        GUIDelete(WinGetHandle(WinGetTitle(""))) 
        
EndSelect
    
 
        
    Case $msg=$steam
        Select
        Case ProcessExists ( "steam.exe")
            MsgBox (0,"Reminder", "Steam is already running. But Gamers Desk will now open your Steam window.")
                Run ( "C:\Program Files\Steam\steam.exe" )
                    Case not ProcessExists ( "steam.exe" )
            Run ( "C:\Program Files\Steam\steam.exe" )
        EndSelect
    case $msg=$jact
    Select
    case ProcessExists ("Eamonn.exe")
        MsgBox (0, "Error", "Eamonn is already running.")
        
        case Not ProcessExists ( "Eamonn.exe")
        run ("C:\Program Files\Eamonn\bin\Eamonn.exe")
    EndSelect

Case $msg=$WoW
    Select
    Case ProcessExists ( "wow.exe")
        MsgBox (0,"Error", "World of Warcraft is already running")
    Case Not ProcessExists ( "wow.exe" )
        Run ( "C:\Users\Public\Games\World of Warcraft\wow.exe" )
    EndSelect

Case $msg=$Fire
    Select
    case ProcessExists ( "firefox.exe" )
        MsgBox ( 0,"Error", "Firefox is already open." )
    Case Not ProcessExists ( "firefox.exe" )
        Run ( "C:\Program Files\Mozilla Firefox\firefox.exe" )
    EndSelect
Case $msg=$email
    Select 
    Case ProcessExists ( "winmail.exe" )
        MsgBox ( 0, "Error", "Windows Mail is already open" )
    Case Not ProcessExists ( "winmail.exe" )
        Run ( "C:\Program Files\Windows Mail\winmail.exe" )
        EndSelect
    case $msg = $tskmgr
        Select
        case ProcessExists ( "taskmgr.exe" )
            MsgBox (0, "Error", "Task Manager is already running. But we will now bring up its window" )
            WinActivate ( "Windows Task Manager" )
        case not ProcessExists ( "taskmgr.exe" )
            run ( "taskmgr.exe")
        EndSelect
    Case $msg = $opt
                pcopt()
         
            Case $msg = $opt2
                _processkill($input)
    

            EndSelect
    WEnd
; Start functions
    Func HideGUI()
    Select
    case WinActive ( $version )
        GUISetState (@SW_Hide, $gd)
    case Not WinActive ( $version )
        GUISetState (@SW_Show, $gd)
        WinActivate ( $version )
        EndSelect
    EndFunc
    
    Func rnotes()
    Select
    Case WinExists ( "Release Notes" )
        WinActivate ( "Release Notes" )
    Case Not WinExists ( "Release Notes" )
        GUICreate ( "Release Notes" )
        GUISetState (@SW_SHOW)
        WinMove ( "Release Notes", "", 10, 10)
        GUICtrlCreateLabel ( $releaseversion, 90, 0 )
        GUICtrlCreateLabel ( $version2,184 , 51 )
        GUICtrlCreateLabel ( " - Repaired Steam access bug(Refer to help file for more info. " , 0 , 75 )
;GUICtrlCreateLabel ( " - Added Help File section (Accessed by pressing Ctrl-P)" , 0, 99 )
;GUICtrlCreateLabel ( " - Added Release notes section (Accessed by pressing Ctrl-N)" , 0, 123 )
;GUICtrlCreateLabel ( " - Removed Steam game buttons (Push Steam button to bring up the window.)", 0, 147 )
;GUICtrlCreateLabel ( " - Fixed bug - Not able to close both Help and Release notes if both are open" , 0, 171 )
        EndSelect
    EndFunc
    
    Func helpGUI()
                Select
        case WinExists ( "Help File" )
            WinActivate ( "Help File" )
        Case Not WinExists ( "Help File" )
            GUICreate ( "Help File" )
            WinMove ( "Help File", "", 5,300 )
            GUISetState (@SW_SHOW)
        GUICtrlCreateLabel ( "Gamers Desk Help file." ,158 ,0 ) 
        GUICtrlCreateLabel ( "Viewing release notes:  Press Ctrl-N to open the release notes window; if the window" , 0, 96 )
        GUICtrlCreateLabel ( "is minimized press Ctrl-N again to re-focus the window." , 0, 108 )
        GUICtrlCreateLabel ( "Viewing control for Gamers Desk desktop:  Press Ctrl-P to hide the window when it is" , 0, 132 )
        GUICtrlCreateLabel ( "active. Pressing Ctrl-P again will re-focus the window." ,0, 144 )
        GUICtrlCreateLabel ( "To view your steam window after activating through GD you may need to ALT-Tab to it." , 0, 168 )
        EndSelect
        EndFunc
    
    Func _processkill(Const $input)
        $rinput = GUICtrlRead ( $input )
        
        Select 
        Case ProcessExists ( $rinput )
            ProcessClose ( $rinput )
            MsgBox (0, "Done", "Process ended.")
        Case not ProcessExists ( $rinput )
            MsgBox (0, "Error", "Process does not exist.")
        EndSelect
            
        EndFunc
        
        Func pcopt()
            Select
        Case WinExists ( "PC Optimizer(Alpha)" )
            WinActivate ( "PC Optimizer(Alpha)" )
        Case Not WinExists ( "PC Optimizer(Alpha)" )
            GUICreate ( "PC Optimizer(Alpha)",200,200)
                GUISetState (@sw_show)
            EndSelect
        $text = GUICtrlCreateInput ( "steam.exe",10, 50 )
        $opt2 = GUICtrlCreateButton ( "Optimize", 42,80 )
    
    EndFunc
;end functions

*edit* sorry for double post....wasn't paying attention...

Edited by aarrowh
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...