Jump to content

How to close a GUI stuck in a loop?


Recommended Posts

I have an interesting problem where I am trying to close a GUI created in one script through a GUI created in another one, if that makes any sense at all. It's difficult to describe this without posting code, but I think I can create a generic scenario, rather than posting a bunch of worthless code that isn't a part of the problem.

I have two different scripts, and both of which create a GUI. The first GUI is responsible for running the second script and closing, while the secondary GUI simply does an automation inside of a while loop. My problem is that I cannot close the second GUI through any means of the first GUI.

Neither WinKill nor WinClose will work, despite the fact that the window exists and the titles match. Are there any other ways to close a GUI / Window other than the two functions above? Or since it is in a while loop can I not touch it?

Thanks.

Link to comment
Share on other sites

I think u should post the code so we can search for ur problem

Edited by star2

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

Fine, here's the code.

Script 1:

Opt("GUIOnEventMode", 1)

#include <GUIConstants.au3>
#include <String.au3>
#include <Array.au3>
#include <IE.au3>
#include <Misc.au3>

;Information for the main gui edit tab
$Parent_Information = "Panda's *Poke* Utility" & @CRLF & "Version 1.0" & @CRLF & "Designed for Facebook" & @CRLF & " & Internet Explorer " & @CRLF & @CRLF & "thetwistedpanda@gmail.com"

;Declared variables
$IniFile = "PokeTools.ini"
$AllowIniLoading = True
$BackgroundSwitch = 1
$AdvancedSwitch = 1
$ButtonSwitch = 1

;Temporary variables
Global $iCounter = 0, $Counter = 0
Global $UserArray = "", $NameArray = "", $Username = "", $Password = "", $IniDirectory = ""

