Jump to content

Gui in If statement...


Recommended Posts

I basically want a Gui to pop up and ask for user input with a combolist if a variable is blank. I've tried it and it's not working, it just skips that part of the script it seems.

Example:

Global $company
Global $conumber

$company = EnvGet("COMPANY")

If Not $company = "" Then
                Run("program.exe")
Else
     ; GUI
    GuiCreate("gui", 400, 150)
    GuiSetIcon("icon.ico")
    GUISetOnEvent($GUI_EVENT_CLOSE, 'Event_GUIClose')
    
; BUTTON
    GUICtrlCreateButton("OK", 100, 100, 200, 30)
    GUICtrlSetOnEvent(-1, 'conumber')
    
; COMBO
    $conumber = GUICtrlCreateCombo("", 130, 75, 150, 120, $CBS_DROPDOWNLIST)
    GUICtrlSetData(-1, "company1|company2","company1")
EndIf

Func conumber()
                Blah Blah Blah, script stuff
EndFunc

Exit
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

  • Developers

This is wrong:

If Not $company = "" Then

should be:

If Not ($company = "") Then

or

If $company <> "" Then

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

This is wrong:

If Not $company = "" Then

should be:

If Not ($company = "") Then

or

If $company <> "" Then

Changed it, it had no effect. I haven't had problems not using () around variables like that before, I think it is redundant.

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

  • Developers

Changed it, it had no effect. I haven't had problems not using () around variables like that before, I think it is redundant.

Nah..

try this

$company = ""
If Not $company = "" Then ConsoleWrite("Test 1" & @LF)
If Not ($company = "") Then ConsoleWrite("Test 2" & @LF)

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

Nah..

try this

$company = ""
If Not $company = "" Then ConsoleWrite("Test 1" & @LF)
If Not ($company = "") Then ConsoleWrite("Test 2" & @LF)
Regardless, why isn't my Gui showing up? It doesn't do anything. Is it possible to use a Gui like that in an If statement?
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

  • Developers

Regardless, why isn't my Gui showing up? It doesn't do anything. Is it possible to use a Gui like that in an If statement?

Regardless is your way of saying ...you are right ? :)

here is a base working GUI... need modification but should get you started:

#include<GUIconstants.au3>
$company = ""
Opt("GUIOnEventMode", 1)
If Not ($company = "") Then
                Run("program.exe")
Else
     ; GUI
    GuiCreate("gui", 400, 150)
    GuiSetIcon("icon.ico")
    GUISetOnEvent($GUI_EVENT_CLOSE, 'Event_GUIClose')
; BUTTON
    GUICtrlCreateButton("OK", 100, 100, 200, 30)
    GUICtrlSetOnEvent(-1, 'conumber')
; COMBO
    $conumber = GUICtrlCreateCombo("", 130, 75, 150, 120, $CBS_DROPDOWNLIST)
    GUICtrlSetData(-1, "company1|company2","company1")
    GUISetState()
    While 1
        Sleep (20)
    WEnd
EndIf

Func Event_GUIClose()
    ; Guiclosed
    Exit
EndFunc
Func conumber()
               ; Blah Blah Blah, script stuff
EndFunc

Exit

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

Thanks guys, adding the while/wend and the GuiSetState() fixed it! You guys rock! :)

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

Try creating a GUI using the GUIWizard first, then modify the script to do whatever you want it to do. At least you know the GUI works.

Regardless, why isn't my Gui showing up? It doesn't do anything. Is it possible to use a Gui like that in an If statement?

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