AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GUI not working

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Jasdeep



Joined: 09 Nov 2009
Posts: 178

PostPosted: Thu Nov 26, 2009 10:55 am    Post subject: GUI not working Reply with quote

hi friends the below code is not giving expected results. if you see when i execute the code it opens up a gui window giving an option to click. when i click that button it proceeds by first getting minimize...but after some execution i try to open another gui window but the problem is that it again opens the first window i dont know why maybe some return problem
below is my code


Code:
Gui, Add, Button, w186 h49,ProductionTest_ETKS4_1_TU6_2; first gui window which gets open
Gui,show
Return

ButtonProductionTest_ETKS4_1_TU6_2: ;when i click the button it proceeds
sleep 500
WinMinimize,Productiontest
sleep 1000
Send !{L}
sleep 500
Send D:\ETASData\ETKControlPanel6.4\ETKS4_1\ETC\ProductionTest_ETKS4_1_TU6_2.etc
sleep 500
Send !{L}
sleep 500
MouseClick,left,56,72
send 225
sleep 500
send !{g}
Return

WinWaitActive CASCON Enable Codes ;now it waits for cascon popup
Send {esc} ;sends esc as soon as detected
WinWaitActive Error
winhide Error ;NOW MY PROGRAM IS ABLE TO RUN TILL HERE BUT IT FAILS TO OPEN THE NEXT NEW GUI WINDOW BELOW AND INSTEAD OF IT OPENS THE FIRST GUI WINDOW ABOVE
Gui, Add, Button, w186 h49,Goodfile
Gui, Add, Button, w186 h49,Badfile
Gui,show
Return

ButtonGoodfile:
FileCopy,D:\Result_1.CAP,C:\Program Files\CAS4WIN\UUTs\TU6_S41\Results\
goto me
Return

ButtonBadfile:
FileCopy,C:\Documents and Settings\jakhangu\Desktop\Result_1.CAP,C:\Program Files\CAS4WIN\UUTs\TU6_S41\Results\
goto me
Return

me:
WinShow Error
send {Enter}
winhide New Autohotkey

Return


[Title edited. Please write descriptive titles for your topics. ~jaco0646]
Back to top
View user's profile Send private message
doyle



Joined: 14 Nov 2007
Posts: 279
Location: London, England

PostPosted: Thu Nov 26, 2009 11:02 am    Post subject: Reply with quote

Quote:
Creating Multiple GUI Windows
For windows other than the first, the window's number is used as a prefix for the special labels mentioned above; for example, 2GuiEscape and 2GuiClose would be the default labels for the second window. To use custom label names, see Gui +Label.

Each script may have up to 99 GUI windows simultaneously. To operate upon a window number other than the default, include a number followed by a colon in front of the sub-command as in these examples:

Gui, 2:Add, Text,, Text for about-box.
Gui, 2:ShowGui 2:Default can be used to avoid the need for the "2:" prefix above. In addition, the prefix is not necessary inside a GUI thread that operates upon the same window number that launched the thread.

Performance might be slightly better for lower window numbers than higher ones.




You either need to destroy the first GUI, or make the second one number 2.

Code:
Gui, 2:Show
Back to top
View user's profile Send private message Visit poster's website
Jasdeep



Joined: 09 Nov 2009
Posts: 178

PostPosted: Thu Nov 26, 2009 11:25 am    Post subject: Reply with quote

thanks brother its really working but i am sorry to say i have encountered one more problem that after showing the second gui when i click the button Goodfile its not exceuting the action related to that button which is described below


Code:
Run C:\ETAS\ETKControlPanel6.4\ETKControlPanel.exe -n
WinWaitActive INCA/MAC
CoordMode,Mouse,Relative
MouseClick,left,395,106
sleep 1000

Gui, Add, Button, w186 h49,ProductionTest_ETKS4_1_TU6_2
Gui, Add, Button, w186 h49,ProductionTest_ETKS4_2C_TU6_x
Gui,show
Return

ButtonProductionTest_ETKS4_1_TU6_2:
sleep 500
WinMinimize,Productiontest
sleep 1000
Send !{L}
sleep 500
Send D:\ETASData\ETKControlPanel6.4\ETKS4_1\ETC\ProductionTest_ETKS4_1_TU6_2.etc
sleep 500
Send !{L}
sleep 500
MouseClick,left,56,72
send 225
sleep 500
send !{g}
WinWaitActive CASCON Enable Codes
Send {esc}
WinWaitActive Error
winhide Error

Gui,2: Add, Button, w186 h49,Goodfile
Gui,2: Add, Button, w186 h49,Badfile
Gui,2:show ;Its showing this GUI but now when i click the button Goodfile its not executing the action related to this button which is shown below
Return

ButtonGoodfile:
FileCopy,D:\Result_1.CAP,C:\Program Files\CAS4WIN\UUTs\TU6_S41\Results\
goto me
Return

ButtonBadfile:
FileCopy,C:\Documents and Settings\jakhangu\Desktop\Result_1.CAP,C:\Program Files\CAS4WIN\UUTs\TU6_S41\Results\
goto me
Return

me:
WinShow Error
send {Enter}
winhide New Autohotkey

Return
Back to top
View user's profile Send private message
doyle



Joined: 14 Nov 2007
Posts: 279
Location: London, England

PostPosted: Thu Nov 26, 2009 11:47 am    Post subject: Reply with quote

You need to give it a gLabel. See red text.

Code:
Run C:\ETAS\ETKControlPanel6.4\ETKControlPanel.exe -n
WinWaitActive INCA/MAC
CoordMode,Mouse,Relative
MouseClick,left,395,106
sleep 1000

Gui, Add, Button, w186 h49,ProductionTest_ETKS4_1_TU6_2
Gui, Add, Button, w186 h49,ProductionTest_ETKS4_2C_TU6_x
Gui,show
Return

