Leaderboard
Popular Content
Showing content with the highest reputation on 09/26/2020 in all areas
-
Then do it in this way: #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <guiconstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiComboBox.au3> #include <File.au3> #include <Array.au3> #include <GuiEdit.au3> #include <MsgBoxConstants.au3> #include <WinAPIShPath.au3> #include <INet.au3> #include <Constants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <Inet.au3> #include <Misc.au3> #include <WinAPIDiag.au3> Opt("GUIOnEventMode", 1) Global $handleGUI = GUICreate("gui", 1250, 900) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetBkColor(0xFFFFFF) Local $idMenu1 = GUICtrlCreateMenu("Menu") Local $idMenu3 = GUICtrlCreateMenu("About") GUICtrlCreateGroup("Option Checker", 960, 20, 220, 200) GUICtrlSetFont(-1, 11, 500) Global $inputfa = GUICtrlCreateInput("aaa", 970, 59, 85, 28) ;input FA GUICtrlSetFont(-1, 12, 700) Global $statusfa = GUICtrlCreateLabel("", 970, 100, 80, 28) ; Valid GUICtrlSetColor(-1, 0x00FF00) ; Green; GUICtrlSetFont(-1, 12, 700) ; Bold Global $fadescription = GUICtrlCreateLabel("", 970, 120, 300, 38) GUICtrlSetFont(-1, 11, 700) ; Bold ;GUICtrlSetFont(-1, 11, 700) Global $checkfa = GUICtrlCreateButton("Check FA", 1070, 59, 95, 30) GUICtrlSetFont(-1, 11, 500) ;GUICtrlSetOnEvent(-1, "checkfagui") GUICtrlSetOnEvent(-1, "Check") Global $sFile = @ScriptDir & "\test.txt" Global $FaFileOpen = FileOpen(@ScriptDir & "\test.txt", 0) ;Global $FaFileRead = FileReadLine($FaFileOpen, 1) GUISetState() While 1 Sleep(20000) WEnd Func Check() local $found=-1 $readinputfa = GUICtrlRead($inputfa) GUICtrlSetState($checkfa, $GUI_HIDE) Global $loadingfa = GUICtrlCreateButton("Loading", 1070, 59, 95, 30) Dim $text If Not _FileReadToArray($sFile, $text) Then MsgBox(4096, "Error", " Error reading text file to Array error:" & @error) Exit EndIf ;_ArrayDisplay($text, "Debug: $text") ; Split lines into 2D array Dim $avIPs[$text[0] + 1][2] = [["col1", "col2"]] ;MsgBox(0,"","" & $text[0] ) For $x = 1 To $text[0] $array = StringSplit($text[$x], "=") If $array[0] = 2 Then $avIPs[$x][0] = StringStripWS($array[1], 3) $avIPs[$x][1] = StringStripWS($array[2], 3) EndIf ConsoleWrite($x & ": " & Chr(34) & $readinputfa & Chr(34) & " = " & Chr(34) & $avIPs[$x][0] & Chr(34) & @CRLF) If $readinputfa = $avIPs[$x][0] Then ConsoleWrite("found" & $avIPs[$x][1] & @CRLF) $found=$x ExitLoop EndIf Next ;_ArrayDisplay($avIPs, "Debug: $avIPs") if $found>-1 then GUICtrlSetData($statusfa, "Valid!") GUICtrlSetColor(-1, 0x00FF00) ; Green; GUICtrlSetFont(-1, 12, 700) ; Bold GUICtrlSetData($fadescription, $avIPs[$found][1]) Else ;ConsoleWrite ("notfound" & $avIPs[$x][1] & @crlf) GUICtrlSetData($statusfa, "Invalid!") GUICtrlSetColor(-1, 0xFFFFFF) ; Green; GUICtrlSetFont(-1, 12, 700) ; Bold ;GUICtrlSetData($fadescription, $avIPs[$x][1]) EndIf GUICtrlSetState($loadingfa, $GUI_HIDE) GUICtrlSetState($checkfa, $GUI_SHOW) EndFunc ;==>Check Func _Exit() FileClose($FaFileOpen) Exit EndFunc ;==>_Exit Edit: Of course, to read in the file and to split the array each time is a bit inefficient, it can be done once (provided that the text file is not changed on the fly). from the Help file:1 point
-
The textfile contains following line: aaa = bbb when you are using the string split method, the aaa has a space after it, so the array gets the "aaa " as a string, which does not match the aaa search. this should work: #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <guiconstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiComboBox.au3> #include <File.au3> #include <Array.au3> #include <GuiEdit.au3> #include <MsgBoxConstants.au3> #include <WinAPIShPath.au3> #include <INet.au3> #include <Constants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <Inet.au3> #include <Misc.au3> #include <WinAPIDiag.au3> Opt("GUIOnEventMode", 1) Global $handleGUI = GUICreate("gui", 1250, 900) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetBkColor(0xFFFFFF) Local $idMenu1 = GUICtrlCreateMenu("Menu") Local $idMenu3 = GUICtrlCreateMenu("About") GUICtrlCreateGroup("Option Checker", 960, 20, 220, 200) GUICtrlSetFont(-1, 11, 500) Global $inputfa = GUICtrlCreateInput("aaa", 970, 59, 85, 28) ;input FA GUICtrlSetFont(-1, 12, 700) Global $statusfa = GUICtrlCreateLabel("", 970, 100, 80, 28) ; Valid GUICtrlSetColor(-1, 0x00FF00) ; Green; GUICtrlSetFont(-1, 12, 700) ; Bold Global $fadescription = GUICtrlCreateLabel("", 970, 120, 300, 38) GUICtrlSetFont(-1, 11, 700) ; Bold ;GUICtrlSetFont(-1, 11, 700) Global $checkfa = GUICtrlCreateButton("Check FA", 1070, 59, 95, 30) GUICtrlSetFont(-1, 11, 500) ;GUICtrlSetOnEvent(-1, "checkfagui") GUICtrlSetOnEvent(-1, "Check") Global $sFile = @ScriptDir & "\test.txt" Global $FaFileOpen = FileOpen(@ScriptDir & "\test.txt", 0) ;Global $FaFileRead = FileReadLine($FaFileOpen, 1) GUISetState() While 1 Sleep(20000) WEnd Func Check() $readinputfa = GUICtrlRead($inputfa) GUICtrlSetState($checkfa, $GUI_HIDE) Global $loadingfa = GUICtrlCreateButton("Loading", 1070, 59, 95, 30) Dim $text If Not _FileReadToArray($sFile, $text) Then MsgBox(4096, "Error", " Error reading text file to Array error:" & @error) Exit EndIf ;_ArrayDisplay($text, "Debug: $text") ; Split lines into 2D array Dim $avIPs[$text[0] + 1][2] = [["col1", "col2"]] ;MsgBox(0,"","" & $text[0] ) For $x = 1 To $text[0] $array = StringSplit($text[$x], "=") If $array[0] = 2 Then $avIPs[$x][0] = StringStripWs($array[1],3) $avIPs[$x][1] = StringStripWs($array[2],3) EndIf ConsoleWrite ( $x & ": " & chr(34) & $readinputfa &chr(34) & " = " &chr(34) & $avIPs[$x][0] &chr(34) & @crlf) If $readinputfa = $avIPs[$x][0] Then ConsoleWrite ("found" & $avIPs[$x][1] & @crlf) GUICtrlSetData($statusfa, "Valid!") GUICtrlSetColor(-1, 0x00FF00) ; Green; GUICtrlSetFont(-1, 12, 700) ; Bold GUICtrlSetData($fadescription, $avIPs[$x][1]) EndIf Next ;_ArrayDisplay($avIPs, "Debug: $avIPs") GUICtrlSetState($loadingfa, $GUI_HIDE) GUICtrlSetState($checkfa, $GUI_SHOW) EndFunc ;==>Check Func _Exit() FileClose($FaFileOpen) Exit EndFunc ;==>_Exit1 point
-
@dragosv6 i would recommend these naming variable practices: $iLineCount - the 'i' is for interger; $sFileName - 's'=string, $hFileOpen - h=handle, a=array, c=control ect... it's difficult to read your code the way it is. are the list in test.txt file created by you or computer generated? either way, it is easier to use IniRead() but you need to add the 'section' tag to test.txt like this [Animals Dictionary] dog = Puppy cat = Kitten [Cars Dictionary] tesla = Model S 3 X Y truck = Cybertruck [EN Dictionary] aaa = a1 bbb = b1 try this #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <guiconstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiComboBox.au3> #include <File.au3> #Include <Array.au3> #include <GuiEdit.au3> #include <MsgBoxConstants.au3> #include <WinAPIShPath.au3> #include <INet.au3> #include <Constants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <Inet.au3> #include <Misc.au3> #include <WinAPIDiag.au3> Opt("GUIOnEventMode", 1) ;~ HotKeySet('{ESC}', '_Exit') Global $sFilePath = @ScriptDir & "\test.txt" ; GUI Global $hGUI = GUICreate("My Dictionary", 1250, 900) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetBkColor(0xFFFFFF) Local $idMenu1 = GUICtrlCreateMenu("Menu") Local $idMenu3 = GUICtrlCreateMenu("About") GUICtrlCreateGroup("Option Checker", 960, 20, 220, 200) GUICtrlSetFont(-1, 11, 500) Global $cUserLookUp = GUICtrlCreateInput("dog", 970, 59, 85, 28) ;input FA GUICtrlSetFont(-1, 12, 700) GUICtrlSetTip(-1, 'Enter term to search') Global $cLookupStatus = GUICtrlCreateLabel("Status", 970, 100, 80, 28) ;display status label ;~ GUICtrlSetColor(-1, 0x00FF00) ; Green; ;~ GUICtrlSetFont(-1, 12, 700) ; Bold GUICtrlSetTip(-1, 'Status') Global $cLookupResult = GUICtrlCreateLabel("Result", 970, 120, 300, 38) ;display result found GUICtrlSetFont(-1, 11, 700) ; Bold ;GUICtrlSetFont(-1, 11, 700) GUICtrlSetTip(-1, 'Result') Global $cBtnSearch = GUICtrlCreateButton("Find", 1070, 59, 95, 30) ;action GUICtrlSetFont(-1, 11, 500) ;GUICtrlSetOnEvent(-1, "checkfagui") GUICtrlSetOnEvent(-1, "_DictionaryFinder") GUISetState() ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; Delete the previous GUIs and all controls. GUIDelete($hGUI) ExitLoop EndSwitch WEnd ; ----------------------- ; e.g dictionary format ; ----------------------- ;~ [Animals Dictionary] ;~ dog = puppy ;~ dat = Kitten ;~ [Cars Dictionary] ;~ tesla = Model S 3 X Y ;~ truck = Cybertruck ;~ [EN Dictionary] ;~ aaa = a1 ;~ bbb = b1 Func _DictionaryFinder() Local $sDictionaryType Local $sw = 1 Switch $sw Case 1 Local $sDictionaryType = "Animals Dictionary" Case 2 Local $sDictionaryType = "Cars Dictionary" Case 3 Local $sDictionaryType = "EN Dictionary" EndSwitch Local $sUserLookupTerm = GUICtrlRead($cUserLookUp) Local $sDefaultValue = "No Search Result Found" Local $sRead = IniRead($sFilePath, $sDictionaryType, $sUserLookupTerm, $sDefaultValue) ;~ If $sRead == $sDefaultValue Then If StringCompare($sRead, $sDefaultValue, $STR_NOCASESENSEBASIC) Then GUICtrlSetData($cLookupStatus,"SUCCESS") GUICtrlSetColor($cLookupStatus, 0x00FF00) ; Green GUICtrlSetFont($cLookupStatus, 12, 700) ; Bold GUICtrlSetData($cLookupResult, $sUserLookupTerm &' = '& $sRead) ;set result Else GUICtrlSetData($cLookupStatus,"FAIL") GUICtrlSetColor($cLookupStatus, 0xff0000) ; red GUICtrlSetFont($cLookupStatus, 12, 700) ; Bold GUICtrlSetData($cLookupResult, $sUserLookupTerm &' = '& $sRead) ;set result EndIf EndFunc ; WARNING THERE ARE LOTS OF PROBLEMS IN THIS FUNCTION - no changes made yet Func _DictionaryFinderXXX() Local $hFileOpen = FileOpen($sFilePath, $FO_READ) Local $sUserLookupTerm = GUICtrlRead($cUserLookUp) GUICtrlSetState($cBtnSearch, $GUI_HIDE) Global $loadingfa = GUICtrlCreateButton("Loading", 1070, 59, 95, 30) Dim $aDictionary If Not _FileReadToArray($sFilePath, $aDictionary) Then MsgBox(4096, "Error", " Error reading text file to Array error:" & @error) Exit EndIf _ArrayDisplay($aDictionary, "Debug: $aDictionary") ; Split lines into 2D array Dim $aSplittedLine[$aDictionary[0] + 1][2] = [["col1", "col2"]] ;MsgBox(0,"","" & $aDictionary[0] ) For $x = 1 To $aDictionary[0] $aLookupWord = StringSplit($aDictionary[$x], "=") If $aLookupWord[0] = 2 Then $aSplittedLine[$x][0] = $aLookupWord[1] $aSplittedLine[$x][1] = $aLookupWord[2] EndIf If $sUserLookupTerm = $aSplittedLine[$x][0] Then GUICtrlSetData($cLookupStatus,"Valid!") GUICtrlSetColor(-1, 0x00FF00) ; Green; GUICtrlSetFont(-1, 12, 700) ; Bold GUICtrlSetData($cLookupResult,$aSplittedLine[$x][1]) GUICtrlSetState($loadingfa, $GUI_HIDE) GUICtrlSetState($cBtnSearch, $GUI_SHOW) EndIf Next _ArrayDisplay($aSplittedLine, "Debug: $aSplittedLine") EndFunc Func _Exit() Exit EndFunc ;==>_Exit1 point
-
Siwa, Here is a very simple script to show you what I suggest might be a good way to proceed. Data is read from Excel and loaded into a ListView - yo ucan have as many items as you want as Windows does all the heavy work of scrolling. Then when you select a line the date from that line is set into the date control - you can do the same thing for any other data on the line if required. Then when the operator has finished setting the new date and inserted something into the edit you can save the new data into the ListView. A final "Save" button will save the new data to Excel - although this could be added to the earlier function if required. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <GuiListView.au3> #include <Date.au3> Global $aNames[100][2] Local $Y, $M, $D ; Simulate reading data from Excel For $i = 0 To UBound($aNames) - 1 $aNames[$i][0] = "Name:A" & $i $aNames[$i][1] = "Name:B" & $i Next Global $aGroupNames[UBound($aNames)][5] $hGUI = GUICreate("My GUI list", 800, 500) $cListView = GUICtrlCreateListView("Name:A|NameB|Date|Label 1|Input|Item 3|Item 4", 10, 10, 780, 300) For $i = 0 To 6 _GUICtrlListView_SetColumnWidth($cListView, $i, 120) Next ; Fill list view from data For $i = 0 To UBound($aNames) - 1 ; Simulate reading datae from Excel $sNewDate = _DateAdd('d', Random(2, 28,1), _NowCalcDate()) GUICtrlCreateListViewItem($aNames[$i][0] & "|" & $aNames[$i][1] & "|" & $sNewDate, $cListView) Next $cDate = GUICtrlCreateDate("", 10, 350, 120, 20) $cSet = GUICtrlCreateButton("Set", 10, 390, 80, 20) $cLabel = GUICtrlCreateLabel("", 100, 390, 80, 20) GUICtrlSetBkColor($cLabel, 0xC4C4C4) $cInput = GUICtrlCreateInput("", 200, 390, 30, 20, BitOR($ES_CENTER, $ES_NUMBER)) $cSave = GUICtrlCreateButton("Save To Excel", 10, 450, 120, 30) GUISetState() ; Windows handler to detect ListView selection change GUIRegisterMsg($WM_Notify, "_WM_Notify") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cSet _Action() Case $cSave MsgBox($MB_SYSTEMMODAL, "Save", "Code to save Excel file") EndSwitch WEnd Func _Action() ; Get index of selected item $iSelected = _GUICtrlListView_GetSelectedIndices($cListView) _GUICtrlListView_SetItemText($cListView, $iSelected, GUICtrlRead($cDate), 2) _GUICtrlListView_SetItemText($cListView, $iSelected, GUICtrlRead($cInput), 4) EndFunc Func _WM_Notify($hWnd, $iMsg, $wParam, $lParam) ; Struct = $tagNMHDR and "int Item;int SubItem" from $tagNMLISTVIEW Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) If @error Then Return Local $hLV = DllStructGetData($tStruct, 1) Local $iItem = DllStructGetData($tStruct, 4) Local $iCode = BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) If $iCode = $LVN_ITEMCHANGED Then ; Read dtae and set into the date control $aContent = _GUICtrlListView_GetItemTextArray($cListView, $iItem) GUICtrlSetData($cDate, $aContent[3]) EndIf EndFunc Does this look useful? M231 point
-
Siwa, Looking at your earlier script (much easier to follow than this one!) I see you were trying to create a series of identical groups which each hold a date control, a button, a label and an edit control. But every other group there is also a block of 28 graphic controls (which I suspect are the root of your problem as they are notoriously resource heavy). I imagine that the user is expected to manipulate each of these controls to set the condition for each of the groups - is that correct? If so, what is the function of the block of graphics as it is only present for every other group? And while the function of the date control and the input seems reasonably clear, what should happen when the button is pressed? A separate function is called? it would greatly help me devise something different to help you if I had a better idea of exactly what is supposed to happen within the script - a simple visual GUI does not offer a lot of guidance! M231 point
-
Siwa, It looks to me as if you are running into the same problem as in your previous script - too many controls in the one GUI. The fact that you are trying to separate them into separate tabs does reduce the total number of controls you are creating. As I mentioned before, I suggest using a simple ListView to display the data with a separate section holding the user-adjustable controls which can then be applied to the ListView contents. I will try and come up with something simple to illustrate this concept. M231 point
-
is this a complete code? there is no while loop CreateGUI() While Sleep(10) WEnd missed closing func Func CreateGUI() ;... EndFunc plus var $Total_people_Groups isn't defined1 point
-
close the file in the function FileClose($file) but not attempt to open and read again when time is up the second time around. should place these in the func $file = FileOpen("c:\hello.txt", 0) $read = FileRead($file)1 point
-
Hi guys, I've spent a couple hours today to understand socks5 proxy and tried to implement connecting to an external proxy through autoit. My goal is to add this function to my IRC client. It's all about learning isn't it ?!? I've got the authentication part working, and I am sending the snippet here thinking it might interest somebody Have fun! Next step, I will be testing some requests to IRC servers, I am also interested into adding SSL support !!! -el tonio ; Socks5 proxy server authentication using the username/password method (0x02) ; Pure AutoIt 3, Authentication to Socks5 proxy server using the username/password method Global Const $AuthNumberOfAuthMethodsSupported = 2 Global Const $AuthMethodNoAuthenticationRequired = 0x00 Global Const $AuthMethodUsernamePassword = 0x02 Local $ProxyHost = "your Socks5 server hostname"; Local $ProxyPort = "your Socks5 server port"; Local $Username = "User name" Local $Password = "Password" TCPStartup() Opt("TCPTimeout", 5000) ; 1. Connect to Proxy Local $socket $socket = TCPConnect(TCPNameToIP($ProxyHost),$ProxyPort) If $socket > 0 Then ConsoleWrite($socket & " Connected..." & @CRLF) ; 2. GREETING the server (Or telling it what Auth Method you support) Local $sReq = Chr("0x05") _ ; Socks version 5 & Chr("2") _ ; 2 auth methods supported & Chr($AuthMethodNoAuthenticationRequired) _ ; No Auth Required method & Chr($AuthMethodUsernamePassword) ; Username/Password method ConsoleWrite("$sReq : " & $sReq & @CRLF) TCPSend($socket, $sReq) Local $sBuff ; Waiting for the server to reply While 1 $sBuff = TCPRecv($socket,6,1) If @error Then ExitLoop If StringLen($sBuff) > 0 Then ExitLoop Sleep(100) WEnd ConsoleWrite(@CRLF & "! Reply: " & $sBuff & @CRLF) If StringRight($sBuff, 2) = "02" Then ; Server chose the username/password method which is GREAT! ; 3. Perform Authentification $sReq = "0x01" _ & StringMid(Binary(StringLen($Username)), 3, 2) _ & StringMid(StringToBinary($Username), 3) _ & StringMid(Binary(StringLen($Password)), 3, 2) _ & StringMid(StringToBinary($Password), 3) ConsoleWrite("$sReq : " & $sReq & @CRLF) TCPSend($socket, $sReq) ; Wait for the Reply ConsoleWrite("Waiting for the reply ... " & @CRLF) While 1 $sBuff = TCPRecv($socket,10,1) If @error Then ExitLoop If StringLen($sBuff) > 0 Then ExitLoop Sleep(100) WEnd ConsoleWrite(@CRLF & "! Reply: " & $sBuff & @CRLF) If StringRight($sBuff, 2) = "00" Then ; Authentication successful ConsoleWrite("Authenticated..." & @CRLF) While 1 ; Now you can work on requests to whatever, from this point the request is similar to Socks4 Sleep(10) WEnd Else ; Authentication failed EndIf Else ; In case the server do not discuss by the book!! EndIf Else ; Connecting error ConsoleWrite("Connecting error " & " - " & @error & @CRLF) EndIf TCPCloseSocket($socket) TCPShutdown() Exit Was helpful to me: https://en.wikipedia.org/wiki/SOCKS#SOCKS5 https://blog.zhaytam.com/2019/11/15/socks5-a-net-core-implementation-from-scratch/1 point
-
GUICtrlCreateUpdown & $GUI_DOCKRIGHT misbehaved
argumentum reacted to mLipok for a topic
To all interested: The issue reported by @argumentum is fixed by @jpm https://www.autoitscript.com/trac/autoit/ticket/3215 The only one thing you should to do is to wait patiently for the fix to be approved and released in one of the next beta or final versions. Please don't ask when it will be, I will answer right away ..... when the right person has enough free time for it.1 point -
set script priority level
krasnoshtan reacted to JLogan3o13 for a topic
This works just fine for me on a compiled script: #include <AutoItConstants.au3> ProcessSetPriority(@ScriptName, $PROCESS_LOW) While 1 Sleep(10) WEnd1 point -
Multiple commands in a line (one liners)
Professor_Bernd reacted to Werty for a topic
BitAND(Consolewrite("A"),Consolewrite("u"),Consolewrite("t"),Consolewrite("o"),Consolewrite("I"),Consolewrite("T"),Consolewrite("3"))1 point