UnDesirable Posted August 22, 2009 Share Posted August 22, 2009 hello i have recently downloaded an autoit tutorial from here and have found it really good. I reached the GUI section, made one of the examples which was working fine but when i pressed enter the input wasnt submitted. From here i started searching and found the _ispressed func. here is the script i am working on expandcollapse popup#include <GUIConstantsEx.au3> ;Constants for GUI Events #include <EditConstants.au3> ;Edit constants. Required for the styles we used. ;Declare any variables/opts. Opt("GUIOnEventMode", 1);We need this otherwise our GUI will not be OnEvent Mode. ;Create the GUI $hGUI = GUICreate("Learning to script with AutoIt V3- Example GUI", 400, 300) ;Create a lable ;Below you can see & _. It allows us to split up lines, making it easier to read. $hLabel = GUICtrlCreateLabel("This is a label control. Type text into the Input control" & _ "and press the button to set the text of the edit control. " & _ "Type /SPECIAL in the edit for a special message!", 10, 10, 380, 40) ;Create an input control $hInput = GUICtrlCreateInput("This is an Input Control. Type stuff here!", 10, 50, 380, 20) ;Create an edit control $hEdit = GUICtrlCreateEdit("This is the edit control. We used a style to make it multiline and read-only!!", 10, 80, 380, 170, BitOR($ES_MULTILINE, $ES_READONLY)) ;Create the button $hButton = GUICtrlCreateButton("Press me!", 320, 260, 70, 25) GUICtrlSetOnEvent($hLabel, "LabelFunction") ; Set the label control's function GUICtrlSetOnEvent($hButton, "ButtonFunction") ; The button's function GUISetOnEvent($GUI_EVENT_CLOSE, "ExitGUI") ; What function to call when we try close the GUI ;Show the GUI. We need this line, or our GUI will NOT be displayed! GUISetState(@SW_SHOW) ;Endless While loop to keep the GUI Open While 1 Sleep(10); So we don't use heaps of CPU WEnd Func LabelFunction() MsgBox(0, "Hello!", "We have clicked on the label!"); Say Hello EndFunc ;==>LabelFunction Func ButtonFunction() $read = GUICtrlRead($hInput) ;Check to see if we have /SPECIAL using StringInStr. If StringInStr($read, "/SPECIAL") Then ;We have it, display the message. MsgBox(0, "WOW!", "This is a special message!") Else ;Get Existing Data of edit $read2 = GUICtrlRead($hEdit) $text = $read2 & @CRLF & $read ; Join the existing and the new text seperated by a line. GUICtrlSetData($hEdit, $text) ; Set the edit control to have our new data! GUICtrlSetData($hInput, "");Reset the data of the input. EndIf EndFunc ;==>ButtonFunction Func ExitGui () Exit ; Exit the program EndFunc i hope someone would tell me how to implement a _ispressed func here so that when either the button or enter are pressed the text in the input box is submitted thanks in advance =D Link to comment Share on other sites More sharing options...
CodyBarrett Posted August 22, 2009 Share Posted August 22, 2009 your using Enter? try this in your While... though i havent tested it out...m aybe you can implement the idea into working code While 1 if _ispressed ('0D') and controlgetfocus ($hGui) = 'Edit1' then ButtonFunction () sleep (100) wend [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Yashied Posted August 22, 2009 Share Posted August 22, 2009 expandcollapse popup#include <GUIConstantsEx.au3> ;Constants for GUI Events #include <EditConstants.au3> ;Edit constants. Required for the styles we used. #include <WinAPI.au3> ;Declare any variables/opts. Opt("GUIOnEventMode", 1);We need this otherwise our GUI will not be OnEvent Mode. ;Create the GUI $hGUI = GUICreate("Learning to script with AutoIt V3- Example GUI", 400, 300) ;Create a lable ;Below you can see & _. It allows us to split up lines, making it easier to read. $hLabel = GUICtrlCreateLabel("This is a label control. Type text into the Input control" & _ "and press the button to set the text of the edit control. " & _ "Type /SPECIAL in the edit for a special message!", 10, 10, 380, 40) ;Create an input control $hInput = GUICtrlCreateInput("This is an Input Control. Type stuff here!", 10, 50, 380, 20) ;Create an edit control $hEdit = GUICtrlCreateEdit("This is the edit control. We used a style to make it multiline and read-only!!", 10, 80, 380, 170, BitOR($ES_MULTILINE, $ES_READONLY)) ;Create the button $hButton = GUICtrlCreateButton("Press me!", 320, 260, 70, 25) GUICtrlSetOnEvent($hLabel, "LabelFunction") ; Set the label control's function GUICtrlSetOnEvent($hButton, "ButtonFunction") ; The button's function GUISetOnEvent($GUI_EVENT_CLOSE, "ExitGUI") ; What function to call when we try close the GUI ;Show the GUI. We need this line, or our GUI will NOT be displayed! HotKeySet('{ENTER}', '_Enter') GUISetState(@SW_SHOW) ;Endless While loop to keep the GUI Open While 1 Sleep(10); So we don't use heaps of CPU WEnd Func LabelFunction() MsgBox(0, "Hello!", "We have clicked on the label!"); Say Hello EndFunc ;==>LabelFunction Func ButtonFunction() $read = GUICtrlRead($hInput) ;Check to see if we have /SPECIAL using StringInStr. If StringInStr($read, "/SPECIAL") Then ;We have it, display the message. MsgBox(0, "WOW!", "This is a special message!") Else ;Get Existing Data of edit $read2 = GUICtrlRead($hEdit) $text = $read2 & @CRLF & $read ; Join the existing and the new text seperated by a line. GUICtrlSetData($hEdit, $text) ; Set the edit control to have our new data! GUICtrlSetData($hInput, "");Reset the data of the input. EndIf EndFunc ;==>ButtonFunction Func ExitGui () Exit ; Exit the program EndFunc Func _Enter() If _WinAPI_GetFocus() = GUICtrlGetHandle($hInput) Then ButtonFunction() Return EndIf HotKeySet('{ENTER}') Send('{ENTER}') HotKeySet('{ENTER}', '_Enter') EndFunc My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
UnDesirable Posted August 22, 2009 Author Share Posted August 22, 2009 (edited) hmmmmmmm well i tried it but it keeps telling me _ispressed : undefined function :S Edited August 22, 2009 by UnDesirable Link to comment Share on other sites More sharing options...
CodyBarrett Posted August 22, 2009 Share Posted August 22, 2009 #include <misc.au3> [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
UnDesirable Posted August 22, 2009 Author Share Posted August 22, 2009 OMG wat a silly mistake i have been trying for hours i had it all right jus the #include -.- i hate includes lol ty cody and yashied =D Link to comment Share on other sites More sharing options...
CodyBarrett Posted August 22, 2009 Share Posted August 22, 2009 anytime my friend... [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] 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