Jump to content
Sign in to follow this  
r1tony

Newbie: Need help resetting guictrl input box

Recommended Posts

r1tony

Sorry new to this and trying to figure out how I can make this script run over again with entering new variables. It works perfect the first time, then when I enter text in again it has no data on the $player1 GUICtrlInput variable, when I enter in a different persons name and click ok.

Here is my code, I know its something simple or how I coded it.. Hopefully someone can quickly point out my mistake.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
 
global $ss_username = "xxxxx"                                   
global $ss_password = "xxxxx"          

; create GUI window with the size of 269*140
$Form1 = GUICreate("Test Gui", 269, 140, 193, 115)
; create input control
$player1 = GUICtrlCreateInput("", 72, 16, 121, 21)
; create a button which says "Scope Player"
$Button1 = GUICtrlCreateButton("Scope Player", 96,44, 75, 25, 0)
; set the GUI to to show, so you can see it
global $label = GuiCtrlCreateLabel("ScopedPlayer:  ROI,  Profit,  Games,  Stake", 8, 82, 200, 15)
global $label2 = GuiCtrlCreateLabel("No Data Yet.", 8, 100, 200, 15)
GUISetState(@SW_SHOW)
 
While 1 ; loop until expression is false
    $nMsg = GUIGetMsg()
    
    Switch $nMsg
        
        Case $GUI_EVENT_CLOSE ; if the user clicks on X (closes the window)
            Exit ;  the script will exit.
            
        Case $button1 ; the the user clicks on the button
            
        $player1 = GUICtrlRead($player1)
        If $player1 <> "" Then                                                    ;make sure we're not scoping a blank string
            GuiCtrlSetData($label, 'Scoping : ' & $player1)
            $avArray = scope_player($player1)
                                                                                                                  ;msgbox(4160, "Debug", "Got here 1")
            If isarray($avArray) == 1 Then
                $playername = $player1
                $gamesplayed = $avArray[2]
                $avgprofit = $avArray[3]
                $avgstake = $avArray[4]
                $avgROI = $avArray[5]       
                $totalprofit = $avArray[6]
                $avgROI = int($avgROI)
                $gamesplayed = int($gamesplayed)
                
                                                                                   ;update label display
                GUICtrlSetData($label, 'ScopedPlayer:  ROI,  Profit,  Games,  Stake')
                GuiCtrlSetData($label2, $playername & ':  ' & $avgROI & '%,  $' & $totalprofit & ',  ' & $gamesplayed & ',  ' & $avgstake)
                GuiCtrlSetData($player1,"")
            EndIf
        Else
            GuiCtrlSetData($label, "Error retrieving username.")
        EndIf
        
    EndSwitch
WEnd; end of loop 

Func scope_player($player1)
        sleep(1000)
        $query = "http://www.xxxxx.com/xxxx/FindPlayer?searchstring=" & $player1 & "&Network=pokerstars&Username=" & $ss_username & "&Password=" & $ss_password & "&StartDate=&EndDate=&DateRange=99&MinPlayers=2&MaxPlayers=4&Rebuy=UAR&MinStake=0&MaxStake=9999"
        $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
        $oHTTP.Open("GET", $query)
        $oHTTP.Send()
        $HTMLSource = $oHTTP.Responsetext 
        ;msgbox(4160, "Http Response", $HTMLSource)
        $search_for = "PlayerList"
        $startvalue = stringinstr($HTMLSource, $search_for)
        If($startvalue == 0) Then
            GuiCtrlSetData($label, "Error scoping.")
            GUICtrlSetData($label2, "Probably blocked.")
            $avArray = "gay!"
        Else
            $line = stringmid($HTMLSource, $startvalue, 150)
            $avArray = stringsplit($line, ",")
        EndIf
        Return $avArray
    EndFunc

So basically I enter in a player into the inputbox and click scope player. It polls stats from a webpage and displays them in the gui box. I want to do this multiple times without restarting the script, with different players.

thanks!

Edited by r1tony

Share this post


Link to post
Share on other sites
Valuater

Sorry new to this and trying to figure out how I can make this script run over again with entering new variables. It works perfect the first time, then when I enter text in again it has no data on the $player1 GUICtrlInput variable, when I enter in a different persons name and click ok.

Here is my code, I know its something simple or how I coded it.. Hopefully someone can quickly point out my mistake.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
 
global $ss_username = "xxxxx"                               
global $ss_password = "xxxxx"         

; create GUI window with the size of 269*140
$Form1 = GUICreate("Test Gui", 269, 140, 193, 115)
; create input control
$player1 = GUICtrlCreateInput("", 72, 16, 121, 21)
; create a button which says "Scope Player"
$Button1 = GUICtrlCreateButton("Scope Player", 96,44, 75, 25, 0)
; set the GUI to to show, so you can see it
global $label = GuiCtrlCreateLabel("ScopedPlayer:  ROI,  Profit,  Games,  Stake", 8, 82, 200, 15)
global $label2 = GuiCtrlCreateLabel("No Data Yet.", 8, 100, 200, 15)
GUISetState(@SW_SHOW)
 
