Sign in to follow this  
Followers 0
Paradox

Is this possible?

13 posts in this topic

Hey guys, me again... Here's something for you try to figure out. I'm working on another script that will set up the ODBC sources for a client side application. In my script, I've made it pause and inform the user that they need to select a data server to connect to from a drop down list and then click the OK button to continue the script. Here's my source:

#include <GUIConstants.au3>

; Automated ODBC Data Source Setup for use with MS SQL Server - Client side.

Run("odbcad32.exe")
WinWaitActive("ODBC Data Source Administrator")
Send("^{TAB}")
Send("!d")
Send("{PGDN 3}")
Send("{ENTER}")
Send("dbLots")
Send("{TAB}")
Send("Batch Manager")

; Creates pop-up window instructing user to select SQL Server. Closes when "OK" or;"X" is pressed.

    Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
    GUICreate("SQL Selection", 375, 100)
    GUICtrlCreateLabel("Choose SQL Server from Drop-Down list. Press Okay when finished", 30, 10)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
    $okbutton = GUICtrlCreateButton("OK", 150,30,50)
    GUICtrlSetOnEvent($okbutton, "OKButton")
    GUISetState(@sw_show)

     Func OKButton()
      GUIDelete()
     EndFunc

       Func CLOSEClicked()
      Exit
     EndFunc
    
WinWaitClose("SQL Selection")

Send("{TAB 2}")
Send("{ENTER}")
Send("{DOWN}")
Send("{TAB 3}")
SEND("DBUser")
SEND("{TAB}")
send("cegedim")
Send("{ENTER}")
SEND("{SPACE}")
SEND("{TAB}")
SEND("dbLots")
send("{ENTER 2}")
send("{TAB}")
send("{SPACE}")
Send("{ENTER}")

As you can see it's pretty straight forward. This is what I'm wanting to figure out now... Is it possible, in the section where I'm pausing for the user to select the SQL Server, to code something in to ensure that a selection has actually been made and that the user isn't just clicking OK to proceed???

Share this post


Link to post
Share on other sites



I dont know much about the gui programing, but for a simple solution you could put a option that is defaulted to "select server" and value of like "null" and if $selection = "null" then bring up a message box saying you must select a server and bring up the selection agine. that way they would have to select something.

Just my 2 cents

Share this post


Link to post
Share on other sites

I dont know much about the gui programing, but for a simple solution you could put a option that is defaulted to "select server" and value of like "null" and if $selection = "null" then bring up a message box saying you must select a server and bring up the selection agine. that way they would have to select something.

Just my 2 cents

<{POST_SNAPBACK}>

I can't have my script put in a selection for this one. It's part of windows, and you have to choose from the drop down list. Basically, once you get to this section of the ODBC setup, Windows will search the existing network and populate the drop down list with all the available SQL servers from your network. You have to then choose from this list which one you connect to. All I want to do is find a way to make sure that the user actually selected something from that list. Sorry if you didn't understand me earlier, hopefully that makes better sense.

Share this post


Link to post
Share on other sites

I can't have my script put in a selection for this one. It's part of windows, and you have to choose from the drop down list. Basically, once you get to this section of the ODBC setup, Windows will search the existing network and populate the drop down list with all the available SQL servers from your network. You have to then choose from this list which one you connect to.  All I want to do is find a way to make sure that the user actually selected something from that list.  Sorry if you didn't understand me earlier, hopefully that makes better sense.

<{POST_SNAPBACK}>

here's what i've got... i took out your message box and added a check to see if the value is still blank in a loop. if the value changes, the script confirms that this is the one they want and continues if it is.

#include <GUIConstants.au3>

; Automated ODBC Data Source Setup for use with MS SQL Server - Client side.

Run("odbcad32.exe")
WinWaitActive("ODBC Data Source Administrator")
Send("^{TAB}")
Send("!d")
Send("{PGDN 3}")
Send("{ENTER}")
Send("dbLots")
Send("{TAB}")
Send("Batch Manager")

; Creates pop-up window instructing user to select SQL Server. Closes when "OK" or;"X" is pressed.

    Opt("GUIOnEventMode", 1); Change to OnEvent mode
    GUICreate("SQL Selection", 375, 100)
    while 1
        sleep(100)
        $test = ControlGetText("Create","",1001)
        if $test <> "" Then
            $MakeSure = MsgBox(4,"Are you sure?","Is " & $test & " the sql server you wish to use?")
            if $MakeSure = 6 then ExitLoop
        EndIf
    WEnd
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
    $okbutton = GUICtrlCreateButton("OK", 150,30,50)
    GUICtrlSetOnEvent($okbutton, "OKButton")
    GUISetState(@sw_show)

     Func OKButton()
      GUIDelete()
     EndFunc

       Func CLOSEClicked()
      Exit
     EndFunc
    
