randrew Posted August 6, 2012 Posted August 6, 2012 hello there, I'm new to autoit and stuck on the script... that's why I'm here to find help here's my part of the script: #include While 1 $sMsg = GUIGetMsg() If $sMsg = $use Then _filewritetoline(@DesktopDir & "\test.txt", 1, GUICtrlRead($use, 0), 1) EndIf If $sMsg = $pas Then _filewritetoline(@DesktopDir & "\test.txt", 2, GUICtrlRead($pas, 0), 1) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Main EndSwitch WEnd the most problem is (when I run the script), everytime I'm typing into the "inputs" for the first time, it runs normally, the file "test.txt" saved as I want, and there are two lines inside it but when I pressing "tab" on my keyboard to go to the next input, it always get buggy, the lines inside "text.txt" is very messy.. sometimes only password is replaced, and sometimes only userID when I try to rewrite the lines inside the file, and run the script again, it backs to normal.. anyone knows how to fix this? I've tried for two days to get way to fix this, but now I'm stuck sorry for my bad english, best regards,
Moderators Melba23 Posted August 6, 2012 Moderators Posted August 6, 2012 randrew,Welcome to the AutoIt forum. It would help if you posted the whole script - otherwise we are only guessing at what might be wrong. When you post it please use Code tags - put [autoit] before and [/autoit] after your posted code. 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
randrew Posted August 6, 2012 Author Posted August 6, 2012 (edited) uppss... I'm sorry here's my whole script: expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <file.au3> #Region ### START Koda GUI section ### Form=c:documents and settingsxtranetdesktopgran vpn.kxf $Main = GUICreate("GRAN VPN", 371, 196, 336, 278) GUISetBkColor(0xFFFBF0) $profile = GUICtrlCreateGroup("Profile", 8, 56, 169, 49) $Profil = GUICtrlCreateCombo("Default", 16, 75, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateGroup("", -99, -99, 1, 1) $server = GUICtrlCreateGroup("Server", 192, 56, 169, 49) $serve = GUICtrlCreateCombo("Canada", 200, 75, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group1 = GUICtrlCreateGroup("Protocol", 8, 107, 169, 41) $ICMP = GUICtrlCreateRadio("ICMP", 16, 123, 49, 17) GUICtrlSetState(-1, $GUI_DISABLE) $UDP = GUICtrlCreateRadio("UDP", 72, 123, 49, 17) GUICtrlSetState(-1, $GUI_DISABLE) $TCP = GUICtrlCreateRadio("TCP", 120, 123, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("Start", 261, 144, 99, 25) $Button2 = GUICtrlCreateButton("Log", 192, 144, 51, 25) $StatusBar1 = _GUICtrlStatusBar_Create($Main) Dim $StatusBar1_PartsWidth[3] = [185, 277, -1] _GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth) _GUICtrlStatusBar_SetText($StatusBar1, "Status: Connected", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Up : 0 KB", 1) _GUICtrlStatusBar_SetText($StatusBar1, "Down : 0 KB", 2) $Button3 = GUICtrlCreateButton("Advanced Settings", 192, 112, 169, 25) $Group2 = GUICtrlCreateGroup("Account Login", 8, 4, 353, 49) $User = GUICtrlCreateLabel("Username", 16, 20, 52, 17) $use = GUICtrlCreateInput("", 72, 20, 105, 21) $Pwd = GUICtrlCreateLabel("Password", 192, 19, 50, 17) $pas = GUICtrlCreateInput("", 248, 17, 105, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $sMsg = GUIGetMsg() If $sMsg = $use Then _filewritetoline(@DesktopDir & "test.txt", 1, GUICtrlRead($use), 1) EndIf If $sMsg = $pas Then _filewritetoline(@DesktopDir & "test.txt", 2, GUICtrlRead($pas), 1) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Main EndSwitch WEnd by the way, I can't edit my previous post, so I write a new one Edited August 6, 2012 by randrew
BrewManNH Posted August 6, 2012 Posted August 6, 2012 Maybe something like this will work for you. While 1 $sMsg = GUIGetMsg() Switch $sMsg Case $Button2 _FileWriteToLine(@DesktopDir & "test.txt", 1, GUICtrlRead($use), 1) _FileWriteToLine(@DesktopDir & "test.txt", 2, GUICtrlRead($pas), 1) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Remember, if the file doesn't exist, _FileWriteToLine won't create it. 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
Moderators Melba23 Posted August 6, 2012 Moderators Posted August 6, 2012 randrew,I can't edit my previous postYou need a minimum of 5 posts to get "Edit" permission on your posts - the button will appear at bottom-right when the mouse cursor is over the post. 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
randrew Posted August 6, 2012 Author Posted August 6, 2012 Maybe something like this will work for you. While 1 $sMsg = GUIGetMsg() Switch $sMsg Case $Button2 _FileWriteToLine(@DesktopDir & "\test.txt", 1, GUICtrlRead($use), 1) _FileWriteToLine(@DesktopDir & "\test.txt", 2, GUICtrlRead($pas), 1) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Remember, if the file doesn't exist, _FileWriteToLine won't create it. well, this script seems better now.. the line is writen correctly as I want.. but i still find a buggy part here.. when I click on $button2, it doesn't always save the file, sometimes I need to click the button twice or more to get it saved.. I'm still trying, gonna post an update if I can fix this.. but I still need some suggestions.. randrew, You need a minimum of 5 posts to get "Edit" permission on your posts - the button will appear at bottom-right when the mouse cursor is over the post. M23 ok I get it
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