John117 Posted July 10, 2007 Share Posted July 10, 2007 I have the following code and would like the input box to clear each time it is selected . . . Can Anyone help with this? CODE#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=D:\Program Files\AutoIt3\Icons\iVista_Pack\ICO\Programs\MSN Messenger.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiConstants.au3> ; make sure net send is running RunWait("net start messenger","",@SW_HIDE) ; GUI GuiCreate("My Messenger", 250, 400) GuiSetIcon(@SystemDir & "\mspaint.exe", 0) ; MENU GuiCtrlCreateMenu("Menu&One") GuiCtrlCreateMenu("Menu&Two") GuiCtrlCreateMenu("MenuTh&ree") GuiCtrlCreateMenu("Menu&Four") GUICtrlCreateLabel("My Messenger", 90, 10) ; INPUT $input = GuiCtrlCreateInput("Type Message Here", 10, 30, 230, 60) Dim $buttons[8]; <- make array to store buttons. In this way you can easily add as many buttons as you want without having to create functions for it $buttons[0] = GuiCtrlCreateButton("HATCHEDA", 10, 100, 100, 30) $buttons[1] = GuiCtrlCreateButton("SCHNEINI", 140, 100, 100, 30) $buttons[2] = GuiCtrlCreateButton("CROWEBRA", 10, 140, 100, 30) $buttons[3] = GuiCtrlCreateButton("BENTONRO", 140, 140, 100, 30) $buttons[4] = GuiCtrlCreateButton("GORDONJ2", 10, 180, 100, 30) $buttons[5] = GuiCtrlCreateButton("ERFORDTR", 140, 180, 100, 30) $buttons[6] = GuiCtrlCreateButton("LIVINGJA", 10, 220, 100, 30) $buttons[7] = GuiCtrlCreateButton("CHARTRTY", 140, 220, 100, 30) ; GUI MESSAGE LOOP GuiSetState() While 1 $msg = GuiGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit For $buttonLooper In $buttons; <- /edit: $buttonLooper will contain consecutively all array elements (buttons) in $buttons, so you can do with one function total instead of one function per button If $msg = $buttonLooper Then Run("net send "&GUICtrlRead($buttonLooper)&" "&GUICtrlRead($input), "", @SW_HIDE) ;MsgBox(0,"test","message to "&GUICtrlRead($buttonLooper)&": "&GUICtrlRead($input)) EndIf Next WEnd Link to comment Share on other sites More sharing options...
eynstyne Posted July 10, 2007 Share Posted July 10, 2007 add an elseif $msg = $input then Guictrlsetdata($input,"") within the if and endif statements F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent] Link to comment Share on other sites More sharing options...
DW1 Posted July 10, 2007 Share Posted July 10, 2007 (edited) Damn I posted at the same time... ALSO, Im sure you should look into this and you can get it from there: ControlGetFocus His was better Edited July 10, 2007 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
eynstyne Posted July 10, 2007 Share Posted July 10, 2007 (edited) forget that last suggestion. That was winging it and it won't work. This might While 1 $cursorinfo = GuigetCursorInfo($Window) if $cursorinfo[4] = $input then if $cursorinfo[2] = 1 then guictrlsetdata($input,"") endif endif Wend Edited July 10, 2007 by eynstyne F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent] Link to comment Share on other sites More sharing options...
John117 Posted July 10, 2007 Author Share Posted July 10, 2007 Which last post? yours or the one below? Also, can you show me getfocus in the code? I want to simply click the input box and have it clear so that I may type with out deleting first . . . then be able to click again, and it clear again, before I send another message. But only clear when I click\select\activate the input box :-) Thanks! Link to comment Share on other sites More sharing options...
DW1 Posted July 10, 2007 Share Posted July 10, 2007 (edited) which wont work? I think mine. Cuase it will just keep clearing if you are in focus, his will work I am pretty sure. Edited July 10, 2007 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
eynstyne Posted July 10, 2007 Share Posted July 10, 2007 forget my last suggestion F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent] Link to comment Share on other sites More sharing options...
John117 Posted July 10, 2007 Author Share Posted July 10, 2007 His I tried, I couldn't get it to work. -Perhaps I was adding it incorrectly? Kept giving errors Link to comment Share on other sites More sharing options...
eynstyne Posted July 10, 2007 Share Posted July 10, 2007 in order for it to work, you must have a variable for GuiCreate $window = Guicreate() F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent] Link to comment Share on other sites More sharing options...
John117 Posted July 10, 2007 Author Share Posted July 10, 2007 Sorry, was talking about trying your first post now trying this and nothing. What have I added incorrectly? Please correct so that I can see it ;-) #include <GuiConstants.au3> ; make sure net send is running RunWait("net start messenger","",@SW_HIDE) $window = Guicreate("My Messenger", 250, 400) ; GUI GuiSetIcon(@SystemDir & "\mspaint.exe", 0) ; MENU GuiCtrlCreateMenu("Menu&One") GuiCtrlCreateMenu("Menu&Two") GuiCtrlCreateMenu("MenuTh&ree") GuiCtrlCreateMenu("Menu&Four") GUICtrlCreateLabel("My Messenger", 90, 10) ; INPUT $input = GuiCtrlCreateInput("Type Message Here", 10, 30, 230, 60) Dim $buttons[8]; <- make array to store buttons. In this way you can easily add as many buttons as you want without having to create functions for it $buttons[0] = GuiCtrlCreateButton("HATCHEDA", 10, 100, 100, 30) $buttons[1] = GuiCtrlCreateButton("SCHNEINI", 140, 100, 100, 30) $buttons[2] = GuiCtrlCreateButton("CROWEBRA", 10, 140, 100, 30) $buttons[3] = GuiCtrlCreateButton("BENTONRO", 140, 140, 100, 30) $buttons[4] = GuiCtrlCreateButton("GORDONJ2", 10, 180, 100, 30) $buttons[5] = GuiCtrlCreateButton("ERFORDTR", 140, 180, 100, 30) $buttons[6] = GuiCtrlCreateButton("LIVINGJA", 10, 220, 100, 30) $buttons[7] = GuiCtrlCreateButton("CHARTRTY", 140, 220, 100, 30) ; GUI MESSAGE LOOP GuiSetState() While 1 $msg = GuiGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit For $buttonLooper In $buttons; <- /edit: $buttonLooper will contain consecutively all array elements (buttons) in $buttons, so you can do with one function total instead of one function per button If $msg = $buttonLooper Then Run("net send "&GUICtrlRead($buttonLooper)&" "&GUICtrlRead($input), "", @SW_HIDE) ;MsgBox(0,"test","message to "&GUICtrlRead($buttonLooper)&": "&GUICtrlRead($input)) EndIf Next WEnd While 1 $cursorinfo = GuigetCursorInfo($Window) if $cursorinfo[4] = $input then if $cursorinfo[2] = 1 then guictrlsetdata($input,"") endif endif Wend Link to comment Share on other sites More sharing options...
eynstyne Posted July 10, 2007 Share Posted July 10, 2007 Don't add another while loop! Just take my code and put it in yours 1 line after the while 1 statement F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent] Link to comment Share on other sites More sharing options...
John117 Posted July 10, 2007 Author Share Posted July 10, 2007 Got it! Thanks! 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