WinWaitClose("SQL Selection")

Send("{TAB 2}")
Send("{ENTER}")
Send("{DOWN}")
Send("{TAB 3}")
SEND("DBUser")
SEND("{TAB}")
send("cegedim")
Send("{ENTER}")
SEND("{SPACE}")
SEND("{TAB}")
SEND("dbLots")
send("{ENTER 2}")
send("{TAB}")
send("{SPACE}")
Send("{ENTER}")

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

here's what i've got... i took out your message box and added a check to see if the value is still blank in a loop.  if the value changes, the script confirms that this is the one they want and continues if it is.

Opt("GUIOnEventMode", 1); Change to OnEvent mode
    GUICreate("SQL Selection", 375, 100)
    while 1
        sleep(100)
        $test = ControlGetText("Create","",1001)
        if $test <> "" Then
            $MakeSure = MsgBox(4,"Are you sure?","Is " & $test & " the sql server you wish to use?")
            if $MakeSure = 6 then ExitLoop
        EndIf
    WEnd
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
    $okbutton = GUICtrlCreateButton("OK", 150,30,50)
    GUICtrlSetOnEvent($okbutton, "OKButton")
    GUISetState(@sw_show)

     Func OKButton()
      GUIDelete()
     EndFunc

       Func CLOSEClicked()
      Exit
     EndFunc
   
I like what you did, but I had to do some modifications to it (hope you don't mind ;) ) Anyways, I changed it slightly back to having a window pop up telling the user that they need to choose a SQL Server, added a 5 second delay in the loop (so that it doesn't give you crap as soon as you press the drop down arrow), then I put your code (veryifying that a selection has been made). Here's what it looks like:

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
GUICreate("SQL Selection", 200, 75)
GUICtrlCreateLabel("Choose SQL Server from Drop-Down list.", 0, 10) 
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState(@sw_show)
while 1
  sleep(5000)
  $test = ControlGetText("Create","",1001)
    if $test <> "" Then
      $MakeSure = MsgBox(4,"Are you sure?","Is " & $test & " the sql server you wish to use?")
        if $MakeSure = 6 then 
     ExitLoop
        EndIF
    EndIf
WEnd

Func CLOSEClicked()
  Exit
EndFunc

WinClose("SQL Selection")   
WinWaitClose("SQL Selection")

Here's the next problem, it goes through, your modification verifies the selection, but when I press "Yes", my whole script just stops... Where am I screwing this up??

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I like what you did, but I had to do some modifications to it (hope you don't mind ;) ) Anyways, I changed it slightly back to having a window pop up telling the user that they need to choose a SQL Server, added a 5 second delay in the loop (so that it doesn't give you crap as soon as you press the drop down arrow), then I put your code (veryifying that a selection has been made). Here's what it looks like:

Opt("GUIOnEventMode", 1); Change to OnEvent mode
GUICreate("SQL Selection", 200, 75)
GUICtrlCreateLabel("Choose SQL Server from Drop-Down list.", 0, 10)    
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState(@sw_show)
while 1
  sleep(5000)
  $test = ControlGetText("Create","",1001)
    if $test <> "" Then
      $MakeSure = MsgBox(4,"Are you sure?","Is " & $test & " the sql server you wish to use?")
        if $MakeSure = 6 then 
     ExitLoop
        EndIF
    EndIf
WEnd

Func CLOSEClicked()
  Exit
EndFunc

WinClose("SQL Selection")    
WinWaitClose("SQL Selection")

Here's the next problem, it goes through, your modification verifies the selection, but when I press "Yes", my whole script just stops... Where am I screwing this up??

<{POST_SNAPBACK}>

once the loop is exited, you run out of code. you probably want another infinite loop to keep your gui on screen and handle user interaction.

***edit*** fixed typo

Edited by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

once the loop is exited, you run out of code.  you probably want another infinite loop to keep your gui on screen and handle user interaction.

***edit***  fixed typo

<{POST_SNAPBACK}>

Nonono... I only posted up the GUI section of the updated code... the remainder of code from my original post is still written... so it's not that there's a lack of code.... Hmmm... I wonder...

Share this post


Link to post
Share on other sites

Nonono... I only posted up the GUI section of the updated code... the remainder of code from my original post is still written... so it's not that there's a lack of code.... Hmmm... I wonder...

<{POST_SNAPBACK}>