While 1 ; loop until expression is false
    $nMsg = GUIGetMsg()
    
    Switch $nMsg
        
        Case $GUI_EVENT_CLOSE ; if the user clicks on X (closes the window)
            Exit ;  the script will exit.
            
        Case $button1 ; the the user clicks on the button
            
        $player1 = GUICtrlRead($player1)
        If $player1 <> "" Then                                     ;make sure we're not scoping a blank string
            GuiCtrlSetData($label, 'Scoping : ' & $player1)
            $avArray = scope_player($player1)
                                                                                                                  ;msgbox(4160, "Debug", "Got here 1")
            If isarray($avArray) == 1 Then
                $playername = $player1
                $gamesplayed = $avArray[2]
                $avgprofit = $avArray[3]
                $avgstake = $avArray[4]
                $avgROI = $avArray[5]      
                $totalprofit = $avArray[6]
                $avgROI = int($avgROI)
                $gamesplayed = int($gamesplayed)
                
                                                                                   ;update label display
                GUICtrlSetData($label, 'ScopedPlayer:  ROI,  Profit,  Games,  Stake')
                GuiCtrlSetData($label2, $playername & ':  ' & $avgROI & '%,    & $totalprofit & ',  ' & $gamesplayed & ',  ' & $avgstake)
                GuiCtrlSetData($player1,"")
            EndIf
        Else
            GuiCtrlSetData($label, "Error retrieving username.")
        EndIf
        
    EndSwitch
WEnd; end of loop 

Func scope_player($player1)
        sleep(1000)
        $query = "http://www.xxxxx.com/xxxx/FindPlayer?searchstring=" & $player1 & "&Network=pokerstars&Username=" & $ss_username & "&Password=" & $ss_password & "&StartDate=&EndDate=&DateRange=99&MinPlayers=2&MaxPlayers=4&Rebuy=UAR&MinStake=0&MaxStake=9999"
        $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
        $oHTTP.Open("GET", $query)
        $oHTTP.Send()
        $HTMLSource = $oHTTP.Responsetext 
        ;msgbox(4160, "Http Response", $HTMLSource)
        $search_for = "PlayerList"
        $startvalue = stringinstr($HTMLSource, $search_for)
        If($startvalue == 0) Then
            GuiCtrlSetData($label, "Error scoping.")
            GUICtrlSetData($label2, "Probably blocked.")
            $avArray = "gay!"
        Else
            $line = stringmid($HTMLSource, $startvalue, 150)
            $avArray = stringsplit($line, ",")
        EndIf
        Return $avArray
    EndFuncoÝ÷ Ù*jÈjYr!éíz¸§jZÉêâÚ-触ë[£§uÉbrK¢©¬¬i¢Yl²Ö­±úè¬n y©Ýv+)¬¬¶¦{az¢nHÁ©í¶h¶¬ém^¶)³­­­ë-j»bazÇ+pØ]÷Þ­éí¦V²z»-©ä³}ÿªê-zÚò¶¬jëh×6       EndIf
        $oHTTP = ""
        Return $avArray
    EndFunc

the original object needs to be removed first... pretty damn good for a first post!!

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
r1tony

Thanks for the reply. I added the suggestion to the function of scope_player and it still will do the same thing.

Let me try to clarify.

I start script, I enter a player name into text box and click ok. The script returns the results from specified web site to GUI and all is good. Now I want to scope another player I backspace/delete previous player out of the text box and hit Scope button again and it returns : "Error retrieving username." to the gui (I know this is a valid name or even if I try the last name that did a successful pull).

I think it is hitting the If $player1 <> "" statement and it is not picking up the new data from which I typed in the $player1 = GUICtrlCreateInput("", 72, 16, 121, 21) before I hit Scope button again. I guess I am not sure how to get the script to reinitialize the top code above the While 1 statement where the data is being pulled via functions etc.

If I close the program and restart it, it works the first time again but any subsiquent times will fail to pull with "Error ...." like described above.

Thank you.

Edited by r1tony

Share this post


Link to post
Share on other sites
Valuater

GOT IT!!!

You cannot have the control name the same as your control-read name

$player1 = GUICtrlRead($player1)

will not work more than once

tat-ta-ta-tahhhhh!!!

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
r1tony

GOT IT!!!

You cannot have the control name the same as your control-read name

$player1 = GUICtrlRead($player1)

will not work more than once

tat-ta-ta-tahhhhh!!!

8)

YES! that is the correct answer it works now.. I thank you very much. Have a great weekend.

Share this post


Link to post
Share on other sites
Valuater

YES! that is the correct answer it works now.. I thank you very much. Have a great weekend.

I'm glad that worked because I really didn't want to get serious and take a fine comb through that script

... and your Welcome

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.