D4rkDr4g0nz Posted June 10, 2013 Share Posted June 10, 2013 (edited) Hi there! I'm currently working on a school project. My entire class is supposed to create something based on Networking. Some decided to make a tiny multiplayer game, others to create a website, another guy is building a Mail server. The best idea gets a prize, though, it must function. I decided to make a proxy. Well, one that you can enable / disable with a klick of a mouse, and I thought of it as another oppurtunity to increase my autoit knowledge and to drag people to this world. well, all goes fine, script works, nice looking window, etc. But then I stumbled across a Un budgeable obstacle, i cannot remove by using google : Activating a Function whenever the Checkbox is checked. Here's the script : While 1 Switch GUIGetMsg() Case $Checkbox1 If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then GUICtrlSetData($Checkbox1, 'Enabled') Else GUICtrlSetData($Checkbox1, 'Disabled') EndIf Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() Exit This was as far as I got with the script. Even if this is finnished, I wont win even in a looong shot. So please don't consider this cheating. Anyone any suggestions? Please help? Thanks in advance ~Daniel. PS. : Func ProxOn() $var = 1 While $var = 1 ... ... WEnd EndFunc ;==>ProxOn Func Proxoff() $var = 0 EndFunc ;==>Proxoff Edited June 10, 2013 by D4rkDr4g0nz Link to comment Share on other sites More sharing options...
water Posted June 10, 2013 Share Posted June 10, 2013 What's the "And" statements after "GUICtrlSetData($Checkbox1, 'Enabled')" for? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
D4rkDr4g0nz Posted June 10, 2013 Author Share Posted June 10, 2013 (edited) Those I added not so long ago, to try and attach the Functions to the "if" statements. you can ignore the "and". EDIT1 On second thought, I'll remove it. Edited June 10, 2013 by D4rkDr4g0nz Link to comment Share on other sites More sharing options...
water Posted June 10, 2013 Share Posted June 10, 2013 To securely test for a checked/unchecked Checkbox use the following code: If BitAnd(GUICtrlRead($Checkbox1), $GUI_CHECKED) = $GUI_CHECKED Then ... What do you want to do with this statement? GUICtrlSetData($Checkbox1, 'Enabled') My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
D4rkDr4g0nz Posted June 10, 2013 Author Share Posted June 10, 2013 (edited) To securely test for a checked/unchecked Checkbox use the following code: If BitAnd(GUICtrlRead($Checkbox1), $GUI_CHECKED) = $GUI_CHECKED Then ... What do you want to do with this statement? GUICtrlSetData($Checkbox1, 'Enabled') Thanks for the tip. And I want to use that statement to indicate if the Checkbox is enabled or not. And if possible, to enable a function. EDIT1 Here is the GUI I suppose, to make it easier : #include <misc.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Form1 = GUICreate("Proxy", 429, 420, 192, 124) GUISetBkColor(0x646464) Global $Checkbox1 = GUICtrlCreateCheckbox("Enable / Disable", 40, 320, 121, 17) Global $Label1 = GUICtrlCreateLabel("use the checkbox to enable / disable the proxy", 0, 384, 422, 17) Global $Button1 = GUICtrlCreateButton("Pointless Button", 168, 312, 75, 25) Global $Label2 = GUICtrlCreateLabel("Warning :", 248, 312, 112, 17) Global $Label3 = GUICtrlCreateLabel("Pointless.", 248, 328, 97, 17) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $CheckBox1 If GUICtrlRead($CheckBox1) = $GUI_CHECKED Then GUICtrlSetData($CheckBox1, 'Enabled') Else GUICtrlSetData($CheckBox1, 'Disabled') EndIf Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() Exit Edited June 10, 2013 by D4rkDr4g0nz Link to comment Share on other sites More sharing options...
D4rkDr4g0nz Posted June 10, 2013 Author Share Posted June 10, 2013 Apologies for the mess in the GUI, accidently gave the non-tidy version of it. It's still the same though. Link to comment Share on other sites More sharing options...
water Posted June 10, 2013 Share Posted June 10, 2013 I suggest to deactivate the button until the checkbox is ticked. You can only click the button = run the function when the user has clicked on the checkbox: #include <misc.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Form1 = GUICreate("Proxy", 429, 420, 192, 124) GUISetBkColor(0x646464) Global $Checkbox1 = GUICtrlCreateCheckbox("Enable / Disable", 40, 320, 121, 17) Global $Label1 = GUICtrlCreateLabel("use the checkbox to enable / disable the proxy", 0, 384, 422, 17) Global $Button1 = GUICtrlCreateButton("Pointless Button", 168, 312, 75, 25) GUICtrlSetState(-1, $GUI_DISABLE) Global $Label2 = GUICtrlCreateLabel("Warning :", 248, 312, 112, 17) Global $Label3 = GUICtrlCreateLabel("Pointless.", 248, 328, 97, 17) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $CheckBox1 If GUICtrlRead($CheckBox1) = $GUI_CHECKED Then GUICtrlSetState($Button1, $GUI_ENABLE) Else GUICtrlSetState($Button1, $GUI_DISABLE) EndIf Case $Button1 Func1() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() Exit Func Func1() MsgBox(0, "Info", "Func1 called") EndFunc My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
D4rkDr4g0nz Posted June 10, 2013 Author Share Posted June 10, 2013 (edited) Uhm, the button is pointless, just there for decoration and a bit of humor, and should have no affect on the program at all. Sorry if that confused you. I am trying to put the entire system on the Checkbox. Example : ---- 1 = Checked 0 = unchecked Checkbox = 1 Run Function Checkbox = 0 End ---- (example is not script-based.) Edited June 10, 2013 by D4rkDr4g0nz Link to comment Share on other sites More sharing options...
BrewManNH Posted June 10, 2013 Share Posted June 10, 2013 Or something like this, just don't put a While loop in the function ProxOn because it will disable your GUI controls until you exit the function. expandcollapse popup#include <misc.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Form1 = GUICreate("Proxy", 429, 420, 192, 124) GUISetBkColor(0x646464) Global $Checkbox1 = GUICtrlCreateCheckbox("Enable / Disable", 40, 320, 121, 17) Global $Label1 = GUICtrlCreateLabel("use the checkbox to enable / disable the proxy", 0, 384, 422, 17) Global $Button1 = GUICtrlCreateButton(" Pointless Button ", 168, 312, 75, 25) Global $Label2 = GUICtrlCreateLabel("Warning :", 248, 312, 112, 17) Global $Label3 = GUICtrlCreateLabel("Pointless.", 248, 328, 97, 17) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $Checkbox1 If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then GUICtrlSetData($Checkbox1, 'Enabled') ProxOn() Else GUICtrlSetData($Checkbox1, 'Disabled') Proxoff() EndIf Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() Exit Func ProxOn() $var = 1 ConsoleWrite('Proxy is on' & @CRLF) EndFunc ;==>ProxOn Func Proxoff() $var = 0 ConsoleWrite('Proxy is off' & @CRLF) EndFunc ;==>Proxoff D4rkDr4g0nz 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
water Posted June 10, 2013 Share Posted June 10, 2013 Where or how do you want to call your function? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
D4rkDr4g0nz Posted June 10, 2013 Author Share Posted June 10, 2013 (edited) You, sir, just completely solved my problem, and i dont think you even knew that you did. If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then GUICtrlSetData($Checkbox1, 'Enabled') ProxOn() Else GUICtrlSetData($Checkbox1, 'Disabled') Proxoff() EndIf That part did it all! The obvious fix, of placing my function name in the If. Sorry for wasting your time with my stupidity, and thankyou, for not being as blind as I am! I do not encounter any problems so far, thankyou for everything, including the head-first dive into my problems. Edited June 10, 2013 by D4rkDr4g0nz Link to comment Share on other sites More sharing options...
D4rkDr4g0nz Posted June 10, 2013 Author Share Posted June 10, 2013 (edited) Oh, I just mis-interpret something. Edit : Thanks Water, for your head-first dive into my problems, and trying to help me! Thanks BrewManNH, for solving my problem! And sorry for the double post. Edited June 10, 2013 by D4rkDr4g0nz Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 10, 2013 Moderators Share Posted June 10, 2013 D4rkDr4g0nz,If you do point your classmates here, please also point them at the Forum rules (there is also a link at bottom right of each page). We would not want them getting off on the wrong foot like someone we could mention, would we? M23 D4rkDr4g0nz 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
D4rkDr4g0nz Posted June 10, 2013 Author Share Posted June 10, 2013 No comment. But yeah, will do! stupid mistake realy, I'm so used to it that every forum has the same rules, that I did not thought of it.Though I had a 100% permission from the flash game's author. He even gave me the color codes Ended up finnishing it without help, still, thanks for helping me to the rules Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 10, 2013 Moderators Share Posted June 10, 2013 D4rkDr4g0nz,No harm done. M23P.S. And it does not matter one whit if the game's author gave you permission - our rules are our rules, not his. D4rkDr4g0nz 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
D4rkDr4g0nz Posted June 10, 2013 Author Share Posted June 10, 2013 I'm glad that I encounter a patient and thoughtfull moderator for once, nice to meet you. - Problem solved, though stuck with another bug, I think I can fix this one. Thanks for the help all. -Daniël 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