AutoHotkey Community

It is currently May 27th, 2012, 11:45 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Gui after gosub
PostPosted: June 13th, 2010, 3:01 am 
Offline

Joined: August 8th, 2007, 5:41 am
Posts: 136
Location: Michigan
My script runs fine until I add in a simple "authorization".

Code:
gui, 4:Add, Text,, ATG Username
gui, 4:Add, Edit, vAuthUser,
gui, 4:Add, Text,, ATG Password
Gui, 4:Add, Edit, vAuthPass,
Gui, 4:Add, Button, Default, OK
gui, 4:Show
return

start:
iniRead, Phone, Settings.ini, Phone, 1
if Phone = ERROR
        Phone = 1235551212
Gui, Add, Button, x16 y297 w320 h40 , SaveSearch
Gui, Add, Button, x456 y457 w100 h40 , Help
Gui, Show
return

ButtonSaveSearch:
msgbox SavedSearchWorked
return

ButtonHelp:
msgbox Help Worked

4ButtonOK:
Gui, 4:submit
Gui, 4:Destroy
gosub, start
return


Obviously I took a ton out but the issue is the same. The buttons in the main GUI do not work. If I remove the 4GUI part completely, then those buttons work. What am I doing wrong?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2010, 3:22 am 
Offline

Joined: August 27th, 2009, 1:36 pm
Posts: 296
I found that this works.. it just doesn't like it being GUI under GUI, 4: I guess...

Code:
gui, 4:Add, Text,, ATG Username
gui, 4:Add, Edit, vAuthUser,
gui, 4:Add, Text,, ATG Password
Gui, 4:Add, Edit, vAuthPass,
Gui, 4:Add, Button, Default, OK
gui, 4:Show
return

4ButtonOK:
Gui, 4:submit
Gui, 4:Destroy
gosub, start
Return

start:
iniRead, Phone, Settings.ini, Phone, 1
if Phone = ERROR
        Phone = 1235551212
Gui, 2: Add, Button, x16 y297 w320 h40, SaveSearch
Gui, 2: Add, Button, x456 y457 w100 h40, Help
Gui, 2: Show
return

2ButtonSaveSearch:
msgbox, SavedSearchWorked
return

2ButtonHelp:
msgbox, Help Worked


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2010, 4:11 am 
Offline

Joined: August 8th, 2007, 5:41 am
Posts: 136
Location: Michigan
ok - that worked fine for the example but when I moved my 4Button stuff up in the real code it still did not work. Here is what I have:

Code:
gui, 4:Add, Text,, ATG Username
gui, 4:Add, Edit, vAuthUser,
gui, 4:Add, Text,, ATG Password
Gui, 4:Add, Edit, vAuthPass,
Gui, 4:Add, Button, Default, OK
gui, 4:Show
return