;Error Checking
;If there is not an ini file, try to locate; If locate fails, write directory in new ini
If (Not FileExists(@WorkingDir & "\" & $IniFile)) Then
    If MsgBox(BitOr(4, 64), "Configuration File Not Found", "Attempt To Locate 'PokeTools.ini'?" & @CRLF & @CRLF & "Note: If this is your first time running the program, please select 'No'") == 6 Then
        $IniDirectory = FileOpenDialog("Looking for 'PokeTools.ini'", @WorkingDir, "Config Files (*.ini)", 3, "PokeTools.ini")
        If StringInStr($IniDirectory, "PokeTools.ini") == 0 Then
            If MsgBox(BitOr(4, 64), "Incorrect Configuration File", "Try Again?") == 6 Then
                Do 
                    $IniDirectory = FileOpenDialog("Looking for 'PokeTools.ini'", @WorkingDir, "Config Files (*.ini)", 3, "PokeTools.ini")
                Until StringInStr($IniDirectory, "PokeTools.ini") <> 0
            EndIf
        EndIf
    EndIf
    IniWrite($IniFile, "Variables", "Directory", @WorkingDir & "\" & $IniFile)
    $AllowIniLoading = False
EndIf

;===========================================================

$GUI_Parent = GUICreate("Facebook  | Poke Utility", 200, 255, ((@DesktopWidth / 2) - 100), ((@DesktopHeight / 2) - 115), BitOr($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), $WS_EX_STATICEDGE)
GUISetBkColor(IniRead($IniFile, "Variables", "Background Color", "0x3b5998"))
GUISetState(@SW_SHOW, $GUI_Parent)  
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")

$Parent_Edit1 = GUICtrlCreateEdit($Parent_Information, 10, 10, 180, 120, BitOr($ES_NOHIDESEL, $ES_READONLY, $ES_CENTER))
    GUICtrlSetColor($Parent_Edit1, 0x000000)
    GUICtrlSetFont($Parent_Edit1, 10, 400, 0, "Comic Sans MS")
    
$Parent_Spacer1 = GUICtrlCreatePic("Spacer.jpg", 10, 140, 180, 1)       
$Parent_Spacer1 = GUICtrlCreatePic("Spacer.jpg", 10, 150, 180, 1)   

$Parent_Combo1 = GUICtrlCreateCombo("Select Friend", 10, 160, 180, 20, BitOr($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
    GUICtrlSetFont($Parent_Combo1, 8, 400, 0, "Comic Sans MS")  
    GUICtrlSetOnEvent($Parent_Combo1, "SaveSelection")
$Parent_Button1 = GUICtrlCreateButton("*Poke*", 115, 190, 75, 25)
    GUICtrlSetFont($Parent_Button1, 10, 400, 0, "Comic Sans MS")    
    GUICtrlSetOnEvent($Parent_Button1, "Poke")
$Parent_Button2 = GUICtrlCreateButton("*Cancel*", 115, 190, 75, 25)
    GUICtrlSetFont($Parent_Button2, 10, 400, 0, "Comic Sans MS")    
    GUICtrlSetOnEvent($Parent_Button2, "CancelPoke")
    GUICtrlSetState($Parent_Button2, $GUI_HIDE)
$Parent_Button3 = GUICtrlCreateButton("*Settings*",115, 220, 75, 25)
    GUICtrlSetFont($Parent_Button3, 10, 400, 0, "Comic Sans MS")
    GUICtrlSetOnEvent($Parent_Button3, "ShowSettings")
$Parent_Radio1 = GUICtrlCreateRadio("Single Poke", 10, 190, 90, 20)
    GUICtrlSetFont($Parent_Radio1, 10, 400, 0, "Comic Sans MS") 
    GUICtrlSetState($Parent_Radio1, IniRead($IniFile, "Variables", "Mode: Single", $GUI_CHECKED))
    GUICtrlSetOnEvent($Parent_Radio1, "GUI_Child1Save")
$Parent_Radio2 = GUICtrlCreateRadio("Auto Poke", 10, 210, 90, 20)
    GUICtrlSetFont($Parent_Radio2, 10, 400, 0, "Comic Sans MS") 
    GUICtrlSetState($Parent_Radio2, IniRead($IniFile, "Variables", "Mode: Auto", $GUI_UNCHECKED))
    GUICtrlSetOnEvent($Parent_Radio2, "GUI_Child1Save")
$Parent_Radio3 = GUICtrlCreateRadio("Poke All", 10, 230, 90, 20)
    GUICtrlSetFont($Parent_Radio3, 10, 400, 0, "Comic Sans MS") 
    GUICtrlSetState($Parent_Radio3, IniRead($IniFile, "Variables", "Mode: Mass", $GUI_UNCHECKED))
    GUICtrlSetOnEvent($Parent_Radio3, "GUI_Child1Save")
;===========================================================

$GUI_Settings = GUICreate("Facebook  | Settings", 200, 255, ((@DesktopWidth / 2) + 105), ((@DesktopHeight / 2) - 115), BitOr($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), $WS_EX_STATICEDGE, $GUI_Parent)
GUISetBkColor(IniRead($IniFile, "Variables", "Background Color", "0x3b5998"))
GUISetState(@SW_HIDE, $GUI_Settings)
GUISwitch($GUI_Settings)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")

$Child_Label1 = GUICtrlCreateLabel("Login Information:", 10, 10, 180, 20)
    GUICtrlSetFont($Child_Label1, 9, 400, 0, "Comic Sans MS")
    GUICtrlSetColor($Child_Label1, 0x000000)
$Child_Input1 = GUICtrlCreateInput(_StringEncrypt(0, IniRead($IniFile, "Login Information", "Email", "11770E850FEAEEB52AC18436F674AFF0F9380D16FB015748CA35364F"), $IniFile, 1), 10, 30, 180, 20, BitOr($ES_WANTRETURN, $ES_NOHIDESEL))
    GUICtrlSetColor($Child_Input1, 0x000000)
    GUICtrlSetFont($Child_Input1, 9, 400, 0, "Comic Sans MS")
$Child_Input2 = GUICtrlCreateInput(_StringEncrypt(0, IniRead($IniFile, "Login Information", "Password", "10710E850EEAE9B32BBD8436F179AFFF"), $IniFile, 1), 10, 60, 180, 20, BitOr($ES_WANTRETURN, $ES_NOHIDESEL, $ES_PASSWORD))
    GUICtrlSetColor($Child_Input2, 0x000000)
    GUICtrlSetFont($Child_Input2, 9, 400, 0, "Comic Sans MS")
$Child_Checkbox1 = GUICtrlCreateCheckbox("Login Automatically", 10, 90, 13, 20)
    GUICtrlSetFont($Child_Checkbox1, 9, 400, 0, "Comic Sans MS")
    GUICtrlSetState($Child_Checkbox1, IniRead($IniFile, "Variables", "Automatic Login", $GUI_UNCHECKED))
    GUICtrlSetOnEvent($Child_Checkbox1, "GUI_Child2Save")       
$Child_Label2 = GUICtrlCreateLabel("Login Automatically", 25, 90, 150, 20)
    GUICtrlSetFont($Child_Label2, 9, 400, 0, "Comic Sans MS")
    GUICtrlSetColor($Child_Label2, 0x000000)    
$Child_Spacer1 = GUICtrlCreatePic("Spacer.jpg", 10, 115, 180, 1)
$Child_Edit1 = GUICtrlCreateEdit("Delay Between Pokes:", 10, 125, 130, 20, BitOr($ES_NOHIDESEL, $ES_READONLY))
    GUICtrlSetFont($Child_Edit1, 8, 400, 0, "Comic Sans MS")    
$Child_Input3 = GUICtrlCreateInput (IniRead($IniFile, "Variables", "Delay Rate", "5"), 150, 125, 39, 20)
    GUICtrlSetFont($Child_Input3, 8, 400, 0, "Comic Sans MS")   
$Child_UpDown1 = GUICtrlCreateUpdown($Child_Input3)
    GUICtrlSetLimit($Child_UpDown1, 60, 1)
    GUICtrlSetOnEvent($Child_UpDown1, "GUI_Child2Save")
$Child_Button1 = GUICtrlCreateButton("Sort Friends", 105, 155, 85, 20)
    GUICtrlSetFont($Child_Button1, 8, 400, 0, "Comic Sans MS")
$Child_Button2 = GUICtrlCreateButton("Load Friends", 10, 155, 85, 20)
    GUICtrlSetFont($Child_Button2, 8, 400, 0, "Comic Sans MS")
    GUICtrlSetOnEvent($Child_Button2, "LoadFriends")
$Child_Button3 = GUICtrlCreateButton("Background Color", 10, 195, 85, 20)
    GUICtrlSetFont($Child_Button3, 8, 400, 0, "Comic Sans MS")
    GUICtrlSetOnEvent($Child_Button3, "Background")
$Child_Input4 = GUICtrlCreateInput (IniRead($IniFile, "Variables", "Background Color", "0x3b5998"), 105, 195, 85, 20, $ES_READONLY)
    GUICtrlSetFont($Child_Input4, 8, 400, 0, "Comic Sans MS")   
$Child_Spacer2 = GUICtrlCreatePic("Spacer.jpg", 10, 185, 180, 1)    
$Child_Button4 = GUICtrlCreateButton("Show HTML", 55, 225, 85, 20)
    GUICtrlSetFont($Child_Button4, 8, 400, 0, "Comic Sans MS")
    GUICtrlSetColor($Child_Button4, 0x000000)       
    GUICtrlSetOnEvent($Child_Button4, "ShowAdvanced")
;===========================================================

$GUI_Advanced = GUICreate("Facebook  | Advanced", 300, 400, ((@DesktopWidth / 2) + 310), ((@DesktopHeight / 2) - 115), BitOr($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), BitOr($WS_EX_TOOLWINDOW, $WS_EX_STATICEDGE), $GUI_Settings)
    GUISetBkColor(IniRead($IniFile, "Variables", "Background Color", "0x3b5998"))
    GUISetState(@SW_HIDE, $GUI_Advanced)
    GUISwitch($GUI_Advanced)

$Advanced_Edit1 = GUICtrlCreateEdit("", 10, 10, 280, 180) 
    GUICtrlSetColor($Advanced_Edit1, 0x3b5998)
    GUICtrlSetFont($Advanced_Edit1, 10, 400, 0, "Comic Sans MS")    
$Advanced_IE = _IECreateEmbedded()
$Advanced_ActiveX = GUICtrlCreateObj($Advanced_IE, 10, 200, 280, 190)   
;===========================================================
    
If $AllowIniLoading == True Then
    $FriendCnt = IniRead($IniFile, "Variables", "Friend Cnt", "")

    Dim $UserArray[$FriendCnt+1]
    Dim $NameArray[$FriendCnt+1]

    For $iCounter = 0 To $FriendCnt
        $UserArray[$iCounter] = IniRead($IniFile, "Facebook Users", $iCounter, "")
        $NameArray[$iCounter] = IniRead($IniFile, "Facebook Names", $iCounter, "")
        GUICtrlSetData($Parent_Combo1, $NameArray[$iCounter])
    Next

    $URL = _IEPropertyGet($Advanced_IE, "locationurl")
    If (Not StringInStr($URL, "facebook.com/login.php")) Then
        _IENavigate($Advanced_IE, "http://www.facebook.com/login.php")
        _IELoadWait($Advanced_IE)
    EndIf

    If IniRead($IniFile, "Variables", "Automatic Login", "") == 1 Then
        $oForm = _IEFormGetCollection($Advanced_IE, 0)
        $FormEmail = _IEFormElementGetCollection($oForm, 3)
        $FormPass = _IEFormElementGetCollection($oForm, 4)
        $FormSubmit = _IEFormElementGetCollection($oForm, 5)
        
        _IEFormElementSetValue($FormEmail, _StringEncrypt(0, IniRead($IniFile, "Login Information", "Email", ""), $IniFile, 1), 0)  
        _IEFormElementSetValue($FormPass, _StringEncrypt(0, IniRead($IniFile, "Login Information", "Password", ""), $IniFile, 1), 0)
        _IEAction($FormSubmit, "click")
    EndIf
EndIf

WinActivate("Facebook  | Poke Utility", "") 

While 1
    Sleep(1000)
WEnd

Func ShowAdvanced()
    If $AdvancedSwitch == 1 Then
        GUISetState(@SW_SHOW, $GUI_Advanced)
        $AdvancedSwitch = $AdvancedSwitch * -1
    Else
        GUISetState(@SW_HIDE, $GUI_Advanced)
        $AdvancedSwitch = $AdvancedSwitch * -1
    EndIf
EndFunc

Func ShowSettings()
    GUISetState(@SW_SHOW, $GUI_Settings)
EndFunc

Func SaveSelection()
    For $iCounter = 0 To IniRead($IniFile, "Variables", "Friend Cnt", "")
        If $NameArray[$iCounter] == GUICtrlRead($Parent_Combo1) Then
            $Counter = $iCounter
            ExitLoop
        EndIf
    Next

    IniWrite($IniFile, "Variables", "Current Name", $NameArray[$Counter])
    IniWrite($IniFile, "Variables", "Current User", $UserArray[$Counter])
EndFunc

Func Background()
    If $BackgroundSwitch == 1 Then
        $BackgroundSwitch = -1
        
        $Color = _ChooseColor (2, GUICtrlRead($Child_Input4), 2)
        While $Color == -1
            $Color = _ChooseColor (2, GUICtrlRead($Child_Input4), 2)
        WEnd
        
        $BackgroundSwitch = 1       
        GUICtrlSetData($Child_Input4, $Color)
        IniWrite($IniFile, "Variables", "Background Color", $Color)
        GUISetBkColor($Color, $GUI_Parent)
        GUISetBkColor($Color, $GUI_Settings)
        GUISetBkColor($Color, $GUI_Advanced)
    EndIf
EndFunc

Func CancelPoke()
    If $ButtonSwitch == -1 Then     
        If WinExists("Facebook  | *Poke*", "") Then
            WinKill("Facebook  | *Poke*", "")
        EndIf
        
        $ButtonSwitch = $ButtonSwitch * -1
        GUICtrlSetState($Parent_Button1, $GUI_SHOW)
        GUICtrlSetState($Parent_Button2, $GUI_HIDE) 
    Else
        $ButtonSwitch = $ButtonSwitch * -1
        GUICtrlSetState($Parent_Button1, $GUI_HIDE)
        GUICtrlSetState($Parent_Button2, $GUI_SHOW) 
    EndIf
EndFunc

Func Poke()
    If $ButtonSwitch == 1 Then      
        If GUICtrlRead($Parent_Combo1) == "Select Friend" Then
            MsgBox(4096, "Error", "You forgot to select a person to poke!")
        Else
            Run("Poke.exe", @WorkingDir)
            $ButtonSwitch = $ButtonSwitch * -1
            GUICtrlSetState($Parent_Button1, $GUI_HIDE)
            GUICtrlSetState($Parent_Button2, $GUI_SHOW) 
        EndIf       
    Else
        $ButtonSwitch = $ButtonSwitch * -1
        GUICtrlSetState($Parent_Button1, $GUI_SHOW)
        GUICtrlSetState($Parent_Button2, $GUI_HIDE)         
    EndIf
EndFunc

;===================
Func LoadFriends()
    $Advanced_IE.navigate("http://msstate.facebook.com/friends.php?")
    _IELoadWait($Advanced_IE)
    
    $Code = _IEPropertyGet($Advanced_IE, "outerhtml")
    GUICtrlSetData($Advanced_Edit1, StringReplace($Code, Chr(34), Chr(39)))

    $UArray = _StringBetween(GuiCtrlRead($Advanced_Edit1), "Editor('", "', ")
    $NArray = _StringBetween(GuiCtrlRead($Advanced_Edit1), "', '", "'); return")
    _CreateArray($NArray, $UArray)
    
    For $iCounter = 0 To $Counter
        GUICtrlSetData($Parent_Combo1, $NameArray[$iCounter])
        IniWrite($IniFile, "Facebook Names", $iCounter, $NameArray[$iCounter])
        IniWrite($IniFile, "Facebook Users", $iCounter, $UserArray[$iCounter])
    Next
EndFunc
;===================
Func _CreateArray(Const ByRef $aArray, Const ByRef $bArray)
    If (Not IsArray($aArray)) Or (Not IsArray($bArray)) Then
        SetError(1)
        Return 0
    EndIf

    For $iCounter = 0 To UBound($aArray) - 1
    Next    

    Dim $UserArray[$iCounter]
    Dim $NameArray[$iCounter]
    
    For $iCounter = 0 To UBound($aArray) - 1
        $NameArray[$iCounter] = StringStripCR($aArray[$iCounter])
        $UserArray[$iCounter] = StringStripCR($bArray[$iCounter])
        $Counter = $iCounter
    Next
    IniWrite($IniFile, "Variables", "Friend Cnt", $Counter)

    SetError(0)
    Return 1
EndFunc
;===================
Func Close()
    If @GUI_WINHANDLE == $GUI_Parent Then
        GUI_ParentSave()
        Exit
    Else
        GUISetState(@SW_HIDE, @GUI_WINHANDLE)
    EndIf
EndFunc
;===================
Func GUI_Child1Save()
    IniWrite($IniFile, "Variables", "Mode: Single", GUICtrlRead($Parent_Radio1))
    IniWrite($IniFile, "Variables", "Mode: Auto", GUICtrlRead($Parent_Radio2))
    IniWrite($IniFile, "Variables", "Mode: Mass", GUICtrlRead($Parent_Radio3))
EndFunc
;===================
Func GUI_Child2Save()
    IniWrite($IniFile, "Variables", "Delay Rate", GUICtrlRead($Child_Input3))   
    IniWrite($IniFile, "Variables", "Automatic Login", GUICtrlRead($Child_Checkbox1))
EndFunc
;===================
Func GUI_ParentSave()
    IniWrite($IniFile, "Login Information", "Password", _StringEncrypt(1, GUICtrlRead($Child_Input2), $IniFile, 1)) 
    IniWrite($IniFile, "Login Information", "Email", _StringEncrypt(1, GUICtrlRead($Child_Input1), $IniFile, 1))
    IniDelete($IniFile, "Variables", "Current Name")
    IniDelete($IniFile, "Variables", "Current User")
EndFunc

Script 2:

Opt("TrayAutoPause", 0)

#include <GUIConstants.au3>
#include <String.au3>
#include <Array.au3>
#include <IE.au3>

If (Not WinExists("Facebook  | Poke Utility")) Then
    MsgBox(4096, "Error", "This is not a stand-alone program. Please use the *Poke* button in the main executable")
    Exit
EndIf

$IniFile = "PokeTools.ini"
;===========================================================

If (Not WinExists("Facebook  | *Poke*")) Then
    $GUI_Special = GUICreate("Facebook  | *Poke*", 300, 200, ((@DesktopWidth / 2) - 100), ((@DesktopHeight / 2) - 115), BitOr($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), BitOr($WS_EX_TOOLWINDOW, $WS_EX_STATICEDGE))
    GUISetBkColor(IniRead($IniFile, "Variables", "Background Color", "0x3b5998"))
    GUISetState(@SW_SHOW, $GUI_Special)
;===========================================================

    $Parent_IE = _IECreateEmbedded()
    $Parent_ActiveX = GUICtrlCreateObj($Parent_IE, 15, 15, 270, 170)
    $Parent_IE.Navigate("http://www.facebook.com/login.php") 

    $Parent_Edit1 = GUICtrlCreateEdit("", 15, 15, 270, 170)
    GUICtrlSetColor($Parent_Edit1, 0x3b5998)
    GUICtrlSetFont($Parent_Edit1, 10, 400, 0, "Comic Sans MS")  
    GUICtrlSetState($Parent_Edit1, $GUI_HIDE)
EndIf

;===========================================================
;Initial Login / Checking===================================
;===========================================================
$URL = _IEPropertyGet($Parent_IE, "locationurl")
If (Not StringInStr($URL, "facebook.com/login.php")) Then
    If (Not StringInStr($URL, "facebook.com/home.php")) Then
        If (Not StringInStr($URL, "facebook.com/poke.php?id=")) Then
            _IENavigate($Parent_IE, "http://www.facebook.com/login.php")
            _IELoadWait($Parent_IE) 
        EndIf
    EndIf
EndIf
$URL = _IEPropertyGet($Parent_IE, "locationurl")
If StringInStr($URL, "facebook.com/login.php") Then
    If IniRead($IniFile, "Variables", "Automatic Login", "") == 1 Then
        $oForm = _IEFormGetCollection($Parent_IE, 0)
        $FormEmail = _IEFormElementGetCollection($oForm, 3)
        $FormPass = _IEFormElementGetCollection($oForm, 4)
        $FormSubmit = _IEFormElementGetCollection($oForm, 5)
        
        _IEFormElementSetValue($FormEmail, _StringEncrypt(0, IniRead($IniFile, "Login Information", "Email", ""), $IniFile, 1), 0)  
        _IEFormElementSetValue($FormPass, _StringEncrypt(0, IniRead($IniFile, "Login Information", "Password", ""), $IniFile, 1), 0)
        _IEAction($FormSubmit, "click")
        _IELoadWait($Parent_IE)
    EndIf
EndIf
    
;===========================================================
;Single Poke================================================
;===========================================================
If IniRead($IniFile, "Variables", "Mode: Single", "") == 1 Then
    $cName = IniRead($IniFile, "Variables", "Current Name", "")
    $cUser = IniRead($IniFile, "Variables", "Current User", "")
        
    $URL = _IEPropertyGet($Parent_IE, "locationurl")
    If (Not StringInStr($URL, "facebook.com/poke.php?id=" & $cUser)) Then
        _IENavigate($Parent_IE, "facebook.com/poke.php?id=" & $cUser & "&pokeback=1")
        _IELoadWait($Parent_IE) 
    EndIf

    If StringInStr($URL, "facebook.com/poke.php?id=" & $cUser) Then
        $Code = _IEPropertyGet($Parent_IE, "outerhtml")
        $Data = GUICtrlSetData($Parent_Edit1, $Code)    
        
        If StringInStr( GUICtrlRead($Data), "has not received your last poke yet.") Then
            _IEAction($Parent_IE, "refresh")
        Else
            $oForm = _IEFormGetCollection($Parent_IE, 1)
            $oSubmit = _IEFormElementGetCollection($oForm, 4)
            _IEAction($oSubmit, "click")
            _IEAction($Parent_IE, "refresh")
        EndIf
    EndIf
;===========================================================
;Mass Poke==================================================
;===========================================================    
ElseIf IniRead($IniFile, "Variables", "Mode: Mass", "") == 1 Then
    
EndIf

While 1
    $msg = GUIGetMsg()
    $cName = IniRead($IniFile, "Variables", "Current Name", "")
    $cUser = IniRead($IniFile, "Variables", "Current User", "")
    
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf

;===========================================================
;Auto Poke==================================================
;===========================================================
    If IniRead($IniFile, "Variables", "Mode: Auto", "") == 1 Then
        $URL = _IEPropertyGet($Parent_IE, "locationurl")
        If (Not StringInStr($URL, "facebook.com/login.php")) Then
            If (Not StringInStr($URL, "facebook.com/home.php")) Then
                If (Not StringInStr($URL, "facebook.com/poke.php?id=")) Then
                    _IENavigate($Parent_IE, "http://www.facebook.com/login.php")
                    _IELoadWait($Parent_IE) 
                EndIf
            EndIf
        EndIf
        
        $URL = _IEPropertyGet($Parent_IE, "locationurl")
        If StringInStr($URL, "facebook.com/login.php") Then
            If IniRead($IniFile, "Variables", "Automatic Login", "") == 1 Then
                $oForm = _IEFormGetCollection($Parent_IE, 0)
                $FormEmail = _IEFormElementGetCollection($oForm, 3)
                $FormPass = _IEFormElementGetCollection($oForm, 4)
                $FormSubmit = _IEFormElementGetCollection($oForm, 5)
                
                _IEFormElementSetValue($FormEmail, _StringEncrypt(0, IniRead($IniFile, "Login Information", "Email", ""), $IniFile, 1), 0)  
                _IEFormElementSetValue($FormPass, _StringEncrypt(0, IniRead($IniFile, "Login Information", "Password", ""), $IniFile, 1), 0)
                _IEAction($FormSubmit, "click")
                _IELoadWait($Parent_IE)
            EndIf
        EndIf       

        $URL = _IEPropertyGet($Parent_IE, "locationurl")
        If (Not StringInStr($URL, "facebook.com/poke.php?id=" & $cUser)) Then
            _IENavigate($Parent_IE, "facebook.com/poke.php?id=" & $cUser & "&pokeback=1", 1)
        EndIf       
                    
        If StringInStr($URL, "facebook.com/poke.php?id=" & $cUser) Then
            $Code = _IEPropertyGet($Parent_IE, "outerhtml")
            $Data = GUICtrlSetData($Parent_Edit1, $Code)    
            
            If StringInStr( GUICtrlRead($Data), "has not received your last poke yet.") Then
                _IEAction($Parent_IE, "refresh")
            Else
                $oForm = _IEFormGetCollection($Parent_IE, 1)
                $oSubmit = _IEFormElementGetCollection($oForm, 4)
                _IEAction($oSubmit, "click")
                _IEAction($Parent_IE, "refresh")
            EndIf
            _IELoadWait($Parent_IE)
        EndIf
    EndIf
WEnd

*Posted updated code for script 2.* I was messing with the latter trying to figure out why it wasn't closing, and it seems that _IELoadWait, and any other pauses I put in script 2 prevents script 1 from killing it. Any ideas?

Edited by thetwistedpanda
Link to comment
Share on other sites

erm..Try ProcessClose() and if not.. then set a hot key in the second, and if not that then..ermm...well, the last thing you shouldn't ever have to is using registry keys, have the first one write it and if the second one pick it up, then it closes itself..

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

erm..Try ProcessClose() and if not.. then set a hot key in the second, and if not that then..ermm...well, the last thing you shouldn't ever have to is using registry keys, have the first one write it and if the second one pick it up, then it closes itself..

I got it to close using ProcessClose(). I had to fiddle with a few things in order for it to work, but atleast now it doesn't wait for pauses in my gui. Thanks.

Link to comment
Share on other sites

Here is an example of my script and how I get out of a loop by returning '' ..........

[F11] is bound to a function that sets $stop2 to 1.

Do
                $tray2 = 1
                If $stop2 = 1 Then Return ''
                $wait3 = 0
                If $once > 0 Then
                    Do
                        Sleep(1000)
                        $wait3 = $wait3 + 1
                    Until $stop2 = 1 OR $wait3 = 15
                EndIf
                ClipPut(" ")
                $n = WinGetTitle("")
                If $stop2 = 1 Then Return ''
                sleep(300)
                If $stop2 = 1 Then Return ''
Edited by Leoj
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...