I'm writing a script that interacts with a webpage.
The contents of the webpage depend on the size of the browser window.
To get the (for me) correct contents from the page, the browser window must be maximized.
However, I also don't need or want to see the browser window when the script creates it, so it should be invisible.
At first I created the browser window with simply this:
$oIE = _IECreate ($url ,0 ,0 ,1 ,0) However, from the results I can see that the invisible browser window isn't maximized.
So I changed the code to maximize the window, but then it becomes visible.
Now I have this:
$oIE = _IECreate ($url ,0 ,0 ,1 ,0) $hIE = _IEPropertyGet($oIE, "hwnd") WinSetState($hIE, "", @SW_MAXIMIZE) WinSetState($hIE, "", @SW_HIDE) ...but then I do see the browser window shortly when it is maximized.
I could live with that if it were just a single browser window. But the script is opening (and closing) quite a few browser windows, and I don't wait to see them flicker, nor do I want to (be able to accidentally) interact with these windows.
Any ideas on how to create and invisible yet maximized IE windows?
I created a script to split a text file to multiple files based on the first two characters of each line, Example:
about my brother and me. About me? Naturally, you can't know. Nature must take her course! The result of this example will be two files:
about my brother and me. About me? NA.txt
Naturally, you can't know. Nature must take her course! As you see the first two characters will be the file name.
My script does the job.
So, What's the problem?
The problem is that my script is so slow with big files.
I tried it with a text file with 1,000,000 lines and it took about half an hour to finish 20% only.
Here is my script:
#include <Array.au3> #include <AutoItConstants.au3> #include <File.au3> #include <scriptingdic.au3> ;Download from: https://www.autoitscript.com/forum/topic/182334-scripting-dictionary-modified/ Global $Lines _FileReadToArray("ORIGINAL.txt", $Lines, $FRTA_NOCOUNT) Global $initArr = ["----"] Global $dict = _InitDictionary() $Total = UBound($Lines) $LastRound = 0 For $i = 0 To UBound($Lines)-1 Step +1 ;Extract the first two characters of the current line $FirstTwoChar = StringMid($Lines[$i], 1, 2) ;Replace symbols that are not valid for file names $FirstTwoChar = StringReplace($FirstTwoChar, " ", "_") $FirstTwoChar = StringReplace($FirstTwoChar, "<", "_") $FirstTwoChar = StringReplace($FirstTwoChar, ">", "_") $FirstTwoChar = StringReplace($FirstTwoChar, "?", "_") $FirstTwoChar = StringReplace($FirstTwoChar, '"', "_") $FirstTwoChar = StringReplace($FirstTwoChar, "|", "_") $FirstTwoChar = StringReplace($FirstTwoChar, ":", "_") $FirstTwoChar = StringReplace($FirstTwoChar, "\", "_") $FirstTwoChar = StringReplace($FirstTwoChar, "/", "_") ;Add the first two characters as a key in the dictionary with an array as its value. if not _ItemExists($dict, $FirstTwoChar) then $initArr = $FirstTwoChar _AddItem($dict, $FirstTwoChar, $initArr) EndIf ;Add the current line to the array. $tmpArray = _Item($dict, $FirstTwoChar) _ArrayAdd($tmpArray ,$Lines[$i]) _ChangeItem($dict, $FirstTwoChar, $tmpArray) ;Show progress on the screen $Percent = $i / $Total * 100 if round($Percent) <> $LastRound then ToolTip('...'&round($Percent)&"%",0,5) $LastRound = round($Percent) EndIf Next ;Save each array as text file DirCreate("result") For $Key In $Dict $FinalArray = _Item($dict, $Key) $FileName = $FinalArray _ArrayDelete($FinalArray, 0) ;_ArrayDisplay($FinalArray) _FileWriteFromArray("result\"&$FileName&".txt", $FinalArray) Next
* Lines must stay in the same order. You can't change lines order while processing the file.
Any idea to make this script fast?
Example of ORIGINAL text file.rar
Hey folks, I have a little problem with my script.
I have no experience with these things, and I know for sure that my code is not the best, but please be lenient, thanks 😅
The User should first choose 1 of the 2 Options to actually start the script. If 1 of the 2 Option is choosen then the User should click start again and all should work.
I have already commented the problem, If the button Start is clicked before, the User will select just 1 of the 2 option and the program will start (Without clicking start).How can I set $Start to $GUI_UNCHECKED? I have already tried to use GuiCtrlSetState, but didnt worked.
$Start = GuiCtrlCreateButton("Start", 20, 200, 90, 50,bitor($BS_CENTER,0,0)) GUICtrlSetOnEvent($Start,"Startallrun") Func Startallrun() If ((GUICtrlRead($Option1) = $GUI_UNCHECKED) And (GUICtrlRead($Option2) = $GUI_UNCHECKED)) Then MsgBox($MB_OK, "Error", "You have to select 1 Option") While (GUICtrlRead($Option1) = $GUI_UNCHECKED) Sleep(10) If (GUICtrlRead($Option1) = $GUI_CHECKED) Or (GUICtrlRead($Option2) = $GUI_CHECKED) Then GUICtrlSetState($Start,$GUI_UNCHECKED) ; This doesen't work for Buttons While (GUICtrlRead($Start) = $GUI_UNCHECKED) Sleep(10) If ($Start = $GUI_CHECKED) Then ; That's the problem. The script will start if I click one of the 2 options (because start was already checked before) ExitLoop EndIf WEnd ExitLoop EndIf WEnd Else If (GUICtrlRead($Option1) = $GUI_CHECKED) Then MsgBox($MB_OK, "Starting", "Start") Start() EndIf EndIf EndFunc
_cFileSelectFolder() is intended as a replacement for native FileSelectFolder() for selecting folders: It implements the left pane of FileSelectFolder(), and goes beyond FileSelectFolder() in several ways.
• It is user friendly and designed to be easy to use;
• New folder, Delete folder and Rename folder controls are optional;
• Its GUI can be placed anywhere, including centred on another window;
• Neither needs nor uses CLSIDs;
• Checks calling parameters rigorously, with the user choosing either to show error messages in a dialog or to set @error and return them to the caller;
• For local and mapped drives, accepts file specifications with drives that can be drive letters, drive labels, or both,
• For local and mapped drives, always returns drive letter:\ ...\ so its output is compatible with native AutoIt functions.
• For UNC paths, returns \\computer\share\...\
• For unmapped drives on computers on the network, offers a shortcut to shares.
• Selecting a treeview item to be highlighted initially is specified in a user-friendly way, including a diagnostic for when the user gets it wrong
• Because it can be called with many arguments, a user can show a list of the arguments / parameters and their values
The root of the treeview can be:
• The Desktop hierarchy with Desktop at the top
• Partial Desktop hierarchy with any other Desktop item at the top, with or without local/mapped drives and file folders, or remote shares and file folders (as appropriate),
• Local/mapped drives and file folders, or
• Remote shares and folders.
The script and example scripts are in the zip file. Documentation beyond what is in the UDF header is in the PDF file, cFileSelectFolder 1_6_0.pdf
Comments and suggestions are most welcome.