4ButtonOK:
Gui, 4:submit
;msgbox, %AuthUser% `n %AuthPass%
;FileDelete, Auth.txt
;UrlDownloadToFile, http://automatethegame.com/forums/auth.php?user=%AuthUser%&pass=%AuthPass%, Auth.txt
IfNotExist, Auth.txt
   {
   Msgbox, 64, Cartel v1.01, There was a problem connecting to the forum. Try again later.
   ExitApp
   }
FileRead, Auth, Auth.txt
;msgbox %auth%
;FileDelete, Auth.txt
If Auth = 1
   {
   Msgbox, 64, Cartel v1.01, Your authorization info is not valid. You need to be a subscriber to use our applications. Renter your info and try again.
   ExitApp
   }
If Auth != 0
   {
   Msgbox, 64, Cartel v1.01, There was a problem connecting to the forum. Try again later.
   ExitApp
   }
Gui, 4:Destroy
gosub, start
return


start:
iniRead, Phone, Settings.ini, Phone, 1
if Phone = ERROR
        Phone = 1235551212
iniRead, Email, Settings.ini, Email, 1
if Email = ERROR
        Email = Example@example.com
iniread, sleepTime, Settings.ini, SleepTime, 1
if SleepTime = ERROR
        SleepTime := ""
iniread, sleepTemp, Settings.ini, SleepTime, 2
if SleepTemp = ERROR
        SleepTemp = 1 Minute|5 Minutes||15 Minutes|30 Minutes|1 Hour|6 Hours|12 Hours|24 Hours
LOCDDL := ""
iniRead, SavedSearches, CLINFO.ini, 1, 1
if SavedSearches = ERROR
        SavedSearches := ""
;urldownloadtofile, http://www.craigslist.org/about/sites, locations.html
fileread, loc, locations.html
BEG := InStr(loc,"http://geo.craigslist.org/iso/us/al")
BEG -= 10
StringTrimLeft, loc, loc, %BEG%
BEG := InStr(loc, "<b>ca cities</b>")
BEG -= 1
StringLeft, Temp1, loc, %BEG%
BEG := InStr(loc, ">bangladesh</a>")
BEG -= 42
StringTrimLeft, loc, loc, %BEG%
BEG := InStr(loc, "http://amsterdam.craigslist.org/")
BEG -= 9
END := InStr(loc, "</html> ")
END += 7
Temp2 := END-BEG
StringTrimRight, loc, loc, %Temp2%
temp3 = %TEMP1% %loc%
loop
{
        BEG := InStr(temp3, "<a href=")
        if %BEG% = 0
                break
        BEG += 8
        StringTrimLeft, Temp3, Temp3, %BEG%
        END := InStr(temp3, ">")
        END -= 2
        StringLeft, LOCURL, Temp3, %END%
        END += 2
        StringTrimLeft, Temp3, Temp3, %END%
        BEG := InStr(temp3, "</a>")
        BEG -= 1
        StringLeft, LOCName, Temp3, %BEG%
        LOCDDL = %LOCDDL%%LOCName%|
        iniWrite, %LOCURL%, Locations.ini, %LOCName%, 1
}


setSub = Choose Category First
;;;Define categories;;;
Categories = Community|Personals|housing|forsale|Services|jobs|gigs

Community = |activities|artists|childcare|general|groups|pets|events|lost and found|musicians|local news|politics|rideshare|volunteers|classes

personals = |strictly platonic|woman seek woman|woman seeking men|men seeking woman|men seeking men|misc romance|casual encounters|missed connections|rants and raves

housing = |apts/housing|rooms/shared|sublets/temporary|housing wanted|housing swap|vacation rentals|parking/storage|office/commercial|real estate for sale

forsale = |appliances|antiques|barter|bikes|boats|books|business|computer|free|furniture|general|jewelry|materials|rvs|sporting|tickets|tools|wanted|arts+crafts|auto parts|baby+kids|beauty+health|cars+trucks|cds/dvds/vhs|cell phones|clothes+acc|collectibles|electronics|farm+garden|garage sale|household|motorcycles|music instr|photo+video|toys+games|video gaming

services = |beauty|computer|creative|event|financial|legal|lessons|pet|adult|automotive|farm+garden|household|labor/move|skill'd trade|real estate|sm bi ads|therapeutic|travel/vac|write/ed/tr8

jobs = |accounting+finance|admin/office|arch/engineering|art/media/design|biotech/science|business/mgmt|customer service|education|food/bev/hosp|general labor|government|human resources|internet engineers|legal/paralegal|manufacturing|marketing/pr/ad|medical/health|nonprofit sector|real estate|retail/wholesale|sales/bi dev|salon/spa/fitness|security|skilled trade/craft|software/qa/dba|systems/network|technical support|transport|tv/film/video|web/info design|writing/editing|ECT|Part time

gigs = |computer|creative|crew|domestic|event|labor|writing|talent|adult

;;;;;/categories defined
Gui, Font, S36 CRed Bold Underline, Verdana
Gui, Add, Text, x16 y7 w540 h80 +Center, Craigs List Monitor
Gui, Font, ,
Gui, Add, Text, x16 y427 w90 h30 , Email Address
Gui, Add, Edit, x126 y387 w130 h20 vPhone, %Phone%
Gui, Add, Text, x16 y387 w90 h30 , Phone Number
Gui, Add, Edit, x126 y427 w130 h20 vEmail, %Email%
Gui, Add, Button, x16 y467 w400 h30 , Search
Gui, Add, Text, x15 y96 w110 h30 , Location
Gui, Add, DropDownList, x145 y96 w110 vLocation , %LOCDDL%
Gui, Add, Text, x16 y257 w110 h30 , Search Phrase
Gui, Add, Edit, x146 y257 w190 h30 vPhrase,
Gui, Add, Text, x15 y136 w110 h30 , Specific Location
Gui, Add, DropDownList, x146 y137 w110 vSpecific, Choose Location First
;Gui, Add, Text, x346 y97 w210 h20 , Defined Searches
;Gui, Add, Text, x346 y127 w210 h290 , Text
Gui, Add, ListView, x345 y96 w210 h310 gLView Checked , Active|Search Terms
loop, Parse, SavedSearches, |
{
iniRead, Temp1, CLINFO.ini, %A_LoopField%, 1
iniRead, Temp2, CLINFO.ini, %A_LoopField%, 2
LV_Add(Temp1,"" ,Temp2)
}
Gui, Add, Button, x16 y297 w320 h40 , SaveSearch
Gui, Add, Text, x15 y176 w110 h30 , Category
;Gui, Add, DropDownList, x145 y176 w110 vTopCategory gSetCategory , %Categories%
Gui, Add, Text, x15 y216 w110 h30 , Sub-Category
Gui, Add, DropDownList, x145 y216 w110 vSubCategory, Choose Category First
Gui, Add, Button, x456 y457 w100 h40 , Help
Gui, Add, Text, x16 y347 w90 h30 , Search every:
;ui, Add, DropDownList, x126 y347 w130 vSleepTemp gSetTime, %SleepTemp%
; Generated using SmartGUI Creator 4.0
Gui, Show, x196 y163 h509 w580, Craigs List Monitor - By AutomateTheGame.com
Return

ButtonSaveSearch:
msgbox ITS RUNNING SAVE SEARCH
Gui, Submit, NoHide
iniRead, URLLOC, locations.ini, %Specific%, 1
;urldownloadtofile, %URLLOC%, categories.txt
sleep, 1000
fileread, tempcat, categories.txt ;;;Will be the URL to categories
END := InStr(tempcat, SubCategory)
END -= 3
StartPos := END-45
BEG := InStr(tempcat, "a href=",false, startpos)
BEG += 8
Get := END - BEG
StringMid, NewStr, tempcat, %BEG%, %Get%
URLLOC = %URLLOC%search/%NewStr%/
StringREplace, phrase, phrase, %A_Space%, +, All
FinalSearch = %URLLOC%?query=%phrase%
iniWrite, check, CLINFO.ini, %phrase%, 1
iniWrite, %phrase%, CLINFO.ini, %phrase%, 2
iniWrite, %FinalSearch%, CLINFO.ini, %phrase%, 3
if SavedSearches =
{
        iniWrite, %phrase%, CLINFO.ini, 1, 1
}
else
        iniWrite, %SavedSearches%|%phrase%, CLINFO.ini, 1, 1
reload
return

LView:
MsgBox,4,Craigs List Monitor - By AutomateTheGame.com, Do You Want to Delete this search?
ifMsgBox No
        return
iniRead, SavedSearches, CLinfo.ini, 1, 1
loop, Parse, SavedSearches, |   
{
        if A_Index = %A_EventInfo%
        {
                StringReplace, SavedSearches, SavedSearches, %A_LoopField%
            StringReplace, SavedSearches, SavedSearches, ||, |
            StringRight, lastcheck, SavedSearches, 1
            if lastcheck = |
            {
               stringtrimright, SavedSearches, SavedSearches, 1
            }
                IniDelete, CLinfo.ini, %A_LoopField%
                IniWrite, %SavedSearches%, CLInfo.ini, 1, 1
                IniRead, SavedSearches, CLinfo.ini, 1, 1
                StringLeft, temp5, SavedSearches, 1
                if temp5 = |
                {
                        StringReplace, SavedSearches, SavedSearches, |
                        iniWrite, %SavedSearches%, CLInfo.ini, 1, 1
                }
                reload
                break
        }
}
return



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2010, 4:16 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
When a Gui number is not specified, controls are added to the default GUI. In your code the controls are being added to GUI 4.
Code:
gui, 4:Add, Text,, ATG Username
gui, 4:Add, Edit, vAuthUser,
gui, 4:Add, Text,, ATG Password
Gui, 4:Add, Edit, vAuthPass,
Gui, 4:Add, Button, Default, OK
gui, 4:Show
return

start:
MsgBox,,GUI #, % A_GUI
iniRead, Phone, Settings.ini, Phone, 1
if Phone = ERROR
        Phone = 1235551212
Gui, Add, Button, x16 y297 w320 h40 , SaveSearch
Gui, Add, Button, x456 y457 w100 h40 , Help
Gui, Show
return

4ButtonSaveSearch:
msgbox SavedSearchWorked
return

4ButtonHelp:
msgbox Help Worked

4ButtonOK:
Gui, 4:submit
Gui, 4:Destroy
gosub, start
return
Please read my comments regarding the use of Gui, Destroy here: GUI Help? Another Window after first. You could rewrite the code to eliminate the jumping around with GoSub as well.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2010, 7:50 am 
Offline

Joined: August 24th, 2005, 5:29 pm
Posts: 549
Location: Berlin / Germany
... or you just insert
Code:
start:
iniRead, Phone, Settings.ini, Phone, 1
if Phone = ERROR
        Phone = 1235551212
Gui, 1:Default
Gui, Add, Button, x16 y297 w320 h40 , SaveSearch
Gui, Add, Button, x456 y457 w100 h40 , Help
Gui, Show
return

_________________
nick :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2010, 7:57 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
That's why I provided the link to the help file. :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2010, 8:41 am 
Offline

Joined: August 24th, 2005, 5:29 pm
Posts: 549
Location: Berlin / Germany
Sorry, but those interested in AHK will likely search in the help file for this unknown "Default" option, and those only interested in a running skript will likely take the changes without learning anything. And so might others do, stumbling across this thread. IMO, no code is better than suboptimal code in the help section. There are many examples of including ancient code-snippets in new scripts. :wink:

_________________
nick :wink:


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: MSN [Bot] and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group