ButtonProductionTest_ETKS4_1_TU6_2:
sleep 500
WinMinimize,Productiontest
sleep 1000
Send !{L}
sleep 500
Send D:\ETASData\ETKControlPanel6.4\ETKS4_1\ETC\ProductionTest_ETKS4_1_TU6_2.etc
sleep 500
Send !{L}
sleep 500
MouseClick,left,56,72
send 225
sleep 500
send !{g}
WinWaitActive CASCON Enable Codes
Send {esc}
WinWaitActive Error
winhide Error

Gui,2: Add, Button, gButtonGoodfile w186 h49,Goodfile
Gui,2: Add, Button, gButtonBadfile w186 h49,Badfile
Gui,2:show ;Its showing this GUI but now when i click the button Goodfile its not executing the action related to this button which is shown below
Return

ButtonGoodfile:
FileCopy,D:\Result_1.CAP,C:\Program Files\CAS4WIN\UUTs\TU6_S41\Results\
goto me
Return

ButtonBadfile:
FileCopy,C:\Documents and Settings\jakhangu\Desktop\Result_1.CAP,C:\Program Files\CAS4WIN\UUTs\TU6_S41\Results\
goto me
Return

me:
WinShow Error
send {Enter}
winhide New Autohotkey

Return


Quote:
G: Gosub (g-label). Launches a subroutine automatically when the user clicks or changes a control. Immediately after the letter G, specify the name of the label to execute. gCancel may be specified to perform an implicit Gui Cancel (but if a label named "Cancel" exists in the script, it will be executed instead). The subroutine may consult the following built-in variables: A_Gui, A_GuiControl, A_GuiEvent, and A_EventInfo.
Back to top
View user's profile Send private message Visit poster's website
Jasdeep



Joined: 09 Nov 2009
Posts: 178

PostPosted: Thu Nov 26, 2009 11:53 am    Post subject: Reply with quote

man man man u r jst gr8t thanks a tonnnnnnnnnnnnnnnnnnnnnnnn

well if i make a file called 123.ahk which includes two more file as x.ahk and y.ahk (and both of it contains same label names)and when i run the file 123.ahk it gives error as same lables in both files can we overcome from it? or i have to give different label names in both files???
Back to top
View user's profile Send private message
doyle



Joined: 14 Nov 2007
Posts: 279
Location: London, England

PostPosted: Thu Nov 26, 2009 11:59 am    Post subject: Reply with quote

Jasdeep wrote:
man man man u r jst gr8t thanks a tonnnnnnnnnnnnnnnnnnnnnnnn

well if i make a file called 123.ahk which includes two more file as x.ahk and y.ahk (and both of it contains same label names)and when i run the file 123.ahk it gives error as same lables in both files can we overcome from it? or i have to give different label names in both files???


You will need two different label names in that case.

If you have two label names the same, AHK will not know which one to run, and therefore does not run the script.

Just call them something like ButtonGoodfile123 and ButtonGoodfileA.

Something which is descriptive.

Also, for future use I would try and keep your labels fairly short.

So using BT instead of Button in the label. (i.e BTGoodFile)

But whatever works for you.
Back to top
View user's profile Send private message Visit poster's website
Jasdeep



Joined: 09 Nov 2009
Posts: 178

PostPosted: Thu Nov 26, 2009 1:00 pm    Post subject: Reply with quote

ok by changing labels its working and what i did now is in the file Production i added a file called Persistentadv.ahk and control is sent to that file but after finishing up the task in Persistentadv.ahk i am not getting return control from it in order to continue with working of the current Production file....below is the code:-

;THIS IS THE MAIN PRODUCTION FILE

Code:
#Persistent

Run C:\ETAS\ETKControlPanel6.4\ETKControlPanel.exe -n
WinWaitActive INCA/MAC
CoordMode,Mouse,Relative
MouseClick,left,395,106
sleep 1000

Gui, Add, Button, w186 h49,ProductionTest_ETKS4_1_TU6_2
Gui, Add, Button, w186 h49,ProductionTest_ETKS4_2C_TU6_x
Gui,show
Return

new:
WinRestore Productiontest
sleep 500
Send {Enter}

ButtonProductionTest_ETKS4_1_TU6_2:
If WinExist(Load Batchtest)
{
   Send {Enter}
}
Else
sleep 500
WinMinimize,Productiontest
sleep 1000
Send !{L}
sleep 500
Send D:\ETASData\ETKControlPanel6.4\ETKS4_1\ETC\ProductionTest_ETKS4_1_TU6_2.etc
sleep 500
Send !{L}
sleep 500
MouseClick,left,56,72
send 225
sleep 500
send !{g}
#Include C:\Documents and Settings\jakhangu\Desktop\PersistentAdv1.ahk
Goto new ;I WANT TO GET CONTROL HERE AGAIN
Return

;THIS IS THE SECOND FILE WHICH IS INCLUDED IN THE ABOVE FILE

WinWaitActive CASCON Enable Codes
Send {esc}
WinWaitActive Error
winhide Error

Gui,2: Add, Button,gButtonGoodfile w186 h49,Goodfile
Gui,2: Add, Button,gButtonBadfile w186 h49,Badfile
Gui,2:show
Return

ButtonGoodfile:
FileCopy,D:\Result_1.CAP,C:\Program Files\CAS4WIN\UUTs\TU6_S41\Results\
goto me
Return

ButtonBadfile:
FileCopy,C:\Documents and Settings\jakhangu\Desktop\Result_1.CAP,C:\Program Files\CAS4WIN\UUTs\TU6_S41\Results\
goto me
Return

me:
WinShow Error
send {Enter}
winhide Productiontest
Return

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group