Astarius Posted March 29, 2015 Share Posted March 29, 2015 Hi all, I´m new to AutoIT so you can imagine, that I know very little about how the functions work in detail. I have the problem that the StringInStr function when searching for a string in the sourcecode of different webpages returns the wrong position of the searched string. I know, that the sourcecode is tens of thousands characters long and the searched string is about in the middle, but the function returns only 28. Also StringLen for example returns about 33000, but i know the sourcecode is much longer. Please note, that the pages have a similar structure only with different titles etc. and for the most pages my script works exactly as intended. Is there some kind of length limitation of the source for these functions to show the right numbers (because the count maybe begins from the start at a certain point)? Thank you in advance for your help. Link to comment Share on other sites More sharing options...
SadBunny Posted March 29, 2015 Share Posted March 29, 2015 You can specify where the search starts or how many characters need to be searched by using the fifth and sixth parameters. See the helpfile for StringInStr for more information. If you do not use those, you shouldn't run into limits any time soon. Without more information it's impossible to give more support. Please show what you have coded so people here can offer suggestions. The best thing would be an actual example of a string search that goes wrong including the string in which you are searching. Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Bowmore Posted March 29, 2015 Share Posted March 29, 2015 I've never had any problems with StringInStr() not returning the expected result. What is the string you are searching for and what is the string you are searching? Without this information no one is going to be able to offer you any help/ "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
guinness Posted March 29, 2015 Share Posted March 29, 2015 No issue with latest version of AutoIt. #include <MsgBoxConstants.au3> MsgBox($MB_SYSTEMMODAL, '', StringInStr('Testing if StringInStr() is broken', 'if')) ; Should be 9. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Astarius Posted March 29, 2015 Author Share Posted March 29, 2015 Here is the reading part of my script so far: expandcollapse popup#include <INet.au3> #include <Misc.au3> #include <Excel.au3> Opt ("WinTitleMatchMode", 2) While 1 Do Sleep(1) Until _IsPressed("12") and _IsPressed("44") ;12 for Alt, 44 for D --> marks the link in the current tab Send( "^c") If WinExists ( "Mods.xls", "") = 1 Then WinActivate ( "Mods.xls", "") WinWaitActive( "Mods.xls", "") Else Local $oExcel = _Excel_Open() Local $sWorkbook = @DesktopDir & "\Mods.xlsx" Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook, Default, Default, True) WinActivate ( "Mods.xls", "") WinWaitActive( "Mods.xls", "") EndIf Local $sURL = ClipGet() Local $sSource = _INetGetSource ( $sURL,True ) Local $iLength = StringLen ( $sSource) MsgBox ( 0, "Length, String($iLength)) Local $sSearch1 = '<span class="header-name">' Local $iPos1 = StringInStr ( $sSource, $sSearch1, 0, 1) + StringLen ( $sSearch1 ) MsgBox ( 0, "Position 1", String($iPos1)) Local $sSearch2 = "</span>" Local $iPos2 = StringInStr ( $sSource, $sSearch2, 0, 1, $iPos1) MsgBox ( 0, "Position 2", String($iPos2)) Local $sModName = StringMid ( $sSource, $iPos1, $iPos2 - $iPos1 ) MsgBox ( 0, "Modname alt", $sModName) wEnd The final aim is to write different infos regarding skyrim modifications from http://www.nexusmods.com/(for example the mod name in this case) into an excel document. Here two example links to the source codes of two modpages: view-source:http://www.nexusmods.com/skyrim/mods/39870/? for this site, the function works view-source:http://www.nexusmods.com/skyrim/mods/12273/? for this site, it doesn´t work Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 29, 2015 Moderators Share Posted March 29, 2015 Astarius,Welcome to the AutoIt forum. Unfortunately you appear to have missed the >Forum rules on your way in. Please read them now (there is also a link at bottom right of each page) - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. See you soon with a legitimate question I hope. 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