Jump to content

_Kurt

Active Members
  • Posts

    838
  • Joined

  • Last visited

About _Kurt

  • Birthday 06/21/2006

Profile Information

  • Member Title
    been a while hasn't it
  • Location
    Canada

Recent Profile Visitors

990 profile views

_Kurt's Achievements

Universalist

Universalist (7/7)

2

Reputation

  1. A little app I made because I hate having duplicate songs on my iTunes, and with 2000 songs I'd hate to find them myself. Shockingly, my script found 20 duplicate songs and I saved 82.5MB worth of space. My script uses a decent comparison method, so some song names that might not be equal might still be picked up. After scanning your library, please uncheck any songs that you do not wish to delete and afterwards click Delete Selected. iTunes is needed to run the application #include <GUIConstants.au3> #include <GUIListView.au3> Global $listcount = 0, $foundCount, $Found, $iTracks, $Tracks ;some variables that will be used $GUI = GUICreate("iScan - Delete duplicate songs", 283, 306, 193, 125) GUICtrlCreateLabel("iScan", 24, 9, 44, 24) GUICtrlSetFont(-1, 13, 2000, 0, "MS Sans Serif") $Scan = GUICtrlCreateButton("Scan Library", 88, 8, 89, 25, 0) $List1 = GUICtrlCreateListView("Song|Artist|Path", 8, 40, 265, 253) _GUICtrlListView_SetExtendedListViewStyle($List1, $LVS_EX_CHECKBOXES) ;Set listview to checkbox style _GUICtrlListView_SetColumnWidth($List1, 0, 87) ;even out the widths of the columns _GUICtrlListView_SetColumnWidth($List1, 1, 87) _GUICtrlListView_SetColumnWidth($List1, 2, 87) $Delete = GUICtrlCreateButton("Delete Selected", 184, 8, 89, 25, 0) GUICtrlSetState(-1,$GUI_DISABLE) ;set it disabled until scan is complete GUISetState() ;show GUI While 1 $msg = GUIGetMsg() Select Case $msg = $Scan ;scan is pressed GUICtrlSetState($Scan, $GUI_DISABLE) ;disable scan button until scan is complete Scan() ;see Scan() GUICtrlSetState($Delete, $GUI_ENABLE) ;enable delete button to allow user to delete checked songs Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $Delete GUICtrlSetState($Delete, $GUI_DISABLE) Delete() ;see Delete() GUICtrlSetState($Delete, $GUI_ENABLE) EndSelect WEnd Func Scan() GUICtrlSetData($Scan, "Creating iTunes Object") Sleep(100) ;Let it update the GUI before we lag the process by creating the iTunes object (if iTunes is not open) $oiTunes = ObjCreate("iTunes.Application") If Not IsObj($oiTunes) Then ;Notify user if user does not have iTunes installed on his computer MsgBox(0, "", "ERROR: Could not create iTunes object." & @CRLF & @CRLF & "Explanation:" & @CRLF & "iTunes, or some of it's components, are not installed on your computer." & @CRLF & "Now Exiting..") Exit EndIf $iTracks = $oiTunes.LibraryPlaylist.Tracks ;Get tracks from the library Global $total = $iTracks.Count ;$total represents the total songs in the library Global $count = 0 ;set values Global $Tracks[$total+1][3] ;create an array, the first dimension sized at the number of songs in your library ; ;the second dimension: [0]=Song [1]=Artist [2]=Size GUICtrlSetData($Scan, "Scanning..") ProgressOn("iScan", "Scanning: ", "0%") ;display progress For $i In $iTracks ;for each track found in the library $count += 1 ;keep track # of songs ProgressSet(Round(($count/$total)*100, 2), Round(($count/$total)*100, 2) & "%", "Scanning: " & $i.Name) $Tracks[$count][0] = $i.Name ;set array member values $Tracks[$count][1] = $i.Artist $Tracks[$count][2] = $i.Size Next ProgressSet(0, "Comparing: ", "0%") ;now that we have all the values in the array, start comparing each song Global $Found[2][2] ;$Found array assures that we don't find 2 of the same duplicate songs Global $foundCount = 1 Global $foundSwitch = False Global $SpaceSaved = 0 For $i = 1 To $total ProgressSet(Round(($i/$total)*100, 2), Round(($i/$total)*100, 2) & "%", "Comparing: " & $Tracks[$i][0]) For $x = 1 To $total If PrepareString($Tracks[$i][0]) = PrepareString($Tracks[$x][0]) AND _ ;compare song names (see PrepareString()) PrepareString($Tracks[$i][1]) = PrepareString($Tracks[$x][1]) AND _ ;compare artist $i <> $x Then ;make sure that we aren't comparing the song with itself $foundSwitch = True For $y = 1 To UBound($Found)-1 If $Found[$y][0] = $x Or $Found[$y][1] = $x Then $foundSwitch = False EndIf Next If $foundSwitch = True Then ;if we haven't already recorded the song as a duplicate, then record it $Found[$foundCount][0] = $x $Found[$foundCount][1] = $i $foundCount += 1 ReDim $Found[$foundCount+1][2] GUICtrlCreateListViewItem($Tracks[$i][0] & "|" & $Tracks[$i][1] & "|" & $iTracks.Item($i).Location, $List1) ;create a new item _GUICtrlListView_SetItemChecked($List1, $listcount, True) ;set it checked by default $listcount += 1 $SpaceSaved += $Tracks[$i][2] ;keep track of the total size that could be saved EndIf EndIf Next Next GUICtrlSetData($Scan, "Completed Scan") ProgressOff() MsgBox(0,"","Scan Complete. Possible space saved: " & Round(($SpaceSaved/1024/1024),2) & " MB") EndFunc Func Delete() $SpaceSaved = 0 $count = 0 For $i = 1 To $foundCount-1 ;for each item in the listview If _GUICtrlListView_GetItemChecked($List1, $i-($count+1)) Then ;if the current item is checked, proceed FileDelete($iTracks.ItemByName($Tracks[$Found[$i][1]][0]).Location) ;delete the file $iTracks.ItemByName($Tracks[$Found[$i][1]][0]).Delete ;delete the library entry _GUICtrlListView_DeleteItem($List1, $i-($count+1)) ;delete it from the listview $SpaceSaved += $Tracks[$Found[$i][1]][2] ;keep track of how much space the user will save $count += 1 ;keep track of how many files have been deleted EndIf Next ;display final message MsgBox(0,"","Task Complete. You have deleted " & $count & " files, and saved " & Round(($SpaceSaved/1024/1024),2) & " MB of space.") EndFunc Func OnAutoItExit() $oiTunes = 0 ;destroy iTunes object EndFunc Func PrepareString($str) ;removes spaces, quotes, dashes, changes to lowercase (for insensitive case and good comparison) Return StringLower(StringStripWS(StringReplace(StringReplace($str,"-",""), "'", ""),8)) EndFunc Enjoy, Kurt
  2. Thanks, and sorry about the limited amount of comments. I still am not really sure how $dwExtraInfo can be used, there is no useful comments from msdn. Also, I've noticed that I don't ever receive the $WM_LBUTTONDBLCLK / $WM_RBUTTONDBLCLK / $WM_MBUTTONDBLCLK events. Kurt
  3. Hi guys, I'm not sure if someone else hasn't posted something like this, I didn't manage to find one through the search engine. I personally liked how it retrieves the mouse wheel state. ; ~~ Mouse Hook ~~ ;For more info, Visit: http://msdn.microsoft.com/en-us/library/ms644986(VS.85).aspx ;Include GUI Consts #include <GUIConstants.au3> ;for $GUI_EVENT_CLOSE #Include <WinAPI.au3> ;for HIWORD ;These constants found in the helpfile under Windows Message Codes Global Const $WM_MOUSEMOVE = 0x0200 ;mouse move Global Const $WM_MOUSEWHEEL = 0x020A ;wheel up/down Global Const $WM_LBUTTONDBLCLK = 0x0203 ;left button Global Const $WM_LBUTTONDOWN = 0x0201 Global Const $WM_LBUTTONUP = 0x0202 Global Const $WM_RBUTTONDBLCLK = 0x0206 ;right button Global Const $WM_RBUTTONDOWN = 0x0204 Global Const $WM_RBUTTONUP = 0x0205 Global Const $WM_MBUTTONDBLCLK = 0x0209 ;wheel clicks Global Const $WM_MBUTTONDOWN = 0x0207 Global Const $WM_MBUTTONUP = 0x0208 ;Consts/structs from msdn Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" ;~ Global Const $WH_MOUSE_LL = 14 ;already declared ;~ Global Const $tagPOINT = "int X;int Y" ;already declared ;Create GUI $GUI = GUICreate("Mouse Hook", 178, 158, @DesktopWidth-178, 0) ;Top-Left corner $_Event = GUICtrlCreateLabel("Event: ", 8, 8, 158, 17) $_XYpos = GUICtrlCreateLabel("X= Y=", 8, 32, 157, 17) $_MData = GUICtrlCreateLabel("Mouse Data: ", 8, 56, 165, 17) $_Flags = GUICtrlCreateLabel("Flags: ", 8, 80, 168, 17) $_Timestamp = GUICtrlCreateLabel("Timestamp: ", 8, 104, 162, 17) $_Extra = GUICtrlCreateLabel("Extra Info: ", 8, 128, 167, 17) GUISetState() WinSetOnTop($GUI, "", 1) ;make GUI stay on top of other windows ;Register callback $hKey_Proc = DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr") $hM_Module = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0) $hM_Hook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE_LL, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hM_Module[0], "dword", 0) While 1 If $GUI_EVENT_CLOSE = GUIGetMsg() Then Exit ;idle until exit is pressed WEnd Func _Mouse_Proc($nCode, $wParam, $lParam) ;function called for mouse events.. ;define local vars Local $info, $ptx, $pty, $mouseData, $flags, $time, $dwExtraInfo Local $xevent = "Unknown", $xmouseData = "" If $nCode < 0 Then ;recommended, see http://msdn.microsoft.com/en-us/library/ms644986(VS.85).aspx $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) ;recommended Return $ret[0] EndIf $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) ;used to get all data in the struct ($lParam is the ptr) $ptx = DllStructGetData($info, 1) ;see notes below.. $pty = DllStructGetData($info, 2) $mouseData = DllStructGetData($info, 3) $flags = DllStructGetData($info, 4) $time = DllStructGetData($info, 5) $dwExtraInfo = DllStructGetData($info, 6) ; $ptx = Mouse x position ; $pty = Mouse y position ; $mouseData = can specify click states, and wheel directions ; $flags = Specifies the event-injected flag ; $time = Specifies the time stamp for this message ; $dwExtraInfo = Specifies extra information associated with the message. ;Find which event happened Select Case $wParam = $WM_MOUSEMOVE $xevent = "Mouse Move" Case $wParam = $WM_MOUSEWHEEL $xevent = "Mouse Wheel" If _WinAPI_HiWord($mouseData) > 0 Then $xmouseData = "Wheel Forward" Else $xmouseData = "Wheel Backward" EndIf Case $wParam = $WM_LBUTTONDBLCLK $xevent = "Double Left Click" Case $wParam = $WM_LBUTTONDOWN $xevent = "Left Down" Case $wParam = $WM_LBUTTONUP $xevent = "Left Up" Case $wParam = $WM_RBUTTONDBLCLK $xevent = "Double Right Click" Case $wParam = $WM_RBUTTONDOWN $xevent = "Right Down" Case $wParam = $WM_RBUTTONUP $xevent = "Right Up" Case $wParam = $WM_MBUTTONDBLCLK $xevent = "Double Wheel Click" Case $wParam = $WM_MBUTTONDOWN $xevent = "Wheel Down" Case $wParam = $WM_MBUTTONUP $xevent = "Wheel Up" EndSelect ; Set GUI control data.. GUICtrlSetData($_Event, "Event: " & $xevent) GUICtrlSetData($_XYpos, "X=" & $ptx & " Y=" & $pty) If $xmouseData <> "" Then GUICtrlSetData($_MData, "Mouse Data: " & $xmouseData) Else GUICtrlSetData($_MData, "Mouse Data: " & $mouseData) EndIf GUICtrlSetData($_Flags, "Flags: " & $flags) GUICtrlSetData($_Timestamp, "Timestamp: " & $time) GUICtrlSetData($_Extra, "Extra Info: " & $dwExtraInfo) ;This is recommended instead of Return 0 $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndFunc ;==>_Mouse_Proc Func OnAutoItExit() DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hM_Hook[0]) $hM_Hook[0] = 0 DllCallbackFree($hKey_Proc) $hKey_Proc = 0 EndFunc ;==>OnAutoItExit Resource: http://msdn.microsoft.com/en-us/library/ms644986(VS.85).aspx Kurt
  4. Ok, thanks for the advice.
  5. Hi there, I'm trying to decided whether I should use TCP or UDP for my current project, and I would like to hear some opinions. My Situation I have 1 computer that will send out very small amounts of data extremely fast to several other computers (10-20). Example data sent: "123/123" So basically I will be sending data like the above to 10-20 computers, at an extremely fast pace. However it does not matter how fast it receives the data, I want to focus on the speed of sending it, I want to have a fast return on my UDP/TCP Send function. Now, I understand that TCP is the most reliable, and UDP is connectionless but could be glitchy and receive duplicate packets/packets in wrong order/etc. Here's a few questions I'm not 100% clear on.. 1. Is it possible to be sending this small amount of data to so many computers at a very fast pace ? 2. Do you need seperate TCP streams when sending out data? .. like for example, will I need to create a For loop for each connection and call TCPSend ? Is this the same with UDP? You see, my vision is to have this data sent out with 1 line of code (so it returns quickly), and still be able to have several clients receive the data. Sorry if I'm not giving enough information/being clear enough.. I need a nap! Thanks alot, Kurt
  6. Well, I'd better start working on how to bypass your filtering script. I'm sure your kids/younger cousins will pay top-dollar for a workaround . Kurt
  7. Try this: MinimizedWindowFuncs.au3 Kurt
  8. I was tired using Msgbox's when users interact with my GUIs, so I decided to write a quick little function to replace my usage of Msgbox's in GUIs. Why use it instead of a Msgbox? - does not allow GUI interaction until a msgbox answer is received - nice looking faded background (see pic) - customizable msgbox (using your own GUICtrlCreate's).. add inputs, etc. - a "floating" msgbox (does not display window in taskbar) Really it's nothing special, but I've been using it so often and I really think it's a step up from a standard Msgbox. #include <WindowsConstants.au3> Global Const $GUI_EVENT_CLOSE = -3 $GUI = GUICreate("") $button1 = GUICtrlCreateButton("Click Me!!",10,10,200,100) $button2 = GUICtrlCreateButton("No, Click Me!!!!",10,200,200,100) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $button1 or $msg = $button2 $Child = _GUIChild_Create($GUI, 200, 80) ; create the child GUI with 200 width / 100 height GUICtrlCreateLabel("Are you sure you want to click on that button?",10,10,200,40) ;create labels/controls $yes = GUICtrlCreateButton("Yes",10,50,80) $no = GUICtrlCreateButton("No",110,50,80) While 1 ;standard GUI loop $xmsg = GUIGetMsg() ;retrieve events Select Case $xmsg = $yes or $xmsg = $no ;whether the user presses yes or no.. we still exit the loop ExitLoop EndSelect WEnd _GUIChild_Delete($Child) ; deletes child GUI & returns focus to the original GUI Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd ; _GUIChild_Create - creates the faded background & creates the "floating toolbar" child GUI ; Parameters.. ; $i_handle -> the window title OR handle of your GUI ; $i_width -> the designated width of the Child GUI ; $i_height -> the designated height of the Child GUI ; $i_transparence -> (OPTIONAL) the transparency of the background ; Return value.. ; On Success -> an array to be used with the _GUIChild_Delete function ; On Failure -> 0 Func _GUIChild_Create($i_handle, $i_width, $i_height, $i_transparency=60) Local $checkHWND = $i_handle If NOT IsHWnd($checkHWND) Then $checkHWND = WinGetHandle($i_handle) If NOT IsHWnd($checkHWND) Then Return 0 Local $pos Local $ret[3] $pos = WinGetPos($checkHWND) $ret[0] = GUICreate("",$pos[2],$pos[3],$pos[0],$pos[1], $WS_POPUP+$WS_DISABLED, $WS_EX_TOOLWINDOW, $checkHWND) GUICtrlCreateLabel("",0,0,$pos[2],$pos[3]) GUICtrlSetBkColor(-1,0x000000) WinSetTrans($ret[0],"",$i_transparency) $ret[1] = GUICreate("",$i_width,$i_height,($pos[2]/2)+$pos[0]-($i_width/2),($pos[3]/2)+$pos[1]-($i_height/2), $WS_POPUP+$WS_BORDER, $WS_EX_TOOLWINDOW, $checkHWND) GUISetState(@SW_DISABLE, $checkHWND) GUISetState(@SW_SHOW, $ret[0]) GUISetState(@SW_SHOW, $ret[1]) $ret[2] = $checkHWND Return $ret EndFunc ; _GUIChild_Delete - deletes the child GUI & returns focus to the original GUI ; Parameters.. ; $ret -> what _GUIChild_Create returned ; Return value.. ; On Success -> 1 ; On Failure -> 0 Func _GUIChild_Delete(ByRef $ret) If NOT IsArray($ret) Then Return 0 GUISetState(@SW_ENABLE,$ret[2]) GUIDelete($ret[0]) GUIDelete($ret[1]) GUISwitch($ret[2]) Return 1 EndFunc Kurt
  9. Grid! That's the word.. Maybe I had some sort of brain fart, couldn't think of the word. I have already done that, but for some reason called it a scale? To use the feature check off the checkbox for Enable Scale, and you will be able to choose the grid dimensions (default is 10x10 pixels) Kurt
  10. Thanks.. And good thinking on the ideas, I'm glad someone made improvements on the script. I don't think constantly calling WinMove in the While loop is smart, it could possibly stress the computer.. so instead why don't we compare the GUI's coordinates with the toolbar window coordinates, and if the coordinates don't match our ideal placement, then we take action and call WinMove. I will update Gorganize.au3 in a moment, thank you for your input. Kurt
  11. This is used to make your GUI controls draggable, helping you position them at their ideal coordinates. It can also output your exact script when done, replacing the old coordinates with the new ones. You can also choose to scale the GUI by pixels (i.e. 10x10 pixel). Do all of this by adding 2 lines of code to your script!! Don't really script much lately, but I had an urge to create a better working version of my previous script the Gorganizer (http://www.autoitscript.com/forum/index.php?showtopic=47379) which was written over a year ago. The previous script had way too many bugs, and didn't work as well as I expected it too. For people who forget to save the Koda Form designer GUI's, or for people who don't use Koda, this could be very useful to you. I wrote this as a UDF, it's made to be called after your GUISetState call. I haven't added in the ability to resize your controls, this is merely for positioning, howeverI may add that feature if I see enough interest in this project. A very short example explaining where to call it (see below for better example): #include <Gorganize.au3> GUICreate("") ;default GUISetState() ;show GUI Gorganize() ;we call it immediately after the GUI has been shown. While 1 ;; technically this is not needed .. WEnd Note: please download the Gorganize.au3 below before trying the script (download to same directory as example script). Download:Gorganize.au3[ Known Errors This script hasn't been tested with complicated GUI's, however the only bugs I can think of are.. 1. You have more than 1 control that is positioned at the exact X & Y coordinates 2. You use variables or addition/substraction/etc to calculate the X & Y position of the control (example: GUICtrlCreateButton("test", $x, 20+2, 200, 20) Note: these bugs will only occur when attempting to click the "Output Code .." button. Contributors -Szhlopp Kurt
  12. That's unfortunate.. One thing I really need to look into is reading .M4A and .M4P music files. I believe those filetypes are in AAC format, and I can't find a way to read it's song/artist name. Kurt
  13. It's been quite a long time since I've been on the forums, but after receiving emails asking what happened to the Ipod Music Transfer project, I decided to rewrite everything. Really it's not that complicated, I don't see why so many people were interested. However, I've added a few features and made a more user friendly interface. The code has not been commented yet unfortunately, if by request it should be, I will eventually get around to it. Download: iCopy.au3 How To Use Select your iPod, choose the filetype filters, and select your destination folder or choose the option to copy directly to itunes (auto-adds the songs to your music library) I have only done testing on my own computer and iPod, and it worked perfectly. So let's hope it works as well for you guys. Leave me some feedback, thanks. Kurt
  14. Small update, see first post. -Fixed it for current autoit version -Fixed the cheat as described by fear1313
  15. Can this even be done through WMI? Really not sure.. Any help? Thanks, Kurt
×
×
  • Create New...