mcornbill Posted October 21, 2008 Share Posted October 21, 2008 (edited) Hi Guys Firstly I'm very new to this, only installed AutoIT last week but I do have some basic programming skills so not a total noob! I had written a script which worked nicely but in trying to make it more flash it now doesn't work and I didn't save my original - DOH! Here's the script: CODE#include <GuiConstants.au3> #include <GuiCombo.au3> Opt('MustDeclareVars',1) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Dim $Label,$Input,$Btn_Search,$Type1,$Type2,$Site,$Header,$msg,$ret GuiCreate("Live Invoice Header Check", 292, 234) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; If 'X' clicked then close program $Type1 = GUICtrlCreateRadio("Group", 55, 20, 120, 20) GUICtrlSetData($Type1,"Group") $Type2 = GUICtrlCreateRadio("Retail", 190, 20, 120, 20) GUICtrlSetData($Type2,"Retail") GUICtrlSetOnEvent($Type1, "Group") ; If Group radio button checked then run the Group function GUICtrlSetOnEvent($Type2, "Retail") ; If Retail radio button checked then run the Retail function GUISetState(@SW_SHOW) Func Group() GUICtrlCreateLabel ("Select site name/prefix ", 30, 60) $Site = GuiCtrlCreateCombo("", 5, 81, 280, 20) GUICtrlSetData($Site,"Aston|BMW|Cadillac|Citroen|Commercials|Ferrari|Fiat|Ford") EndFunc Func Retail() GUICtrlCreateLabel ("Enter site name/prefix i.e Eastern etc", 30, 60) $Site = GuiCtrlCreateCombo("", 5, 81, 280, 20) GUICtrlSetData($Site,"06ormskirk|abbeygate|adriansmith|aks|wmdunnets|worley|yorkwardrowlatt") EndFunc GUICtrlCreateLabel ("Enter header name from Pinnacle Parameters", 30, 115) $Header = GuiCtrlCreateInput("", 5, 130, 280, 20) GUICtrlSetData($Header,"") $Btn_Search = GuiCtrlCreateButton("Search", 98, 170, 90, 30) GUICtrlCreateLabel ("© 2008 Mark Cornbill", 5, 220) GUICtrlCreateLabel ("Version 1.2", 235, 220) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $Btn_Search checkheader($Site,$Header) EndSelect WEnd Exit Func checkheader($Site,$Header) If $Type1 And BitAND(GUICtrlRead($Type1), $GUI_CHECKED) = $GUI_CHECKED Then Run(@ProgramFilesDir&'\Internet Explorer\iexplore.exe http://'&GUICtrlRead($Site)&'-pinnacle.pendragon.uk.com/global/invoicestyles/'&GUICtrlRead($Header)&'/invoiceheader.xsl') Else Run(@ProgramFilesDir&'\Internet Explorer\iexplore.exe http://'&GUICtrlRead($Site)&'.pinnacledms.net/global/invoicestyles/'&GUICtrlRead($Header)&'/invoiceheader.xsl') EndIf EndFunc Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;and @GUI_WINHANDLE would equal $mainwindow Exit EndFunc Before I messed it up it worked like this: You selected either "Group" or "Retail". You entered the site name i.e "Ford", "Vauxhall" etc for Group or "abbeygate", "adriansmith" etc for Retail. Lastly you entered the invoice header name which is just a string like "AdrianSmithSales". Then the program checked to see what radio button was checked, group or retail, and from this it would fire up Internet Explorer and enter a URL which contained the site name and invoice header name ($Site and $Header). The URL varies slightly depending on if it's a group or retail site. That's it, plain and simple and worked beautifully. I then decided that I wanted to add combo boxes for group and retail with a list of all of the available sites so that the user didn't have to manually enter it. I can't for the life of me get the combo list to change AFTER the group or retail radio button is checked - it always gives the one list. I tried the GUIOnEventMode and now my search button has stopped working altogether! Can anyone help me out, sorry for the war and peace post! Cheers Mark Edited October 21, 2008 by mcornbill Link to comment Share on other sites More sharing options...
Malkey Posted October 21, 2008 Share Posted October 21, 2008 Hi Guys Firstly I'm very new to this, only installed AutoIT last week but I do have some basic programming skills so not a total noob! I had written a script which worked nicely but in trying to make it more flash it now doesn't work and I didn't save my original - DOH! Here's the script: CODE#include <GuiConstants.au3> #include <GuiCombo.au3> Opt('MustDeclareVars',1) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Dim $Label,$Input,$Btn_Search,$Type1,$Type2,$Site,$Header,$msg,$ret GuiCreate("Live Invoice Header Check", 292, 234) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; If 'X' clicked then close program $Type1 = GUICtrlCreateRadio("Group", 55, 20, 120, 20) GUICtrlSetData($Type1,"Group") $Type2 = GUICtrlCreateRadio("Retail", 190, 20, 120, 20) GUICtrlSetData($Type2,"Retail") GUICtrlSetOnEvent($Type1, "Group") ; If Group radio button checked then run the Group function GUICtrlSetOnEvent($Type2, "Retail") ; If Retail radio button checked then run the Retail function GUISetState(@SW_SHOW) Func Group() GUICtrlCreateLabel ("Select site name/prefix ", 30, 60) $Site = GuiCtrlCreateCombo("", 5, 81, 280, 20) GUICtrlSetData($Site,"Aston|BMW|Cadillac|Citroen|Commercials|Ferrari|Fiat|Ford") EndFunc Func Retail() GUICtrlCreateLabel ("Enter site name/prefix i.e Eastern etc", 30, 60) $Site = GuiCtrlCreateCombo("", 5, 81, 280, 20) GUICtrlSetData($Site,"06ormskirk|abbeygate|adriansmith|aks|wmdunnets|worley|yorkwardrowlatt") EndFunc GUICtrlCreateLabel ("Enter header name from Pinnacle Parameters", 30, 115) $Header = GuiCtrlCreateInput("", 5, 130, 280, 20) GUICtrlSetData($Header,"") $Btn_Search = GuiCtrlCreateButton("Search", 98, 170, 90, 30) GUICtrlCreateLabel ("© 2008 Mark Cornbill", 5, 220) GUICtrlCreateLabel ("Version 1.2", 235, 220) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $Btn_Search checkheader($Site,$Header) EndSelect WEnd Exit Func checkheader($Site,$Header) If $Type1 And BitAND(GUICtrlRead($Type1), $GUI_CHECKED) = $GUI_CHECKED Then Run(@ProgramFilesDir&'\Internet Explorer\iexplore.exe http://'&GUICtrlRead($Site)&'-pinnacle.pendragon.uk.com/global/invoicestyles/'&GUICtrlRead($Header)&'/invoiceheader.xsl') Else Run(@ProgramFilesDir&'\Internet Explorer\iexplore.exe http://'&GUICtrlRead($Site)&'.pinnacledms.net/global/invoicestyles/'&GUICtrlRead($Header)&'/invoiceheader.xsl') EndIf EndFunc Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;and @GUI_WINHANDLE would equal $mainwindow Exit EndFunc Before I messed it up it worked like this: You selected either "Group" or "Retail". You entered the site name i.e "Ford", "Vauxhall" etc for Group or "abbeygate", "adriansmith" etc for Retail. Lastly you entered the invoice header name which is just a string like "AdrianSmithSales". Then the program checked to see what radio button was checked, group or retail, and from this it would fire up Internet Explorer and enter a URL which contained the site name and invoice header name ($Site and $Header). The URL varies slightly depending on if it's a group or retail site. That's it, plain and simple and worked beautifully. I then decided that I wanted to add combo boxes for group and retail with a list of all of the available sites so that the user didn't have to manually enter it. I can't for the life of me get the combo list to change AFTER the group or retail radio button is checked - it always gives the one list. I tried the GUIOnEventMode and now my search button has stopped working altogether! Can anyone help me out, sorry for the war and peace post! Cheers Mark Welcome to the Forums. I think this is working ok now. expandcollapse popup#include <GuiConstants.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Dim $Label, $Input, $Btn_Search, $Type1, $Type2, $Site, $Header, $msg, $ret GUICreate("Live Invoice Header Check", 292, 234) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; If 'X' clicked then close program $Type1 = GUICtrlCreateRadio("Group", 55, 20, 120, 20) GUICtrlSetOnEvent($Type1, "Group") ; If Group radio button checked then run the Group function GUICtrlSetData($Type1, "Group") $Type2 = GUICtrlCreateRadio("Retail", 190, 20, 120, 20) GUICtrlSetOnEvent($Type2, "Retail") ; If Retail radio button checked then run the Retail function GUICtrlSetData($Type2, "Retail") $Header = GUICtrlCreateInput("", 5, 130, 280, 20) GUICtrlSetData($Header, "") $Btn_Search = GUICtrlCreateButton("Search", 98, 170, 90, 30) GUICtrlSetOnEvent($Btn_Search, "checkheader") GUICtrlCreateLabel("Enter header name from Pinnacle Parameters", 30, 108) GUICtrlCreateLabel("© 2008 Mark Cornbill", 5, 220) GUICtrlCreateLabel("Version 1.2", 235, 220) GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Exit Func Group() GUICtrlCreateLabel("Select site name/prefix ", 30, 60) GUICtrlDelete($Site) $Site = GUICtrlCreateCombo("", 5, 81, 280, 20) GUICtrlSetData($Site, "Aston|BMW|Cadillac|Citroen|Commercials|Ferrari|Fiat|Ford") EndFunc ;==>Group Func Retail() GUICtrlCreateLabel("Enter site name/prefix i.e Eastern etc", 30, 60) GUICtrlDelete($Site) $Site = GUICtrlCreateCombo("", 5, 81, 280, 20) GUICtrlSetData($Site, "06ormskirk|abbeygate|adriansmith|aks|wmdunnets|worley|yorkwardrowlatt") EndFunc ;==>Retail Func checkheader() If BitAND(GUICtrlRead($Type1), $GUI_CHECKED) = $GUI_CHECKED Then Run(@ProgramFilesDir & '\Internet Explorer\iexplore.exe http://' & GUICtrlRead($Site) & '-pinnacle.pendragon.uk.com/global/invoicestyles/' & GUICtrlRead($Header) & '/invoiceheader.xsl') Else Run(@ProgramFilesDir & '\Internet Explorer\iexplore.exe http://' & GUICtrlRead($Site) & '.pinnacledms.net/global/invoicestyles/' & GUICtrlRead($Header) & '/invoiceheader.xsl') EndIf EndFunc ;==>checkheader Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;and @GUI_WINHANDLE would equal $mainwindow Exit EndFunc ;==>CLOSEClicked Link to comment Share on other sites More sharing options...
mcornbill Posted October 21, 2008 Author Share Posted October 21, 2008 Welcome to the Forums. I think this is working ok now. expandcollapse popup#include <GuiConstants.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Dim $Label, $Input, $Btn_Search, $Type1, $Type2, $Site, $Header, $msg, $ret GUICreate("Live Invoice Header Check", 292, 234) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; If 'X' clicked then close program $Type1 = GUICtrlCreateRadio("Group", 55, 20, 120, 20) GUICtrlSetOnEvent($Type1, "Group") ; If Group radio button checked then run the Group function GUICtrlSetData($Type1, "Group") $Type2 = GUICtrlCreateRadio("Retail", 190, 20, 120, 20) GUICtrlSetOnEvent($Type2, "Retail") ; If Retail radio button checked then run the Retail function GUICtrlSetData($Type2, "Retail") $Header = GUICtrlCreateInput("", 5, 130, 280, 20) GUICtrlSetData($Header, "") $Btn_Search = GUICtrlCreateButton("Search", 98, 170, 90, 30) GUICtrlSetOnEvent($Btn_Search, "checkheader") GUICtrlCreateLabel("Enter header name from Pinnacle Parameters", 30, 108) GUICtrlCreateLabel("© 2008 Mark Cornbill", 5, 220) GUICtrlCreateLabel("Version 1.2", 235, 220) GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Exit Func Group() GUICtrlCreateLabel("Select site name/prefix ", 30, 60) GUICtrlDelete($Site) $Site = GUICtrlCreateCombo("", 5, 81, 280, 20) GUICtrlSetData($Site, "Aston|BMW|Cadillac|Citroen|Commercials|Ferrari|Fiat|Ford") EndFunc ;==>Group Func Retail() GUICtrlCreateLabel("Enter site name/prefix i.e Eastern etc", 30, 60) GUICtrlDelete($Site) $Site = GUICtrlCreateCombo("", 5, 81, 280, 20) GUICtrlSetData($Site, "06ormskirk|abbeygate|adriansmith|aks|wmdunnets|worley|yorkwardrowlatt") EndFunc ;==>Retail Func checkheader() If BitAND(GUICtrlRead($Type1), $GUI_CHECKED) = $GUI_CHECKED Then Run(@ProgramFilesDir & '\Internet Explorer\iexplore.exe http://' & GUICtrlRead($Site) & '-pinnacle.pendragon.uk.com/global/invoicestyles/' & GUICtrlRead($Header) & '/invoiceheader.xsl') Else Run(@ProgramFilesDir & '\Internet Explorer\iexplore.exe http://' & GUICtrlRead($Site) & '.pinnacledms.net/global/invoicestyles/' & GUICtrlRead($Header) & '/invoiceheader.xsl') EndIf EndFunc ;==>checkheader Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;and @GUI_WINHANDLE would equal $mainwindow Exit EndFunc ;==>CLOSEClicked Hi Malkey That's brilliant mate thanks a lot! In the interim I had noticed why the search button had stopped working, I had GUISetOnEvent rather than GUICtrlSetOnEvent. I see that is what you changed also. So I managed to get it all working again apart from I still got just the one list being shown, I'm now going to scrutinise your code to see how you're getting the lists to change based on the radio buttons! Thanks again and what a superb forum Link to comment Share on other sites More sharing options...
mcornbill Posted October 21, 2008 Author Share Posted October 21, 2008 GUICtrlDelete($Site) Sheez that's all it was then! Link to comment Share on other sites More sharing options...
mcornbill Posted October 21, 2008 Author Share Posted October 21, 2008 Ok one more question guys. Is it possible to have the user hit the enter button and for it to search rather than having to mouse click the search button? Cheers Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 21, 2008 Share Posted October 21, 2008 Ok one more question guys. Is it possible to have the user hit the enter button and for it to search rather than having to mouse click the search button?CheersInclude the $BS_DEFPUSHBUTTON style on your search button. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
mcornbill Posted October 21, 2008 Author Share Posted October 21, 2008 Include the $BS_DEFPUSHBUTTON style on your search button. Legendary mate Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now