Sign in to follow this  
Followers 0
HHCory

Problem with Combo Boxes

26 posts in this topic

I have a script with a combo box I know how to loop a function but im not sure how to loop it when a combo box is used.

RoomMate.au3


I am really starting to learn how to piece together the puzzle that is AutoIt. [u]ComboBox RadioButton Help.au3[/u]

Share this post


Link to post
Share on other sites



put this around it

but this repeats it forever and ever and ever lol untill you say end script

While1
Script goes here, that wants to be repeated 
WEnd

Share this post


Link to post
Share on other sites

put this around it

but this repeats it forever and ever and ever lol untill you say end script

While1
Script goes here, that wants to be repeated 
WEnd
I want it to repeat forever but i tried that and now my go button does execute.

I am really starting to learn how to piece together the puzzle that is AutoIt. [u]ComboBox RadioButton Help.au3[/u]

Share this post


Link to post
Share on other sites

I want it to repeat forever but i tried that and now my go button does execute.

the thing is with your main loop(s). here's what you have

While 1
    $MainMsg = GUIGetMsg()
    Select
        Case $MainMsg = $GUI_EVENT_CLOSE
            Exit
        Case $MainMsg = $Button1 
            Do
                If GuiCtrlread($Combo_1) = '3-Point Shootout' Then Run('"C:\Program Files\Mozilla Firefox\firefox.exe" http://www.pogo.com/room/connect.jsp?game=threepoint&site=pogop&apid&auto=PlayNow')
                If GUICtrlRead($Combo_1) = '6th Street Omaha Poker' Then Run('"C:\Program Files\Mozilla Firefox\firefox.exe" http://www.pogo.com/room/connect.jsp?game=omaha&site=pogop&apid&auto=PlayNow')
                    Sleep((GUICtrlRead($input)) * 60 * 1000)
            Until $DumpOut = 1
    EndSelect
WEnd

here's what will work.

While 1
    $MainMsg = GUIGetMsg()
    Select
        Case $MainMsg = $GUI_EVENT_CLOSE
            Exit
        Case $MainMsg = $Button1 
                If GuiCtrlread($Combo_1) = '3-Point Shootout' Then Run('"C:\Program Files\Mozilla Firefox\firefox.exe" http://www.pogo.com/room/connect.jsp?game=threepoint&site=pogop&apid&auto=PlayNow')
                If GUICtrlRead($Combo_1) = '6th Street Omaha Poker' Then Run('"C:\Program Files\Mozilla Firefox\firefox.exe" http://www.pogo.com/room/connect.jsp?game=omaha&site=pogop&apid&auto=PlayNow')
    EndSelect
Sleep(100)
WEnd

even with this little change, your code is not as efficient as it could be, but it should work as you want it to; and i think right now that's what's most important to you right?


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

even with this little change, your code is not as efficient as it could be, but it should work as you want it to; and i think right now that's what's most important to you right?

yeah that is true. I am trying to learn this language but i am having a hard time putting it together.

I am really starting to learn how to piece together the puzzle that is AutoIt. [u]ComboBox RadioButton Help.au3[/u]

Share this post


Link to post
Share on other sites

yeah that is true. I am trying to learn this language but i am having a hard time putting it together.

don't be too hard on yourself, learning anything is a process. my suggestion is to read through the posts here on the support forum, and try to post solutions to ones you think you can handle. that will give you practice, and seeing other people's answers to the same issue can help you fine tune your own abilities. The suggested replacement worked for you atleast i hope.

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

#7 ·  Posted (edited)

well unfortunately it didn't. the Button still will not execute.

here is what i changed

RoomMate.au3

Edited by HHCory

I am really starting to learn how to piece together the puzzle that is AutoIt. [u]ComboBox RadioButton Help.au3[/u]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

well unfortunately it didn't. the Button still will not execute.

here is what i changed

