Alex8192 Posted August 21, 2009 Share Posted August 21, 2009 I have a gui with a text box and a button, plus a label. The box is the default style, and is intended for a url. The button will take the url and use it with the inetget function to retrieve a file. The destination of the file is hard coded. Problems: 1. The button is sending its message to the gui when I hit tab from the edit box; it does not wait for me to click or hit enter on the button first. 2. I can just hit enter and the button fires, which is fine except that I did not code that functionality. 3. Nothing happens, no matter how many times I click the button (after the first time the button fires) until I change the text in the box. If I type "abc" and hit tab, it tries to get a file at abc. I can hit enter on the button all day, but nothing will happen until I change "abc" do "def", and then tab will try to get a file from def. I am pretty new to autoit, but I know javascript and html very well, as well as php, java, and a little c++. I have not worked much with GUIs before. The code is below. Sorry if the controls' positions are strange; I am blind and use JAWS for Windows to access my computer; I am guessing at the control positions and hoping I get the numbers right. Strange positioning of the controls would not cause the problems I am having, would it?expandcollapse popupOpt("GUICloseOnESC", 1) #include <ButtonConstants.au3> #include <EditConstants.au3> #include <Timers.au3> #include <ComboConstants.au3> #include <GuiComboBox.au3> #include<sound.au3> #include <GUIConstantsEX.au3> #include<misc.au3> #include <GUIConstants.au3> $win=GUICreate("Web", 500, 500) $lbl1=GUICtrlCreateLabel("Enter the URL of a file to retrieve:", 30, 20, 1, 1) $addr=GUICtrlCreateInput("http://", 50, 20, 1, 21) $go=GUICtrlCreateButton("Get Page", 20, 20, 50, 1) GUISetState(@SW_Show) While 1 $msg=GUIGetMsg() Select Case $msg=$addr geturl() Case $msg=$GUI_EVENT_CLOSE close() EndSelect WEnd HotKeySet("{ESC}", "close") #cs This function retrieves a file from the address in the $addr edit box #ce func geturl() $url=GUICtrlRead($addr) if $url == "" Then ;no addr MsgBox(0,"no","no text") Else MsgBox(0, "You typed:", $url);for testing InetGet($url, "c:\prog\autoit\test.html") EndIf EndFunc func close() Exit endFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 21, 2009 Moderators Share Posted August 21, 2009 Alex8192,First, welcome to the AutoIt forums.You were using the Input ID ($addr) as the trigger to run your geturl function. If you replace it with the Button ID ($go) you get the functionality you want:expandcollapse popup#include <EditConstants.au3> #include <Timers.au3> #include <ComboConstants.au3> #include <GuiComboBox.au3> #include<sound.au3> #include <GUIConstantsEX.au3> #include<misc.au3> #include <GUIConstants.au3> $win = GUICreate("Web", 500, 500) $lbl1 = GUICtrlCreateLabel("Enter the URL of a file to retrieve:", 10, 10, 100, 20) $addr = GUICtrlCreateInput("http://", 10, 50, 200, 20) $go = GUICtrlCreateButton("Get Page", 10, 90, 80, 30) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $go geturl() Case $msg = $GUI_EVENT_CLOSE close() EndSelect WEnd HotKeySet("{ESC}", "close") #cs This function retrieves a file from the address in the $addr edit box #ce Func geturl() $url = GUICtrlRead($addr) If $url == "" Then ;no addr MsgBox(0, "no", "no text") Else MsgBox(0, "You typed:", $url);for testing InetGet($url, "c:\prog\autoit\test.html") EndIf EndFunc ;==>geturl Func close() Exit EndFuncThanks for the heads-up about the control positions - I wondered what was going on at first!Any time you want help - you know where we are!M23 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...
Alex8192 Posted August 21, 2009 Author Share Posted August 21, 2009 Alex8192, First, welcome to the AutoIt forums. You were using the Input ID ($addr) as the trigger to run your geturl function. If you replace it with the Button ID ($go) you get the functionality you want: expandcollapse popup#include <EditConstants.au3> #include <Timers.au3> #include <ComboConstants.au3> #include <GuiComboBox.au3> #include<sound.au3> #include <GUIConstantsEX.au3> #include<misc.au3> #include <GUIConstants.au3> $win = GUICreate("Web", 500, 500) $lbl1 = GUICtrlCreateLabel("Enter the URL of a file to retrieve:", 10, 10, 100, 20) $addr = GUICtrlCreateInput("http://", 10, 50, 200, 20) $go = GUICtrlCreateButton("Get Page", 10, 90, 80, 30) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $go geturl() Case $msg = $GUI_EVENT_CLOSE close() EndSelect WEnd HotKeySet("{ESC}", "close") #cs This function retrieves a file from the address in the $addr edit box #ce Func geturl() $url = GUICtrlRead($addr) If $url == "" Then ;no addr MsgBox(0, "no", "no text") Else MsgBox(0, "You typed:", $url);for testing InetGet($url, "c:\prog\autoit\test.html") EndIf EndFunc ;==>geturl Func close() Exit EndFunc Thanks for the heads-up about the control positions - I wondered what was going on at first! Any time you want help - you know where we are! M23 I changed it, and it works!! That was such a stupid mistake to make, but it happens in programming; you see (or hear, in my case) what you expect, but a fresh pair of eyes finds the problem right off. Now for one more problem that no one will probably know about: in my $addr edit box, my screen reader never reacts right. It always says the box is empty, even though I know it is not since I pop up whatever is in the box. The examples in the Autoit folder do not behave like this; Jaws treats them just fine. In the examples, is text always highlighted or something? If so, can I do this? Thanks for the help, and I will have many more questions as I expand this little experiment. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 21, 2009 Moderators Share Posted August 21, 2009 Alex8192,Glad I could help. Seriously, if there is ever anything I can do to help you in your coding, please do not hesitate to ask - either in open forum (so we can help others too) or via PM. I can only vaguely begin to understand what it must mean to code without being able to see the screen or output - so do not apologise for making mistakes which can catch out even the best of us on a bad day! I am only a hobbyist coder who codes AutoIt to keep my mind active in retirement - but I know I can call on certain other more experienced members if we get into waters too deep for my limited skills!As to the new problem - in your original script, the input box was very small (only 1 pixel wide!) so that might have been the problem. I have checked and the text in an input control is always highlighted if you put the required initial text in the creation command. If this causes you (or rather your software) a problem, there are 2 solutions:1. Create the Input with a an empty text string and then use GUICtrlSetData to add the required text. I have tried this and it comes up non-highlighted with the cursor at the end of the text.2. Create the Input with the text as you did before, but then once the GUI is visible use ControlSend to put the cursor at the end of the text. In your case the line would read ControlSend($win, "", $addr, "{End}").See if either of those fixes will help you.M23 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...
Alex8192 Posted August 21, 2009 Author Share Posted August 21, 2009 Alex8192,Glad I could help. Seriously, if there is ever anything I can do to help you in your coding, please do not hesitate to ask - either in open forum (so we can help others too) or via PM. I can only vaguely begin to understand what it must mean to code without being able to see the screen or output - so do not apologise for making mistakes which can catch out even the best of us on a bad day! I am only a hobbyist coder who codes AutoIt to keep my mind active in retirement - but I know I can call on certain other more experienced members if we get into waters too deep for my limited skills!As to the new problem - in your original script, the input box was very small (only 1 pixel wide!) so that might have been the problem. I have checked and the text in an input control is always highlighted if you put the required initial text in the creation command. If this causes you (or rather your software) a problem, there are 2 solutions:1. Create the Input with a an empty text string and then use GUICtrlSetData to add the required text. I have tried this and it comes up non-highlighted with the cursor at the end of the text.2. Create the Input with the text as you did before, but then once the GUI is visible use ControlSend to put the cursor at the end of the text. In your case the line would read ControlSend($win, "", $addr, "{End}").See if either of those fixes will help you.M23Well, I copied the code for an edit box from the encrypt.au3 example file... and now my input box works just as expected! I have no clue what the size or position has to do with it, but I guess it is important for more than just looks. Thanks for your help. Is it possible to make, say, my main gui window black, then each control a different, bright, color? I have a bit of vision, and such a contrast may help me see where things are. Finally, what does the manual mean when it says that the second and third parameters of the GuiCreateCtrlInput() function are top and left? Top and left from what? The top left corner of the main window? Again, I have done a lot of coding, but not in autoit, and not with a gui; I stuck to cmd line or web pages. Thanks! Link to comment Share on other sites More sharing options...
Alex8192 Posted August 21, 2009 Author Share Posted August 21, 2009 Never mind; I have it sorted now, basically. I have a black window and colored gui controls, and I know how hex color codes work (I am glad they switched to rgb since web pages use that and bgr, or whatever it used to be, would have been strange to use). Now to expand the program... which will generate many more questions! Link to comment Share on other sites More sharing options...
CodyBarrett Posted August 22, 2009 Share Posted August 22, 2009 to expand? as in resize? Gui COntrol Styles in the helpfile [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...
Moderators Melba23 Posted August 22, 2009 Moderators Share Posted August 22, 2009 Alex8192,I have no clue what the size or position has to do with it, but I guess it is important for more than just looks.As I mentioned before, the Input box was only 1 pixel wide in your original code (on my screen that is about 1mm) so there was no room for the text to display so that your JAWS software could read it.I must point out that AutoIt is quite sensitive to overlapping controls - it gets confused about which control is being clicked when they do occupy the same bit of screen - so correctly positioning and sizing controls plays an important part in getting a script to work. Often it is a very simple fix - reducing the size of a label or moving a button - although I appreciate that it is not that simple for you. But as I said also said earlier, do not hesitate to ask if you run into problems - you know where we are!M23 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...
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