AntiVirus Posted June 28, 2008 Share Posted June 28, 2008 I just started scripting in autoit and want to make a simple gui program that opens up sites that I need in firefox. I made the gui and the checkboxes and the button. The checkboxes look like this. I am using other sites but google as example. $google=GuiCtrlCreateCheckbox("Google",etc) The checkboxes work fine and I made a button at the bottom which looks like this. $button=GuiCtrlCreateButton("go",etc) The "etc" of course is the positioning. I want to make it so that what ever boxes I have checked ( for example $google ) work after hitting the button. I got the GuiGetMsg feature implemented and some code written but don't understand how I can read which boxes are checked after hitting go and then be able to run a function ( lets say Firefox() ) to open those sites. Do I need a function? Do I have to set a certain value for each checkbox or did I already do that? A little confused. I used to code in BASIC before but its very rusty. Link to comment Share on other sites More sharing options...
tlokz Posted June 28, 2008 Share Posted June 28, 2008 (edited) try this: Global $google, $google2;have to declare the $google var because it will end up with data, and $google2 to handle it $button = GuiCtrlCreateButton("go", etc);create the button of course GUICtrlSetOnEvent(-1, "_go");will tell it what func to call when pushed $google = GuiCtrlCreateCheckbox("Google", etc);create the checkbox of course Func _go();func called by the button "go" Local $google2 = GUICtrlRead($google);temp var to find out if checked or not If $google2 = $GUI_CHECKED Then;if its checked $google2 = 1;set $google2 to 1 Else;if not check $google2 = 0;set $google2 to 0 EndIf ;now do what ever you want and google = 1 if check and 0 if not checked EndFunc without the help comments in there: Global $google, $google2 $button = GuiCtrlCreateButton("go", etc) GUICtrlSetOnEvent(-1, "_go") $google = GuiCtrlCreateCheckbox("Google", etc) Func _go() Local $google2 = GUICtrlRead($google) If $google2 = $GUI_CHECKED Then $google2 = 1 Else $google2 = 0 EndIf EndFunc Edited June 28, 2008 by tlokz Link to comment Share on other sites More sharing options...
goldenix Posted June 28, 2008 Share Posted June 28, 2008 (edited) the easiest way: just change this to ShellExecute('My firefox path') Opt("GUIOnEventMode", 1) ; Change to OnEvent mode #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 335, 286, 193, 115) $Button1 = GUICtrlCreateButton("Button1", 144, 152, 75, 25, 0) $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 120, 88, 97, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;~ GUI events ;~ =================================================================== GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUICtrlSetOnEvent($Button1, "_My_Function") Func _My_Function() If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then _Go_babe() EndFunc Func _Go_babe() ShellExecute('D:\portable proggies\FirefoxPortable\FirefoxPortable.exe') EndFunc Func CLOSEClicked() Exit EndFunc while 1 sleep(100) ;Keep yourcode alive WEnd Edited June 28, 2008 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] 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