Sign in to follow this  
Followers 0
Raluvian

conditional help

8 posts in this topic

im trying to make a launch pad for all my programs assosiated with a certain game... and i have been trying to get this gui working, but i don't get how to link exe to a button. and be able to type an exe name into a chat box within the gui and click a button to run that exe name i typed in.

so far i have

$var1 = "notepad.exe"

if $button_2 > 1 Then

run("$var1")

else

msgbox(0, "ERROR", "The given EXE was not found")

EndIf

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

this should help

#include <GUIConstants.au3>

Dim $var1 = "notepad.exe"

GUICreate("MY gui")
$button_2 = GUICtrlCreateButton("RUN NOTEPAD", 50, 100, 100, 20)
GUISetState()

While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE then Exit
    
    If $msg = $button_2 Then
        Run($var1); no quotes
        WinWait("")
        If WinExists("Untitled -") Then
            Send("Hello", 1)
        Else
            msgbox(0,"ERROR", " Notepad was not found   ")
        EndIf
    EndIf
    
WEnd

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

ok that works but how would i replicate this to work with maybe 14 different buttons. here is my whole code

#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>

Dim $var1 = "notepad.exe"

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("LAUNCH PAD", 590, 124,(@DesktopWidth-590)/2, (@DesktopHeight-124)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Input_1 = GuiCtrlCreateInput("EXE LAUNCHER", 10, 90, 100, 20)
$Button_2 = GuiCtrlCreateButton("Button2", 0, 30, 50, 40)
$Button_3 = GuiCtrlCreateButton("Button3", 60, 30, 50, 40)
$Button_4 = GuiCtrlCreateButton("Button4", 120, 30, 50, 40)
$Button_5 = GuiCtrlCreateButton("Button5", 180, 30, 50, 40)
$Button_6 = GuiCtrlCreateButton("Button6", 240, 30, 50, 40)
$Button_7 = GuiCtrlCreateButton("Button7", 300, 30, 50, 40)
$Button_8 = GuiCtrlCreateButton("Button8", 360, 30, 50, 40)
$Button_9 = GuiCtrlCreateButton("Button9", 420, 30, 50, 40)
$Button_10 = GuiCtrlCreateButton("Button10", 480, 30, 50, 40)
$Button_11 = GuiCtrlCreateButton("Button11", 540, 30, 50, 40)
$Label_12 = GuiCtrlCreateLabel("LAUNCH PAD", 220, 10, 150, 20)
$Button_13 = GuiCtrlCreateButton("Button13", 120, 80, 50, 40)
$Button_14 = GuiCtrlCreateButton("Button14", 180, 80, 50, 40)
$Button_15 = GuiCtrlCreateButton("Button15", 240, 80, 50, 40)
$Button_16 = GuiCtrlCreateButton("Button16", 300, 80, 50, 40)
$Button_17 = GuiCtrlCreateButton("Button17", 360, 80, 50, 40)
$Button_18 = GuiCtrlCreateButton("Button18", 420, 80, 50, 40)
$Button_19 = GuiCtrlCreateButton("Button19", 480, 80, 50, 40)
$Button_20 = GuiCtrlCreateButton("Button20", 540, 80, 50, 40)

GUISetState()
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE then Exit
    
    If $msg = $button_2 Then
        Run($var1)
    EndIf
    
WEnd

Exit
#endregion --- GuiBuilder generated code End ---

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE then Exit
    
    If $msg = $button_2 Then
        Run($var1); no quotes
        WinWait("")
        If WinExists("Untitled -") Then
            Send("Hello", 1)
        Else
            msgbox(0,"ERROR", " Notepad was not found   ")
        EndIf
    EndIf
    
    If $msg = Button?? then
      ;do this
    endif

    if $msg = $button???? then
     ; do this
    endif

WEnd

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Also the command

Run

will give a fatal error and the script will crash ... unless you set the @error... see help

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

ok that works but how would i replicate this to work with maybe 14 different buttons. here is my whole code

Valuater gave you what you asked for and a whole lot more...

You meant to say thank-you right?


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

i was exagerating i was going to say thank you at the end of this whole topic but, thanks to some other interuptions maybe i will now.

Thank you Valuater

DaleHohm B)

Share this post


Link to post
Share on other sites

Your welcome

and i feel the same way sometimes Dale...thx

8)


NEWHeader1.png

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