-
Posts
64 -
Joined
-
Last visited
About BoonPek
- Birthday 05/03/1996
Profile Information
-
Location
Lala Land
-
Interests
AutoIt Scripting and other IT Related stuff.
BoonPek's Achievements
Wayfarer (2/7)
0
Reputation
-
Huffman Trees - finding the prefix codes
BoonPek replied to BoonPek's topic in AutoIt General Help and Support
Hi! Thanks for your reply and pointer to that resource I'm not learned in the various other programming languages having only stuck to AutoIt for casual scripting for the past 6 years (wow, I feel old now :/). Looking over the various codes above suggests that I restart the writing of my code and drop the old one, right? I've spoken with my CS teacher earlier and he mentioned heaps and priority queues and lists, which I believe are not officially supported data types in AutoIt? More pointers? EDIT: It's easy to miss out in the mess of code above, but I managed to generate my own tree -- somewhat: (( t) (((h g) i) (((n r) (e a)) s))) -- visually interpret-able but difficult to derive a codeword from -
Huffman Trees - finding the prefix codes
BoonPek replied to BoonPek's topic in AutoIt General Help and Support
Update! I managed to get the program to generate a tree-ish, but am struggling to get the prefix codes for the different symbols. The output, for example, of "this is a test string" is: "[0.[0. |1.t]|1.[0.[0.[0.h|1.g]|1.i]|1.[0.[0.[0.n|1.r]|1.[0.e|1.a]]|1.s]]]" [t] = 01 [ ] = 00 = 111 = 101 etc. I've tried StringSplit on the different delimiters such as [, |, . and ] but it doesn't seem to work for most of the symbols. Can anyone point me in the right direction? I'm doing this to better understand programming; I understand that other languages (supposedly) do it better but I'd like to try it out with AutoIt. Thank you #include <Array.au3> $time = TimerInit() $str = "this is a test string" $var = StringSplit($str, "") Dim $trie[1][2] $trie[0][0] = $str $trie[0][1] = $var[0] For $i = 1 To $var[0] For $j = 1 To UBound($trie)-1 If $trie[$j][0] == $var[$i] Then $trie[$j][1] += 1 ContinueLoop 2 EndIf Next ReDim $trie[$j + 1][2] $trie[$j][0] = $var[$i] $trie[$j][1] = 1 Next Do $num = UBound($trie) _ArraySort($trie, 1, 0, 0, 1) $trie[$num-2][0] = "[0." & $trie[$num-1][0] & "|1." & $trie[$num-2][0] & "]" $trie[$num-2][1] = $trie[$num-1][1] + $trie[$num-2][1] ReDim $trie[$num-1][2] Until UBound($trie) = 2 ConsoleWrite($trie[1][0] & @LF) ConsoleWrite("Execution time: " & TimerDiff($time) & "ms" & @LF) -
Hi all, I understand the underlying concepts behind the generation of a Huffman Tree and can do it on paper; the problem is converting the concept into a routine/program. This is what I'm hoping to accomplish: http://huffman.ooz.ie/?text=This%20is%20a%20test%20string So far I've been able to create and organise the frequency table. I don't know what the next step is. I know, however, that I need to begin with the two lowest frequencies and sum them up then repeat. I'm uncertain as to how I can accomplish this and generate a tree. A 2D, 3D array? Some queer data type? Any help would be highly appreciated, thanks! #include <Array.au3> $time = TimerInit() $str = "This is a test string" $var = StringSplit($str, "") Dim $trie[1][2] $trie[0][0] = $str $trie[0][1] = $var[0] For $i = 1 To $var[0] For $j = 1 To UBound($trie)-1 If $trie[$j][0] == $var[$i] Then $trie[$j][1] += 1 ContinueLoop 2 EndIf Next ReDim $trie[$j + 1][2] $trie[$j][0] = $var[$i] $trie[$j][1] = 1 Next ConsoleWrite("Execution time: " & TimerDiff($time) & "ms" & @LF) _ArraySort($trie, 1, 0, 0, 1) _ArrayDisplay($trie) $trie[UBound($trie)-2][0] = $trie[UBound
-
This time, if you want to escape the script simply press the ESC key. Mr. Dictator here has good tips too. Thank you!
-
HotKeySet("{ESC}", "_exit") ;This way, when you press {ESC} the script will call the function _exit ;This supercedes current loops Func _exit() ;Exits the script Exit EndFunc While 1 WinWaitActive("Encrypting Key Request") Send("password1") MouseClick("left",382,435,1) Send("password2") MouseClick("left",382,435,1) ;I assume that instead of sending a mouseclick you could press ENTER instead? ;Send("{ENTER}") WEnd Could this work?
-
Using Eval() to retrieve object properties
BoonPek posted a topic in AutoIt General Help and Support
A Merry (late) Christmas! I was working on something, and am trying to shorten some code. ;Local $eTemp = "err.description is: " & @TAB & $oError.description & _ ; "err.windescription:" & @TAB & $oError.windescription & _ ; "err.number is: " & @TAB & Hex($oError.number, 8) & _ ; "err.scriptline is: " & @TAB & $oError.scriptline & _ ; "err.source is: " & @TAB & $oError.source Local $eTemp = 'description.windescription.number.scriptline.source' $eTemp = StringSplit($eTemp, '.') For $i = 1 To $eTemp[0] ConsoleWrite($eTemp[$i] & @TAB & Eval("oError" & '.' & $eTemp[$i]) & @LF) Next As you can see in the initial commented code, the method used to display the errors is much longer and space-consuming. I am trying to simplify it below. Problem is, I don't know how to retrieve those variables using Eval (which is supposed to convert a variable into a string). While I work on it, any help would be greatly appreciated. Have a great day guys! EDIT: I'm sure we all don't like this when it happens I spent almost half an hour tinkering with Eval and doing other stuff, experimenting, to try and get it to work. Moments after posting for help I found the solution. Instead of using Eval() I used Execute like so: Execute("$oError." & $eTemp[$i]) Thanks for your time though! -
Window resizing and GUIRegisterMsg()
BoonPek replied to BoonPek's topic in AutoIt GUI Help and Support
Thanks for your assistance. I'm going to assume that there's no other alternative to accomplish the OP other than what I specified? Anyways, onto another issue here xD In GUICtrlCreateInput, you could set the maximum of characters allowed for entry by using GUICtrlSetLimit($handle, maxvalue). Is this possible for a GUICtrlCreateCombobox? Once again, I'd prefer a native function. Thank you Edit: Fixed: _GUICtrlComboBox_LimitText() -
Sorry for bumping this here, but the issue here also pertains to mine. Here's my code thus far; it doesn't seem to function despite being tinkered with for several hours =.=" #include <Constants.au3> #include <GuiConstantsEx.au3> $mGUI = GUICreate('My Test GUI', 800, 550, -1, -1) $sProc = Run('cmd.exe', @ScriptDir, @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED) $sText = GUICtrlCreateEdit('', 10, 10, 780, 500) $sInput = GUICtrlCreateInput('', 10, 520, 700, 20) $sEnter = GUICtrlCreateButton('Send', 720, 520, 70, 20) GUISetState(@SW_SHOW, $mGUI) While 1 $msg = GUIGetMsg($mGUI) Switch $msg Case $GUI_EVENT_CLOSE ProcessClose($sProc) ExitLoop Case $sEnter If GUICtrlRead($sInput) <> '' Then StdinWrite($sProc, GUICtrlRead($sInput)) GUICtrlSetData($sInput, '') EndIf EndSwitch If ProcessExists($sProc) Then $sRead = StdoutRead($sProc) If $sRead <> '' Then $sRead = StringReplace($sRead, @LF, @CRLF) $sRead = GUICtrlRead($sText) & $sRead GUICtrlSetData($sText, $sRead) EndIf EndIf WEnd
-
Window resizing and GUIRegisterMsg()
BoonPek replied to BoonPek's topic in AutoIt GUI Help and Support
Yes, I guess so. Problem is, though, I'd like my users to be unable to resize these windows - but here the potential for resizing still exists. Adding the sleep(100), whilst decreasing CPU load for slower PCs, makes the GUI less fancy Thanks for your input though! I'm looking forwards to those by others -
Window resizing and GUIRegisterMsg()
BoonPek replied to BoonPek's topic in AutoIt GUI Help and Support
3 days; bump! -
BoonPek reacted to a post in a topic:
_EncodeUrl()
-
Hello there! Currently, I use this from Melba23 to prevent my AutoIt GUI from being resized too small, and it works extremely well! #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $GUIMINWID = 200, $GUIMINHT = 200 ; set your restrictions here Global $GUIMAXWID = 200, $GUIMAXHT = 200 GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") $hGUI = GUICreate("Test", 200, 200, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetState() $hGUI_2 = GUICreate("Sizer", 200, 200, 100, 100) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam) $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tagMaxinfo, 7, $GUIMINWID) ; min X DllStructSetData($tagMaxinfo, 8, $GUIMINHT) ; min Y DllStructSetData($tagMaxinfo, 9, $GUIMAXWID) ; max X DllStructSetData($tagMaxinfo, 10, $GUIMAXHT) ; max Y Return 0 EndFunc ;==>WM_GETMINMAXINFO Problem with this, though, is that it doesn't seem to work with external, non AutoIt-created GUIs. To compensate for this, I created a simple script that loops continuously and checks that the window size is large enough. If not, it would resize the window accordingly: Global $p_ID, $hWnd, $hSize $p_ID = Run('Notepad.exe') $hWnd = WinWait('[CLASS:Notepad]', '', 5) While WinGetProcess($hWnd) <> $p_ID $hWnd = WinList("[CLASS:Notepad]") For $i = 1 To $hWnd[0][0] If WinGetProcess($hWnd[$i][0]) = $p_ID Then $hWnd = $hWnd[$i][1] ExitLoop EndIf Next WEnd While WinExists($hWnd) $hSize = WinGetPos($hWnd) If $hSize[2] < 800 Then WinMove($hWnd, '', $hSize[0], $hSize[1], 800, $hSize[3]) If $hSize[3] < 600 Then WinMove($hWnd, '', $hSize[0], $hSize[1], $hSize[2], 600) WEnd Cheap, I know, but I am unable to find any other alternatives. Thanks for any input, guys!
-
Grouping multiple images into one control.
BoonPek replied to BoonPek's topic in AutoIt General Help and Support
Excellent! This works as intended, thank you! -
Grouping multiple images into one control.
BoonPek posted a topic in AutoIt General Help and Support
Hi there! Currently, I have a script which does this: Do GUICtrlCreatePic($imgDir & "\grass.gif", $bM, 455, 128, 25) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetResizing(-1, 840) $bM += 128 Until $bM > @DesktopWidth It works fine, but it involved the looping of an image over the GUI. Is there a way to make it so that it's one sinle control and not multiple controls? I'd like to be able to hide that whole segment using GUICtrlSetState, and with its' current setup it doesn't seem possible. Thanks for any input! Extras: grass.gif is 128x25 -
[Help] Trying to extract a jar file
BoonPek replied to gononono64's topic in AutoIt General Help and Support
This is what I use for my custom minecraft launcher/mod installer. You can use a native Window's DLL, it's something like ZIP UDF in pure AutoIt, but that doesn't guarantee reliability. Some users don't have the DLL or they don't have it registered so your best bet would be to use an external exe and place it into a temporary directory to have it deleted after use: GUICtrlSetData($uCtrl[2], "Decompressing packages") RunWait($bcDir & "\7za.exe x minecraft.jar -ospouttemp", $tmpDir, @SW_HIDE) RunWait($bcDir & "\7za.exe x spoutcraft.zip -y -ospouttemp", $tmpDir, @SW_HIDE) DirRemove($tmpDir & "\spouttemp\META-INF", 1) GUICtrlSetData($uCtrl[2], "Compiling SpoutCraft") RunWait($bcDir & "\7za.exe a -tzip -mx9 spoutcraft.jar *.* -r", $tmpDir & "\spouttemp", @SW_HIDE) FileMove($tmpDir & "\spouttemp\spoutcraft.jar", $tmpDir & "\minecraft.jar", 9) GUICtrlSetData($uCtrl[2], "Patching SpoutCraft") FileDelete($tmpDir & "\spoutcraft.zip") DirRemove($tmpDir & "\spouttemp", 1) DirMove($tmpDir, $scDir & "\bin", 1)