dersiniar Posted February 11, 2022 Posted February 11, 2022 (edited) Hello.. Here i have this code. Like title says, $count -1 not updating and how i can make exit button to work while code is running, It works after code is done Func _Scraping() Global $oIE = _IECreate("", 0, 0) Local $Count = $i For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) $Count -1 _IE() _CSV() Sleep (500) Next _CloseIE() MsgBox(0, "", "Done") GUICtrlSetData($txt, "") EndFunc Func _IE() $Count -1 _IENavigate($oIE, $line) _IELoadWait($oIE, 2000) $HTML = _IEBodyReadHTML($oIE) $result = _StringBetween($HTML, $PriceDivR, '</span') Global $result2 = $result[1] $result3 = _StringBetween($HTML, $StockDivR, '</span') Global $result4 = $result3[1] GUICtrlSetData($txt, $result2 & " " & $result4 & " " & $Line & " " & $Count & " URL done") EndFunc Edited February 11, 2022 by dersiniar
Solution water Posted February 11, 2022 Solution Posted February 11, 2022 I think this should be: $Count -= 1 ; equal to $Count = $Count - 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
dersiniar Posted February 11, 2022 Author Posted February 11, 2022 15 minutes ago, water said: I think this should be: $Count -= 1 ; equal to $Count = $Count - 1 Thank you, that did the trick. Now only need to figure out how to exit program when code is still running
SOLVE-SMART Posted February 11, 2022 Posted February 11, 2022 Hi @dersiniar, what are you try to achieve? Your posted code is very incomplete and we have to do assumptions. #include-once #include <File.au3> #include <IE.au3> #include <String.au3> Global $Count, $file, $line, $txt, $PriceDivR, $StockDivR Func _Scraping() Global $oIE = _IECreate("", 0, 0) For $i = 1 To _FileCountLines($file) $line = FileReadLine($file, $i) $Count -= 1 ; decrease the count by one _IE() ;~ _CSV() Sleep(500) Next ;~ _CloseIE() MsgBox(0, "", "Done") GUICtrlSetData($txt, "") EndFunc ;==>_Scraping Func _IE() $Count -= 1 ; do you want to decrease the count here too? _IENavigate($oIE, $line) _IELoadWait($oIE, 2000) $HTML = _IEBodyReadHTML($oIE) $result = _StringBetween($HTML, $PriceDivR, '</span') Global $result2 = $result[1] $result3 = _StringBetween($HTML, $StockDivR, '</span') Global $result4 = $result3[1] GUICtrlSetData($txt, $result2 & " " & $result4 & " " & $line & " " & $Count & " URL done") EndFunc ;==>_IE Like @water already said: $Count -= 1 do the job, but the rest of the logic wouldn't properly work. Best regards Sven ________________Stay innovative! ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
dersiniar Posted February 11, 2022 Author Posted February 11, 2022 (edited) 2 minutes ago, SOLVE-SMART said: Hi @dersiniar, what are you try to achieve? Your posted code is very incomplete and we have to do assumptions. #include-once #include <File.au3> #include <IE.au3> #include <String.au3> Global $Count, $file, $line, $txt, $PriceDivR, $StockDivR Func _Scraping() Global $oIE = _IECreate("", 0, 0) For $i = 1 To _FileCountLines($file) $line = FileReadLine($file, $i) $Count -= 1 ; decrease the count by one _IE() ;~ _CSV() Sleep(500) Next ;~ _CloseIE() MsgBox(0, "", "Done") GUICtrlSetData($txt, "") EndFunc ;==>_Scraping Func _IE() $Count -= 1 ; do you want to decrease the count here too? _IENavigate($oIE, $line) _IELoadWait($oIE, 2000) $HTML = _IEBodyReadHTML($oIE) $result = _StringBetween($HTML, $PriceDivR, '</span') Global $result2 = $result[1] $result3 = _StringBetween($HTML, $StockDivR, '</span') Global $result4 = $result3[1] GUICtrlSetData($txt, $result2 & " " & $result4 & " " & $line & " " & $Count & " URL done") EndFunc ;==>_IE Like @water already said: $Count -= 1 do the job, but the rest of the logic wouldn't properly work. Best regards Sven ________________Stay innovative! Everything else works like charm, its just a tiny part of full code. And i got count to work thanks @water Edited February 11, 2022 by dersiniar
SOLVE-SMART Posted February 11, 2022 Posted February 11, 2022 (edited) Hi again, Quote Everything else works like charm If you think so, okay 😁 . expandcollapse popup#include-once #include <File.au3> #include <IE.au3> #include <String.au3> HotKeySet('{F10}', '_exit') Global $Count, $file, $line, $txt, $PriceDivR, $StockDivR Func _Scraping() Global $oIE = _IECreate("", 0, 0) For $i = 1 To _FileCountLines($file) $line = FileReadLine($file, $i) $Count -= 1 ; decrease the count by one _IE() ;~ _CSV() Sleep(500) Next ;~ _CloseIE() MsgBox(0, "", "Done") GUICtrlSetData($txt, "") EndFunc ;==>_Scraping Func _IE() $Count -= 1 ; do you want to decrease the count here too? _IENavigate($oIE, $line) _IELoadWait($oIE, 2000) $HTML = _IEBodyReadHTML($oIE) $result = _StringBetween($HTML, $PriceDivR, '</span') Global $result2 = $result[1] $result3 = _StringBetween($HTML, $StockDivR, '</span') Global $result4 = $result3[1] GUICtrlSetData($txt, $result2 & " " & $result4 & " " & $line & " " & $Count & " URL done") EndFunc ;==>_IE Func _exit() Exit EndFunc One suggestion is to use HotKeySet. In the example code I added this function (_exit). Best regards Sven ________________Stay innovative! Edited February 11, 2022 by SOLVE-SMART ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
dersiniar Posted February 11, 2022 Author Posted February 11, 2022 Just now, SOLVE-SMART said: Hi again, expandcollapse popup#include-once #include <File.au3> #include <IE.au3> #include <String.au3> HotKeySet('{F10}', '_exit') Global $Count, $file, $line, $txt, $PriceDivR, $StockDivR Func _Scraping() Global $oIE = _IECreate("", 0, 0) For $i = 1 To _FileCountLines($file) $line = FileReadLine($file, $i) $Count -= 1 ; decrease the count by one _IE() ;~ _CSV() Sleep(500) Next ;~ _CloseIE() MsgBox(0, "", "Done") GUICtrlSetData($txt, "") EndFunc ;==>_Scraping Func _IE() $Count -= 1 ; do you want to decrease the count here too? _IENavigate($oIE, $line) _IELoadWait($oIE, 2000) $HTML = _IEBodyReadHTML($oIE) $result = _StringBetween($HTML, $PriceDivR, '</span') Global $result2 = $result[1] $result3 = _StringBetween($HTML, $StockDivR, '</span') Global $result4 = $result3[1] GUICtrlSetData($txt, $result2 & " " & $result4 & " " & $line & " " & $Count & " URL done") EndFunc ;==>_IE Func _exit() Exit EndFunc If you think so, okay 😁 . One suggestion is to use HotKeySet. In the example code I added this function (_exit). Best regards Sven ________________Stay innovative! No need to think so i have tested it like 200+ times lol Cant make the button to work? $SimpleGUI = GUICreate("", 300, 220, -1, -1, $WS_BORDER) WinSetTrans($SimpleGUI, "", 250) GUISetBkColor(0x000000) Global $Text = GUICtrlCreateLabel("Scraper", 10, 12, 290, 30, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0xb8b8b8) GUICtrlSetFont(-1, 16) GUICtrlCreateLabel("Made by dersiniar@gmail.com", 10, 40, 280, 30, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetColor(-1, 0xb8b8b8) GUICtrlSetFont(-1, 12) GUICtrlCreateLabel ("", 10,40,280,3, $SS_SUNKEN) $ImportButton = GUICtrlCreateButton("ADD URLs", 18, 70, 125, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xb8b8b8) GUICtrlSetBkColor(-1, 0x545454) $Settings = GUICtrlCreateButton("Settings", 45, 100, 70, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xb8b8b8) GUICtrlSetBkColor(-1, 0x545454) $ExitButton = GUICtrlCreateButton("Exit", 180, 100, 75, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xb8b8b8) GUICtrlSetBkColor(-1, 0x545454) $UpdatetButton = GUICtrlCreateButton("Update", 158, 70, 125, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xb8b8b8) GUICtrlSetBkColor(-1, 0x545454) GUISetState(@SW_Show)
SOLVE-SMART Posted February 11, 2022 Posted February 11, 2022 Hi @dersiniar, without more code, especially your while loop for the GUI event handling, it's just guessing. So please share a bit more 😉 . Best regards Sven ________________Stay innovative! ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
water Posted February 11, 2022 Posted February 11, 2022 Hotkey reacts much faster. As described in the help file "A hotkey-press *typically* interrupts the active AutoIt function/statement and runs its user function" My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted February 11, 2022 Posted February 11, 2022 BTW: When you want to reply to a post, please simply add the text at the end of the thread. Do not use the Quote button as this only clutters the thread. We all know what we have posted before 😉 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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