this works for me (i made it notepad and calculator again because i can't bring games up), although a little slow to respond... i'm going to play with it a little and see if i can't find what's slowing it down...

***edit*** i'm retarded. you're using msgloop mode that i don't normally use, for message loop you don't need the sleep, that's what was causing my slow response. corrected code below, it should work for you.

#include <GuiConstants.au3>
Global $DumpOut = 0
HotKeySet('{esc}', "MyExitLoop")
$InetActive = Ping("www.google.com")
If Not $InetActive > 0 Then
    MsgBox(4112, "Connection Not Found!", "You must be connected to the Internet" & @CRLF & "to use this program")
    Exit
EndIf

MsgBox(0, "Help File", "To Run this auto first select the time you want this game to run" & @CRLF & "Then Select the game you want to play and Press Go" & @CRLF & "The agent will then run for the time you selected then it will close " & @CRLF & "and reload the game window." & @CRLF & "To stop the Auto Close progam in system Menu")
; GUI
GUICreate("RoomMate", 175, 90, (@DesktopWidth - 191) / 2, (@DesktopHeight - 157) / 2)
opt("TrayMenuMode", 1)
opt("TrayOnEventMode", 1)
$show_tray = TrayCreateItem("About this Program")
TrayItemSetOnEvent(-1, "Set_Show")
TrayCreateItem("")
$exit_tray = TrayCreateItem("Exit this Program")
TrayItemSetOnEvent(-1, "Set_Exit")
TraySetState()

$Combo_1 = GUICtrlCreateCombo("Select Game", 10, 10, 150, 21)
GUICtrlSetData($Combo_1, "|notepad|calculator")
$Button1 = GUICtrlCreateButton('GO', 35, 35, 100, 17)
GUICtrlCreateLabel("Minutes to play?", 10, 55, 250, 20)
$input = GUICtrlCreateInput(60, 125, 53, 30, 17, $ES_NUMBER)

GUISetState()
While 1
    $MainMsg = GUIGetMsg()
    Select
        Case $MainMsg = $GUI_EVENT_CLOSE
            Exit
        Case $MainMsg = $Button1
            If GUICtrlRead($Combo_1) = 'notepad' Then Run('notepad.exe')
            If GUICtrlRead($Combo_1) = 'calculator' Then Run('calc.exe')
    EndSelect
WEnd




;------------- Functions ----------------------

Func MyExitLoop()
    $DumpOut = 1
EndFunc ;==>MyExitLoop
Func Set_Exit()
    Exit
EndFunc ;==>Set_Exit

Func Set_Show()
    MsgBox(64, " About this Program", " this Program was designed by HHCORY!!!")
EndFunc ;==>Set_Show
; GUI MESSAGE LOOP
GUISetState()
While GUIGetMsg() <> $GUI_EVENT_CLOSE
WEnd
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

#9 ·  Posted (edited)

i see that that works. i have it inputed to sleep

Sleep((GUICtrlRead($input)) * 60 * 1000)

could that be the problem?

with the version that you posted it will sleep but it will not loop the run function.

for instance it will load the notepad once but it will not reload it when the sleep function is complete.

just seen your edit. with the sleep function removed what is to tell it how long to wait before it loops?

Edited by HHCory

I am really starting to learn how to piece together the puzzle that is AutoIt. [u]ComboBox RadioButton Help.au3[/u]

Share this post


Link to post
Share on other sites

i see that that works. i have it inputed to sleep

Sleep((GUICtrlRead($input)) * 60 * 1000)

could that be the problem?

with the version that you posted it will sleep but it will not loop the run function.

for instance it will load the notepad once but it will not reload it when the sleep function is complete.

right. even with the sleep there, once the sleep runs out, the $MainMsg is re-evaluated (it will have a different value in an hour) and the select statement runs again. if you want to do something like that, you should have an external condition check. like have a value that is set before the loop..

$relaunch = ""

then when an application is launched, update it with the name. Then you can have a check in your while loop that re-launches as necessary, resets the timer etc.

Case $MainMsg = $Button1
            If GUICtrlRead($Combo_1) = 'notepad' Then Run('notepad.exe')
            If GUICtrlRead($Combo_1) = 'calculator' Then Run('calc.exe')
$Timer = TimerInit()
$relaunch = GUICtrlRead($Combo_1)
    EndSelect
If StringLen($relaunch) and TimerDiff($Timer) > GUICtrlRead($input)*60000 Then
ControlClick("RoomMate","","GO")
$Timer = TimerInit()
EndIf

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

sighs...... that gives me an error saying

==> Variable used without being declared.:

If StringLen($relaunch) and TimerDiff($Timer) > GUICtrlRead($input)*60000 Then

If StringLen(^ ERROR

:lmao:


I am really starting to learn how to piece together the puzzle that is AutoIt. [u]ComboBox RadioButton Help.au3[/u]

Share this post


Link to post
Share on other sites

sighs...... that gives me an error saying

==> Variable used without being declared.:

If StringLen($relaunch) and TimerDiff($Timer) > GUICtrlRead($input)*60000 Then

If StringLen(^ ERROR

:lmao:

did you add the first line that's by itself? that creates the variable and assigns empty string

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

No i forgot that. I added that and i tested it. I set the timer to 1min. selected notepad and hit go. it loaded go but after the 1 min is up it did not reload(which in the case with notepad it should open a new notepad).


I am really starting to learn how to piece together the puzzle that is AutoIt. [u]ComboBox RadioButton Help.au3[/u]

Share this post


Link to post
Share on other sites

No i forgot that. I added that and i tested it. I set the timer to 1min. selected notepad and hit go. it loaded go but after the 1 min is up it did not reload(which in the case with notepad it should open a new notepad).

new script?

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

sorry here it is

the problem is that your $relaunch="" is inside your while loop. move it up one line before the while loop and you're all set. tested and it works.

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

#17 ·  Posted (edited)

yeah that is it. it works now even with the run file changed to run the game it was made to run. thanks for the help. My next thing to add to it is to add checkbox's to change it from firefox to IE. i will play with if for a few days. i may be back for more help later. I am really starting to learn how to piece together the puzzle that is AutoIt. thanks again

Edited by HHCory

I am really starting to learn how to piece together the puzzle that is AutoIt. [u]ComboBox RadioButton Help.au3[/u]

Share this post


Link to post
Share on other sites

yeah that is it. it works now even with the run file changed to run the game it was made to run. thanks for the help. My next thing to add to it is to add checkbox's to change it from firefox to IE. i will play with if for a few days. i may be back for more help later. I am really starting to learn how to piece together the puzzel that is AutoIt. thanks again

no problem. i'm always glad to help.

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

#19 ·  Posted (edited)

for some reason this is giving me a error

(23) : ==> "EndSelect" statement with no matching "Select" statement.:

Edited by HHCory

I am really starting to learn how to piece together the puzzle that is AutoIt. [u]ComboBox RadioButton Help.au3[/u]

Share this post


Link to post
Share on other sites

for some reason this is giving me a error

(23) : ==> "EndSelect" statement with no matching "Select" statement.:

have a look at the Tidy output:

While 1
    $MainMsg = GUIGetMsg()
    Select
        Case $MainMsg = $GUI_EVENT_CLOSE
            Exit
        Case $MainMsg = $Button1
            If GUICtrlRead($Radio1) = 'Firefox' Then 
                If GUICtrlRead($Combo_1) = '3-Point Shooter' Then Run('"C:\Program Files\Mozilla Firefox\firefox.exe" www.google.com'
                If GUICtrlRead($Radio2) = 'Internet Explorer' Then 
                    If GUICtrlRead($Combo_1) = '3-Point Shooter' Then Run('"C:\Program Files\Internet Explorer\IExplore.exe" www.google.com')
;### Tidy Error: Level error -> EndSelect is closing previous If
            EndSelect
;### Tidy Error: Level error -> WEnd is closing previous Case
        WEnd

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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