i haven't finished my UDF for guessing other people's code yet, so i'm only able to troubleshoot what's posted... ;)

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

i haven't finished my UDF for guessing other people's code yet, so i'm only able to troubleshoot what's posted... ;)

<{POST_SNAPBACK}>

Nah man, it's cool... I figured it out... :P I took out the GUI completely and put in a leading MSGBOX() command... here's what the new junk looks like:

Msgbox(48, "SQL Selection", "Please choose a SQL Server from the drop down list, then press OK to continue")
$test = ControlGetText("Create","",1001)
if $test = "" Then
do
  msgbox(48, "SQL Selection", "Please choose a SQL Server from the drop down list, then press OK to continue")
  sleep(2500)
  $test = ControlGetText("Create","",1001)
    if $test <> "" Then
    $MakeSure = MsgBox(4,"Are you sure?","Is " & $test & " the sql server you wish to use?")
        if $makesure <> 6 then
            $test=""
        endif
    endif
until $makesure=6
endif

Winclose("SQL Selection")   
WinWaitClose("SQL Selection")
WinActivate("Create a New Data Source to SQL Server")
WinWaitActive("Create a New Data Source to SQL Server")
.
.
.
code continues on....

Works like a charm, if the user doesn't choose anything, it reopens the window instructing them to choose a server. Once they choose a server, your code has them verify.. If they say "NO", then it assigns the $test back to null and reinitiates the loop. They can sit there hitting anything they want, but until there's a value for the server, and they confirm that that's the server they want to connect to, it'll just loop..

Thanks for the help man!! Really appreciate it! Couldn't have gotten it done any sooner either... I'm going to lunch right now, and then when I get back, I have to roll out the whole package to a bank in Miami. Fun, huh??? :mad2:

Share this post


Link to post
Share on other sites

i haven't finished my UDF for guessing other people's code yet, so i'm only able to troubleshoot what's posted... ;)

<{POST_SNAPBACK}>

:P:mad2:

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Nah man, it's cool... I figured it out...  ;) I took out the GUI completely and put in a leading MSGBOX() command... here's what the new junk looks like:

Msgbox(48, "SQL Selection", "Please choose a SQL Server from the drop down list, then press OK to continue")
$test = ControlGetText("Create","",1001)
if $test = "" Then
do
  msgbox(48, "SQL Selection", "Please choose a SQL Server from the drop down list, then press OK to continue")
  sleep(2500)
  $test = ControlGetText("Create","",1001)
    if $test <> "" Then
    $MakeSure = MsgBox(4,"Are you sure?","Is " & $test & " the sql server you wish to use?")
        if $makesure <> 6 then
            $test=""
        endif
    endif
until $makesure=6
endif

Winclose("SQL Selection")    
WinWaitClose("SQL Selection")
WinActivate("Create a New Data Source to SQL Server")
WinWaitActive("Create a New Data Source to SQL Server")
.
.
.
code continues on....

Works like a charm, if the user doesn't choose anything, it reopens the window instructing them to choose a server. Once they choose a server, your code has them verify.. If they say "NO", then it assigns the $test back to null and reinitiates the loop.  They can sit there hitting anything they want, but until there's a value for the server, and they confirm that that's the server they want to connect to, it'll just loop..

Thanks for the help man!! Really appreciate it! Couldn't have gotten it done any sooner either... I'm going to lunch right now, and then when I get back, I have to roll out the whole package to a bank in Miami. Fun, huh???  :P

<{POST_SNAPBACK}>

glad i could help. you wanna hear about fun? we just got notice that our office is being shut down. they pulled 187 people off the phones to let us know in 90 days the building is closed for business, then asked everybody to go on doing their job as usual until the set date, or the the day that they choose to close us early. Probably the funniest thing i've heard in a long time, and they said it with a straight face. Oh well, more forum time today than usual i guess. No worries, i'm employable.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

glad i could help.  you wanna hear about fun? we just got notice that our office is being shut down.  they pulled 187 people off the phones to let us know in 90 days the building is closed for business, then asked everybody to go on doing their job as usual until the set date, or the the day that they choose to close us early.  Probably the funniest thing i've heard in a long time, and they said it with a straight face.  Oh well, more forum time today than usual i guess.  No worries, i'm employable.

<{POST_SNAPBACK}>

;) Dude, I cannot tell you how much that just plain sucks ass!! My condolences...

Share this post


Link to post
Share on other sites

;)  Dude, I cannot tell you how much that just plain sucks ass!! My condolences...

<{POST_SNAPBACK}>

thanks, i'm really not worried about it. in 3 months i think about anybody could get a job, i've gone to college, and have a decent resume

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

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