Leaderboard
Popular Content
Showing content with the highest reputation on 10/21/2012 in all areas
-
Hi guys, this is a small gui to change a volume letter, press button to list the volumes, then choose the volume that you want to change the letter, write the volume number in the input box, and write the letter you want the volume to change to...press change, it'll change the letter. This uses the cmd tool, i wasn't able to incorporate all this into autoit due to my poor skills, maybe one of you experts can help on that kind of improvement. #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Resources\Terminal.ico #AutoIt3Wrapper_Res_Icon_Add=Resources\Terminal.ico #AutoIt3Wrapper_Run_Tidy=y #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Local $Change, $List, $Vol1, $Vol2, $Vol3, $Vol4, $mylist, $exec $Form1 = GUICreate("Volume Letter", 292, 70, 190, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") $Vol1 = GUICtrlCreateInput("", 104, 8, 57, 21) $Label1 = GUICtrlCreateLabel("Volume to change", 8, 8, 91, 17) $Exit = GUICtrlCreateButton("Exit", 184, 34, 75, 25) GUICtrlSetOnEvent($Exit, "Close") $Change = GUICtrlCreateButton("Change to", 96, 34, 75, 25) GUICtrlSetOnEvent($Change, "Change") $List = GUICtrlCreateButton("List Drives", 8, 34, 75, 25) GUICtrlSetOnEvent($List, "List") $Label2 = GUICtrlCreateLabel("Set to:", 176, 8, 35, 17) $Vol2 = GUICtrlCreateInput("", 216, 8, 57, 21) GUISetState(@SW_SHOW) Func Close() ProcessClose("diskpart.exe") _WinAPI_Beep(3500, 200) Exit EndFunc ;==>Close Func List() _WinAPI_Beep(1500, 200) ShellExecute("C:\Windows\System32\diskpart.exe") WinWait("C:\Windows\System32\diskpart.exe") WinActivate("C:\Windows\System32\diskpart.exe") Sleep(100) Send("list volume") Sleep(100) Send("{ENTER}") EndFunc ;==>List Func Change() _WinAPI_Beep(2500, 200) $Vol3 = GUICtrlRead($Vol1, 1) WinActivate("[CLASS:ConsoleWindowClass]") Sleep(500) Send("select volume " & $Vol3) Sleep(500) Send("{ENTER}") Sleep(100) $Vol4 = GUICtrlRead($Vol2, 1) WinActivate("[CLASS:ConsoleWindowClass]") Sleep(500) Send("assign letter=" & $Vol4) Sleep(100) Send("{ENTER}") Sleep(1000) Send("list volume") Sleep(100) Send("{ENTER}") EndFunc ;==>Change While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd1 point
-
Haagimus, Not just yet. Try running this: Global $aArray[4] = [1, 2, 3, 4] _FileWriteFromArray(@ScriptDir & "Test_1.txt", $aArray) Global $aArray[4][2] = [[1, 1], [2, 2], [3, 3], [4, 4]] _FileWriteFromArray(@ScriptDir & "Test_2.txt", $aArray) Func _FileWriteFromArray($sFilePath, $aArray, $iBase = 0, $iUBound = 0, $sDelimeter = "|") ; Check if we have a valid array as input If Not IsArray($aArray) Then Return SetError(2, 0, 0) ; Check the number of dimensions Local $iDims = UBound($aArray, 0) If $iDims > 2 Then Return SetError(4, 0, 0) ; Determine last entry of the array Local $iLast = UBound($aArray) - 1 If $iUBound < 1 Or $iUBound > $iLast Then $iUBound = $iLast If $iBase < 0 Or $iBase > $iLast Then $iBase = 0 ; Open output file for overwrite by default, or use input file handle if passed Local $hFileOpen If IsString($sFilePath) Then $hFileOpen = FileOpen($sFilePath, 1) Else $hFileOpen = $sFilePath EndIf If $hFileOpen = -1 Then Return SetError(1, 0, 0) ; Write array data to file Local $iError = 0 Switch $iDims Case 1 For $i = $iBase To $iUBound If FileWrite($hFileOpen, $aArray[$i] & @CRLF) = 0 Then $iError = 3 ExitLoop EndIf Next Case 2 Local $sTemp Local $iCols = UBound($aArray, 2) For $i = $iBase To $iUBound $sTemp = $aArray[$i][0] For $j = 1 To $iCols - 1 $sTemp &= $sDelimeter & $aArray[$i][$j] Next If FileWrite($hFileOpen, $sTemp & @CRLF) = 0 Then $iError = 3 ExitLoop EndIf Next EndSwitch ; Close file only if specified by a string path If IsString($sFilePath) Then FileClose($hFileOpen) ; Return results If $iError Then Return SetError($iError, 0, 0) Return 1 EndFunc ;==>_FileWriteFromArrayThis is using the function from the beta File.au3 include. M231 point
-
It's currently the creation date returned by the function FileGetTime, change the second parameter to your needs. Br, FireFox.1 point
-
Code for Connect four games (Four stars)
PunProgram reacted to jaberwacky for a topic
Now all I gotta do is learn to play Connect4.1 point -
You won't : #include <Array.au3> ;just to display results #include <Date.au3> #include "RecFileListToArray.au3" Global $iNowTime = _NowCalc(), $aTime Global $sFolder = @DesktopDir Global $aFiles = _RecFileListToArray($sFolder, "*", 1, 1) Global $aFilteredFiles[$aFiles[0]][2] For $iFile = 1 To $aFiles[0] $aTime = FileGetTime($sFolder & "" & $aFiles[$iFile], 1) If _DateDiff("D", $aTime[0] & "/" & $aTime[1] & "/" & $aTime[2] & " " & $aTime[3] & ":" & $aTime[4] & ":" & $aTime[5], $iNowTime) > 14 Then ;created more than 14 days ago $aFilteredFiles[$aFilteredFiles[0][0] + 1][0] = $aTime[1] & StringUpper(_DateToMonth(@MON, 1)) & $aTime[0] $aFilteredFiles[$aFilteredFiles[0][0] + 1][1] = $aFiles[$iFile] $aFilteredFiles[0][0] += 1 EndIf Next ReDim $aFilteredFiles[$aFilteredFiles[0][0] + 1][2] _ArrayDisplay($aFilteredFiles) Br, FireFox.1 point
-
1 point
-
Figured it out [/sup] [sup]#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GuiListView.au3> #include <GDIPlus.au3>[/sup] [sup]; Hide system tray icon #NoTrayIcon[/sup] [sup]; Use Event mode Opt("GUIOnEventMode", 1)[/sup] [sup]; Setup some constants Const $ProgramName = "Cropper" Const $Version = "v1.00" Const $WindowTitle = $ProgramName & " " & $Version & " by NiVZ"[/sup] [sup]#Region ### START Koda GUI section ### Form= $Form = GUICreate($WindowTitle, 520, 520)[/sup] [sup]$TabHost = GUICtrlCreateTab(10, 10, 504, 500)[/sup] [sup]$TabPhoto = GUICtrlCreateTabItem("Photos")[/sup] [sup] $grpPhotos = GUICtrlCreateGroup("Photo List", 20, 40, 300, 460) $lvPhotos = GUICtrlCreateListView("Photo Title", 30, 60, 280, 390, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_REPORT, $LVS_NOCOLUMNHEADER)) GUICtrlSetBKColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) _GUICtrlListView_SetColumnWidth(-1, 0, 259) $btnAddPhoto = GUICtrlCreateButton("Add Photo", 30, 460, 90, 30)[/sup] [sup] GUICtrlCreateGroup("", -99, -99, 1, 1)[/sup] [sup] Global $grpPThumb = GUICtrlCreateGroup("Thumbnail", 330, 40, 170, 160) Global $imgPIcon = GUICtrlCreatePic("", 370, 60, 88, 88, -1, $WS_EX_CLIENTEDGE) ;Global $butChange = GUICtrlCreateButton("Change Thumbnail", 360, 158, 108, 30) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group [/sup] [sup]#EndRegion ### END Koda GUI section ###[/sup] [sup]GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") GUICtrlSetOnEvent($btnAddPhoto, "AddPhoto")[/sup] [sup]_GDIPlus_Startup()[/sup] [sup]GUISetState(@SW_SHOW)[/sup] [sup]While 1 ; Wait for events WEnd[/sup] [sup] [/sup] [sup]Func AddPhoto() ; Show the add photos dialog Local $aFiles = FileOpenDialog("Add Photo", @DesktopDir, "Photos (*.jpg)", 1 + 2, "", $Form) If @error Then ; Do nothing Else CropImage($aFiles) EndIf EndFunc[/sup] [sup] [/sup] [sup]Func CropImage($inFilename)[/sup] [sup] ; Function written by [email="Prog@ndy"]Prog@ndy[/email] - many thanks[/sup] [sup] Local $newwidth, $newheight, $x, $y[/sup] [sup] Local $hLblDC = _WinAPI_GetDC(GUICtrlGetHandle($imgPIcon)) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hLblDC, 88, 88) Local $hDC = _WinAPI_CreateCompatibleDC($hLblDC) _WinAPI_SelectObject($hDC, $hBitmap) Local $hImg = _GDIPlus_ImageLoadFromFile($inFilename)[/sup] [sup] Local $width = _GDIPlus_ImageGetWidth($hImg) Local $height = _GDIPlus_ImageGetHeight($hImg) If $width > $height Then ; Landscape $x = ($width - $height) /2 $y = 0 $newwidth = $height $newheight = $height ElseIf $height > $width Then ; Portrait $x = 0 $y = ($height-$width) /2 $newwidth = $width $newheight = $width [/sup] [sup] Else ; Square $x = 0 $y = 0 $newwidth = $width $newheight = $width EndIf Local $hGraph = _GDIPlus_GraphicsCreateFromHDC($hDC)[/sup] [sup] ;_GDIPlus_GraphicsDrawImageRect($hGraph, $hImg, 0, 0, 88, 88) _GDIPlus_GraphicsDrawImageRectRect($hGraph, $hImg, $x, $y, $newwidth, $newheight, 0, 0, 88, 88)[/sup] [sup] _GDIPlus_GraphicsDispose($hGraph) _GDIPlus_ImageDispose($hImg)[/sup] [sup] Local $tData = DllStructCreate("byte[15488]")[/sup] [sup] Local $tBITMAPINFOHEADER = DllStructCreate("DWORD biSize;LONG biWidth;LONG biHeight;WORD biPlanes;WORD biBitCount;DWORD biCompression;DWORD biSizeImage;LONG biXPelsPerMeter;LONG biYPelsPerMeter;DWORD biClrUsed;DWORD biClrImportant; DWORD colormap[3]") DllStructSetData($tBITMAPINFOHEADER, 1, DllStructGetSize($tBITMAPINFOHEADER)) DllStructSetData($tBITMAPINFOHEADER, 2, 88) DllStructSetData($tBITMAPINFOHEADER, 3, -88) DllStructSetData($tBITMAPINFOHEADER, 4, 1) DllStructSetData($tBITMAPINFOHEADER, 5, 16)[/sup] [sup] ; use default GDI32 16 bit format: 5-5-5 DllStructSetData($tBITMAPINFOHEADER, 6, 0)[/sup] [sup] ; Choose Colormask manually, example for 5-5-5 ;~ DllStructSetData($tBITMAPINFOHEADER, 6, 3) ;BI_BITFIELDS ;~ DllStructSetData($tBITMAPINFOHEADER, "colormap", 0x7C00, 1) ;- Red mask ;~ DllStructSetData($tBITMAPINFOHEADER, "colormap", 0x03E0, 2) ;- Green mask ;~ DllStructSetData($tBITMAPINFOHEADER, "colormap", 0x001F, 3) ;- Blue mask[/sup] [sup] _WinAPI_GetDIBits($hLblDC, $hBitmap, 0, 88, DllStructGetPtr($tData), DllStructGetPtr($tBITMAPINFOHEADER), 1)[/sup] [sup] _WinAPI_ReleaseDC(GUICtrlGetHandle($imgPIcon), $hLblDC) _WinAPI_DeleteDC($hDC)[/sup] [sup] _GUICtrlStatic_SetImage($imgPIcon, $hBitmap) EndFunc[/sup] [sup]Func SpecialEvents()[/sup] [sup] Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE _GDIPlus_Shutdown() Exit[/sup] [sup] ;Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE ;MsgBox(0, "Window Minimized", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)[/sup] [sup] ;Case @GUI_CtrlId = $GUI_EVENT_RESTORE ;MsgBox(0, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)[/sup] [sup] EndSelect[/sup] [sup]EndFunc ;==>SpecialEvents[/sup] [sup]Func _GUICtrlStatic_SetImage($iCtrlId, $hBitmap) ; Function written by [email="Prog@ndy"]Prog@ndy[/email] - many thanks Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local Const $SS_BITMAP = 0xE Local Const $GWL_STYLE = -16[/sup] [sup] If IsHWnd($iCtrlId) Then If WinGetProcess($iCtrlId) <> @AutoItPID Then Return SetError(1,0,0) Else $iCtrlId = GUICtrlGetHandle($iCtrlId) If Not $iCtrlId Then Return SetError(2,0,0) EndIf ; set SS_BITMAP style to control Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE) If @error Then Return SetError(3, 0, 0) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP)) If @error Then Return SetError(4, 0, 0) Local $oldBmp = DllCall("user32.dll", "handle", "SendMessageW", "hwnd", $iCtrlId, "int", $STM_SETIMAGE, "wparam", $IMAGE_BITMAP, "handle", $hBitmap) If @error Then Return SetError(5, 0, 0) If $oldBmp[0] Then _WinAPI_DeleteObject($oldBmp[0]) Return 1 EndFunc[/sup] [sup]1 point