Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/09/2012 in all areas

  1. ripdad

    Using FileOpen

    Everyone starts from somewhere. We all had to do this in the beginning. A new programmer will have to understand what a path is, before they learn anything else. I can't remember, but I'm sure I had some difficulty understanding it at first. I wasn't born with that knowledge. It takes some time to grasp basic coding practices. So, for someone reading the help file for the very first time (about files), it helps to have a proper structure in order to better understand what they are reading. Anyways, just my 2 cents (which used to buy some bubble gum).
    2 points
  2. Jos

    Using FileOpen

    Guys, come on, where are the days we also expect people to think and understand what is happening when programming. Whatever we do in the examples, there always will be something that could be "improved". In this case my humble opinion is that the examples are fine and have been for the past 10 years. Jos
    2 points
  3. The following example gets all unread items with at least one attachment and writes the mail subject plus the name of all attachments to the Console. Use _OL_ItemAttachmentSave to save the attachments of your mails. #AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y #include <OutlookEX.au3> Global $aAttachments ; Connect to Outlook Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error opening connection to Outlook. @error = " & @error & ", @extended = " & @extended) ; Access the Inbox Global $aFolder = _OL_FolderAccess($oOutlook, "", $olFolderInbox) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the Inbox. @error = " & @error & ", @extended = " & @extended) ; Search for unread items with attachments Global $sFilter = "@SQL=""urn:schemas:httpmail:hasattachment"" = 1 and ""urn:schemas:httpmail:read""=0" Global $aResult = _OL_ItemSearch($oOutlook, $aFolder[1], $sFilter, "EntryID,subject") If @error Then MsgBox(16, "OutlookEX UDF - _OL_ItemSearch Example Script", "Error running _OL_ItemSearch. @error = " & @error & ", @extended = " & @extended) Else _Arraydisplay($aResult, "Example 6") EndIf ; Now get a list of attachments For $i = 1 To $aResult[0][0] ConsoleWrite($aResult[$i][1] & @CRLF) ; Mail subject $aAttachments = _OL_ItemAttachmentGet($oOutlook, $aResult[$i][0]) For $j = 1 To $aAttachments[0][0] ConsoleWrite(" " & $aAttachments[$j][2] & @CRLF) ; Name of atachment Next Next _OL_Close($oOutlook) Exit
    2 points
  4. Hello. When I am drawing button on aero glass window. Anything that's dark gets lost. does anyone know how to maintain black text on button.... Or how to have that button unaffected. $hgui = GUICreate("test",100,100) GUISetBkColor(0) GUICtrlCreateButton("test button",0,0) GUISetState() Dim $Area[4] = [0, 0, 0, -1]; Glass area extension _Vista_ApplyGlassArea($hgui,$Area) while GUIGetMsg() <> -3 WEnd Func _Vista_ApplyGlassArea($hWnd, $Area, $bColor = 0x000000) If @OSVersion <> "WIN_VISTA" And @OSVersion <> "WIN_7" Then MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!") Exit Else If IsArray($Area) Then $Struct = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;") DllStructSetData($Struct, "cxLeftWidth", $Area[0]) DllStructSetData($Struct, "cxRightWidth", $Area[1]) DllStructSetData($Struct, "cyTopHeight", $Area[2]) DllStructSetData($Struct, "cyBottomHeight", $Area[3]) $Ret = DllCall("dwmapi.dll", "long*", "DwmExtendFrameIntoClientArea", "uint", $hWnd, "ptr", DllStructGetPtr($Struct)) If @error Then Return 0 Else Return $Ret EndIf Else MsgBox(16, "_Vista_ApplyGlassArea", "Area specified is not an array!") EndIf EndIf EndFunc ;==>_Vista_ApplyGlassArea
    1 point
  5. Is this working? #include <ScreenCapture.au3> $s555Bmp = @ScriptDir & "TestBMP555.bmp" _GDIPlus_Startup() Global $iW = 57, $iH = 57 Global $hHBitmap = _ScreenCapture_Capture("", 0, 0, $iW, $iH) Global $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) _WinAPI_DeleteObject($hHBitmap) Global $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", $GDIP_PXF16RGB555, "ptr", 0, "int*", 0) ;create RGB555 bitmap Global $hBmp555 = $aResult[6] Global $hContext = _GDIPlus_ImageGetGraphicsContext($hBmp555) _GDIPlus_GraphicsDrawImageRect($hContext, $hBitmap, 0, 0, $iW, $iH) ;copy captured image 24bit image to RGB555 bitmap _GDIPlus_ImageSaveToFile($hBmp555, $s555Bmp) ;save to a bmp file _GDIPlus_GraphicsDispose($hContext) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hBmp555) _GDIPlus_Shutdown() ;load bitmap and cut off first 54 header bytes and save it to a new file Global $iFileSize = FileGetSize($s555Bmp) Global $hFile = FileOpen($s555Bmp, 16) Global $iPos = FileSetPos($hFile, 54, $FILE_BEGIN) Global $binBOB = FileRead($hFile, $iFileSize - 54) FileClose($hFile) $hFile = FileOpen(@ScriptDir & "Blob555", 18) FileWrite($hFile, $binBOB) FileClose($hFile) ShellExecute($s555Bmp) Br, UEZ
    1 point
  6. noobish, The following displays a countdown on a transparent gui and the same in a traytip every 30 seconds. The traytip stays active for 10 seconds. If you don't like the gui, comment it out. You don't need this as a service to run automatically, just put it in the startup folder. Calculations greedily plagarized from UEZ!!! #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <date.au3> local $target_date = '2013/01/01 00:00:00' local $hrs, $mins, $secs, $days=0, $diff, $warn = 24*60*60, $warn_intrvl = 30, $display_time local $gui010 = guicreate('',@DesktopWidth,20,(@desktopwidth)/2,20,$ws_popup,bitor($ws_ex_layered,$ws_ex_topmost)) GUISetBkColor(0xABCDEF) local $lbl010 = guictrlcreatelabel('',0,0,600,20) guictrlsetfont(-1,10,800,-1,'lucinda console') _WinAPI_SetLayeredWindowAttributes($gui010, 0xABCDEF, 250) guisetstate() adlibregister('_update',1000) while guigetmsg() <> $gui_event_close wend func _update() $diff = _datediff('s',_NowCalc(),$target_date) ; calcs from UEZ Local $secs = Mod($diff, 60) Local $mins = Mod(Int($diff / 60), 60) Local $hrs = Int($diff / 60 ^ 2) If $hrs > 23 Then $days = Floor($hrs/ 24) $hrs -= $days * 24 endif local $diff_out = stringformat('%02i Days %02i Hours %02i Minutes %02i Seconds to ' & stringleft($target_date,stringinstr($target_date,' ')), $days, $hrs, $mins, $secs) guictrlsetdata($lbl010,$diff_out) $warn -= 1 if mod($warn,$warn_intrvl) = 0 then traytip('',$warn_intrvl & ' seconds have passed' & @lf & $diff_out,5) $display_time = 1 endif if $display_time = 10 then traytip('','',0) $display_time = 0 endif if $display_time then $display_time += 1 endfunc kylomas
    1 point
  7. ripdad

    Using FileOpen

    Actually, that example should read closer to this... Local $sPath = @ScriptDir Local $sFile = "test.txt" Local $hFile = FileOpen($sPath & '' & $sFile, 0) ; Check if file opened for reading OK If $hFile = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileClose($hFile) This way... it breaks it down properly to the reader: 1) The Path that the file resides in. 2) The File Name with Extension. 3) The Handle of the File, once opened. This will kill the idea that the reader only needs a file name to work. Just my opinion.
    1 point
  8. kylomas

    Using FileOpen

    Rhyono, I will agree that the example scripts should at least run, as coded. I'll put something in the thread that handles these kinds of problems. kylomas
    1 point
  9. Rhyono

    Using FileOpen

    By "improved" you mean it could be changed to an example that would work in at least one instance? If you saw an example which did not specify a directory, and you assumed it was written by someone who knew what they were doing, I believe you'd be more inclined to think "it must use the current directory" over "this guy is lazy." @Xandy If the example had used a placeholder like "filename": yeah, I would've assumed path too. However, it specifically used just a filename.
    1 point
  10. Try this: #include <Date.au3> #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Global $sTimeLeft, $label Global $hGUI = GUICreate("Test", 300, 300) Global $button = GUICtrlCreateButton("YES", 10, 250, 50) $label = GUICtrlCreateLabel("", 80, 120, 200, 30) ;~ GUICtrlSetBkColor(-1, 0x808080) GUICtrlSetFont($label, 20, 400, 0, "Arial", 5) GUISetState() Global $seconds = _DateDiff("s", _NowCalc(), "2013/01/01 00:00:00") Global $dummy = GUICtrlCreateDummy() Countdown() AdlibRegister("Countdown", 1000) Global $iTimeTrayIcon = 2 * 60 * 60 * 1000 ;displays every 2h a tray tip Global $iTimer = TimerInit() Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $button, $dummy Run("calc.exe") EndSwitch If TimerDiff($iTimer) > $iTimeTrayIcon Then TrayTip("Information", "Sylvester Party in: " & $sTimeLeft, 10, 1) $iTimer = TimerInit() EndIf Until False AdlibUnRegister("Countdown") GUIDelete($hGUI) Exit Func Countdown() Local $days = 0 Local $sec = Mod($seconds, 60) Local $min = Mod(Int($seconds / 60), 60) Local $hr = Int($seconds / 60 ^ 2) If $hr > 23 Then $days = Floor($hr / 24) $hr -= $days * 24 EndIf $sTimeLeft = StringFormat("%01id %02i:%02i:%02i", $days, $hr, $min, $sec) GUICtrlSetData($label, $sTimeLeft) $seconds -= 1 If $seconds < 0 Then GUICtrlSendToDummy($dummy) AdlibUnRegister("Countdown") EndIf EndFunc Br, UEZ
    1 point
  11. It saved people signature images as additional attachment. I will read up and on what you suggested thanks Water
    1 point
  12. I have considered to add a PST compact function. Unfortunately Outlook doesn't offer a method in the object model. So, no, there will be no such function in the OutlookEX UDF. The only way to do it by script is to automate the Outlook GUI.
    1 point
  13. MKISH, Moving the mouse is sending a message which is picked up by GUIGetMsg - as nothing else much is going on this effectively cuts short the 12-15ms delay that is automatically built into that function and so the whole loop speeds up. So I would do something like this to force a standard delay: While 1 ; Get a timestamp $iBegin = TimerInit() _Projectile() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_GraphicsDispose($hGraphicLabel) _WinAPI_DeleteObject($hBMPBuff) _GDIPlus_Shutdown() DllClose($USER32DLL) Exit EndSwitch ; Now wait until at least 20 ms have passed - you can increase the time as required, but this is probably the minimum you can use While TimerDiff($iBegin) < 20 Sleep(10) ; This is the minimum Sleep WEnd WEndNow you will always wait 20ms regardless of how many messages are waiting in the queue.
    1 point
  14. Crayfish

    Password changer

    You shouldn't mask the new password without a second validation that the user had actually type new password or what they think they typed are two different thing. The error never get trigger for SQL because you don't have any error handler. Default script crashed before it reach your @error
    1 point
  15. Jmon - Thank you for pointing me with the switch. That's good way to replace it. Since the actual data is not random, is there a way to read the existing array and replace the value instead? Updated: I solved with the right direction from Jmon using switch. Here is example if anyone ever need to replace array on fly. #include <Array.au3> ; Required only for _ArrayDisplay(). #include <GUIConstantsEx.au3> #include <GUIListView.au3> #include <WindowsConstants.au3> Example() Func Example() Local $iWidth = 600, $iHeight = 400, $iListView Local $hGUI = GUICreate('_GUICtrlListView_CreateArray()', $iWidth, $iHeight, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) _CreateListView($hGUI, $iListView) Local $iGetArray = GUICtrlCreateButton('REPLACE', $iWidth - 90, $iHeight - 28, 85, 25) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKSIZE + $GUI_DOCKBOTTOM) Local $iRefresh = GUICtrlCreateButton('Refresh', $iWidth - 180, $iHeight - 28, 85, 25) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKSIZE + $GUI_DOCKBOTTOM) GUISetState(@SW_SHOW, $hGUI) Local $aReturn = 0, $aStringSplit = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $iGetArray $aReturn = _GUICtrlListView_CreateArray($iListView, Default) ; Use | as the default delimeter. _ArrayDisplay($aReturn, 'BEFORE') ; replace string in array for specific column For $A = 0 To UBound($aReturn, 1)-1 Switch $aReturn[$A ][0] Case 1 $aReturn[$A ][0] = "Offline" Case 3 $aReturn[$A ][0] = "Online" Case 8 $aReturn[$A ][0] = "I don't even know" EndSwitch Next _ArrayDisplay($aReturn, 'AFTEr') Case $iRefresh GUICtrlDelete($iListView) _CreateListView($hGUI, $iListView) EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example Func _CreateListView($hGUI, ByRef $iListView) ; Thanks to AZJIO for this function. Local $aClientSize = WinGetClientSize($hGUI) $iListView = GUICtrlCreateListView('', 0, 0, $aClientSize[0], $aClientSize[1] - 30) GUICtrlSetResizing($iListView, $GUI_DOCKBORDERS) Sleep(250) Local $iColumns = 3 __ListViewFill($iListView, $iColumns, Random(25, 100, 1)) ; Fill the ListView with Random data. For $i = 0 To $iColumns _GUICtrlListView_SetColumnWidth($iListView, $i, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($iListView, $i, $LVSCW_AUTOSIZE_USEHEADER) Next EndFunc ;==>_CreateListView Func __ListViewFill($hListView, $iColumns, $iRows) ; Required only for the Example. If Not IsHWnd($hListView) Then $hListView = GUICtrlGetHandle($hListView) EndIf Local $fIsCheckboxesStyle = (BitAND(_GUICtrlListView_GetExtendedListViewStyle($hListView), $LVS_EX_CHECKBOXES) = $LVS_EX_CHECKBOXES) _GUICtrlListView_BeginUpdate($hListView) For $i = 0 To $iColumns - 1 _GUICtrlListView_InsertColumn($hListView, $i, 'Column ' & $i + 1, 50) _GUICtrlListView_SetColumnWidth($hListView, $i - 1, -2) Next For $i = 0 To $iRows - 1 _GUICtrlListView_AddItem($hListView, Random(1,9,1), $i) If Random(0, 1, 1) And $fIsCheckboxesStyle Then _GUICtrlListView_SetItemChecked($hListView, $i) EndIf For $j = 1 To $iColumns _GUICtrlListView_AddItem($hListView, Random(1, 8, 1), $i) _GUICtrlListView_AddSubItem($hListView, $i, 'Row ' & $i + 1 & ': Col ' & $j + 1, $j) Next Next _GUICtrlListView_EndUpdate($hListView) EndFunc ;==>__ListViewFill ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlListView_CreateArray ; Description ...: Creates a 2-dimensional array from a lisview. ; Syntax ........: _GUICtrlListView_CreateArray($hListView[, $sDelimeter = '|']) ; Parameters ....: $hListView - Control ID/Handle to the control ; $sDelimeter - [optional] One or more characters to use as delimiters (case sensitive). Default is '|'. ; Return values .: Success - The array returned is two-dimensional and is made up of the following: ; $aArray[0][0] = Number of rows ; $aArray[0][1] = Number of columns ; $aArray[0][3] = Delimited string of the column name(s) e.g. Column 1|Column 2|Column 3|Column nth ; $aArray[1][0] = 1st row, 1st column ; $aArray[1][1] = 1st row, 2nd column ; $aArray[1][2] = 1st row, 3rd column ; $aArray[n][0] = nth row, 1st column ; $aArray[n][1] = nth row, 2nd column ; $aArray[n][2] = nth row, 3rd column ; Author ........: guinness ; Remarks .......: GUICtrlListView.au3 should be included. ; Example .......: yes ; =============================================================================================================================== Func _GUICtrlListView_CreateArray($hListView, $sDelimeter = '|') Local $iColumnCount = _GUICtrlListView_GetColumnCount($hListView), $iDim = 0, $iItemCount = _GUICtrlListView_GetItemCount($hListView) If $iColumnCount < 3 Then $iDim = 3 - $iColumnCount EndIf If $sDelimeter = Default Then $sDelimeter = '|' EndIf Local $aColumns = 0, $aReturn[$iItemCount + 1][$iColumnCount + $iDim] = [[$iItemCount, $iColumnCount, '']] For $i = 0 To $iColumnCount - 1 $aColumns = _GUICtrlListView_GetColumn($hListView, $i) $aReturn[0][2] &= $aColumns[5] & $sDelimeter Next $aReturn[0][2] = StringTrimRight($aReturn[0][2], StringLen($sDelimeter)) For $i = 0 To $iItemCount - 1 For $j = 0 To $iColumnCount - 1 $aReturn[$i + 1][$j] = _GUICtrlListView_GetItemText($hListView, $i, $j) Next Next Return SetError(Number($aReturn[0][0] = 0), 0, $aReturn) EndFunc ;==>_GUICtrlListView_CreateArray
    1 point
×
×
  • Create New...