Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/06/2013 in all areas

  1. _Dateadd() will roll over the date if necessary.... You just need to split up the result into different date and time fields possibly using string functions like: #include <Date.au3> ;Global $objName = $CmdLine[1], $hours = 2 ; commented out for testing Global $sDateTime, $sStartDate, $sStartTime, $sCmd, $sXtra_Parms If $CmdLine[0] = 2 Then $hours = $CmdLine[2] $objName = "\\Server1\RemotePC2" ; for testing $hours = 12 ; for testing $sDateTime = _DateAdd('h', $hours, _NowCalc()) $sStartDate = StringMid($sDateTime, 6, 3) & StringMid($sDateTime, 9, 2) & "/" & StringLeft($sDateTime, 4) $sStartTime = StringRight($sDateTime, 8) If @OSVersion = "WIN_VISTA" Or @OSVersion = "WIN_7" Or @OSVersion = "WIN_8" Then $sXtra_Parms = " /Z /V1" $sCmd = 'SCHTASKS /Create /SC ONCE /TN DeleteAdmin /TR "net localgroup administrators /delete "' & $objName & ' /SD ' & $sStartDate & ' /ST ' & $sStartTime & ' /RU SYSTEM' & $sXtra_Parms ;Run($sCmd, "", @SW_HIDE) ; commented out for testing MsgBox(0, "", $sCmd) ; for testing Edit: I didn't run this, but it looks like you have a spacing error in the cmd string about where the $objName variable is inserted.
    1 point
  2. satanttin, Like this: Func load() $sIniFile = FileOpenDialog("Select your character", @scriptdir, "Character (*.ini)") If Not @error Then $name = IniRead ($sIniFile, "Player", "Name", "Error") $race = IniRead ($sIniFile, "Player", "Race", "Error") $age = IniRead ($sIniFile, "Player", "Age", "Error") $Gold = IniRead ($sIniFile, "Player", "Gold", "Error") EndIf EndFunc Any questions? M23
    1 point
  3. somewhat likethis#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $Main, $New_Deck, $Options guimain() Func guimain() $Main = GUICreate("Main", 183, 267, 192, 124) $ND = GUICtrlCreateButton("New Deck", 56, 0, 75, 25) $LD = GUICtrlCreateButton("Load Deck", 56, 24, 75, 25) $Option = GUICtrlCreateButton("Options", 56, 48, 75, 25) $Pic1 = GUICtrlCreatePic("", 0, 80, 182, 185) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") GUICtrlSetOnEvent($ND, "guiND") GUICtrlSetOnEvent($LD, "LD") GUICtrlSetOnEvent($Option, "Option") GUISetState() While 1 WEnd EndFunc ;==>guimain Func guiND() $Form1 = GUICreate("Form1", 50, 50, Random(0, @DesktopWidth - 100 ), Random(0, @DesktopHeight - 100 )) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") GUISetState() EndFunc ;==>guiND Func LD() MsgBox(64, "Info", "Load_Deck Button Clicked") EndFunc ;==>LD Func Close() Exit EndFunc ;==>Close Func Option() MsgBox(64, "Info", "Option Button Clicked") EndFunc ;==>Option!!
    1 point
  4. PhoenixXL

    string

    I have added a regex decode. Ask if you have any questions. For more examples search the Forum or check my Signature Regards Phoenix XL
    1 point
  5. water

    string

    That's a Regular Expression. How they work can be found here and details can be found here.
    1 point
  6. PhoenixXL

    string

    Does this helpLocal $tit ='DLGDIAG - QUICK TEST' #region -Regex_Decode- ;(?mi)........: ^ and $ match newlines within data. Searches are case-insensitive. ;^............: The start of the string assertion ;(?!Run)......: The Literal "Run" is not there ;.*?\R........: Match any number of characters(lazy) after which a Line-Break sequence is received #endregion ;Replace the matched line to '' i.e. None ( or simply delete the line which doesnt start with a Run ) MsgBox(0, "ControlGetText Example", "The control text is: " & StringRegExpReplace( WinGetText($tit), "(?mi)^(?!Run).*?\R", '' ))
    1 point
  7. One more thing Your timing is good... This example is more relevant to your questions regarding the Outlook multiline listview. To get two or more fonts per line (in this case normal and bold) DrawText is called twice per line. Draw the left most text, set the left rect element to the width of the leftmost text plus a few added pixels to indent, then draw the right most text. Text metrics measuring code is needed to replace the hard coded values used for setting left rect and top rect GetStringWidth code added for left rect The number of drawtext calls can be cut down by using multiline text with linefeeds, but then you can't set indentation and font colour/bold per line The example is optimized for speed with dll pseudo handles for dllcalls, stripped down/optimized listview functions and global resources (fonts/pens/brush) for re-use in the WM_DRAWITEM message handler Edit: added _GUICtrlListView_GetStringWidth Edit: corrected ODS_SELECTED multiple item selection, added optional themed/unthemed custom coloured select bar demonstration (try the listview states in Vista/Win7), closed theme handle, added themes parts and states usage example, added optional remove line separators when item selection themed, clarified a few things Edit: Added combo for Button or *Listview theme parts, Added resize of theme rect for Listview parts *Listview group header theme has a better gradient than button in Vista+ ;coded by rover 2k12 #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> Opt("GUIDataSeparatorChar", "|") Global Const $ODA_SELECT = 0x2 Global Const $ODA_FOCUS = 0x4 Global Const $ODS_SELECTED = 0x0001 Global Const $ODT_LISTVIEW = 102 Global Const $ODA_DRAWENTIRE = 0x1 Global $iDllGDI = DllOpen("gdi32.dll") Global $iDllUSER32 = DllOpen("user32.dll") Global $iDllUxtheme = DllOpen("uxtheme.dll") ;global resources for WM_DRAWITEM - optimize speed Global $aFont[2] $aFont[0] = _WinAPI_CreateFont(16, 0, 0, 0, $FW_HEAVY, False, False, False, _ $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, $DEFAULT_PITCH, 'Calibri') $aFont[1] = _WinAPI_CreateFont(16, 0, 0, 0, $FW_MEDIUM, False, False, False, _ $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, $DEFAULT_PITCH, 'Calibri') Global $hPen1 = _WinAPI_CreatePen($PS_SOLID, 1, 0xF3EAE7) Global $hPen2 = _WinAPI_CreatePen($PS_SOLID, 1, 0xF4E8E6) Global $hBrush = _WinAPI_CreateSolidBrush(0xEEDDBB) ;Theme Parts and States ;http://msdn.microsoft.com/en-us/library/windows/desktop/bb773210%28v=vs.85%29.aspx ;Part - vsstyle.h Global Const $BP_PUSHBUTTON = 1 Global Const $LVP_GROUPHEADER = 6 ;State - vsstyle.h Global Enum $PBS_NORMAL=1,$PBS_HOT,$PBS_PRESSED,$PBS_DISABLED,$PBS_DEFAULTED Global Enum $LVGH_CLOSEHOT=10,$LVGH_CLOSESELECTED,$LVGH_CLOSESELECTEDHOT,$LVGH_CLOSESELECTEDNOTFOCUSED ;this allows you to theme individual items for your own needs, not just if items are selected ;the same as customdrawing item and subitem colours ;XP+ Global $sTheme = 'Button' Global $iThemePart = $BP_PUSHBUTTON Global $iThemeState = $PBS_NORMAL ; Vista+ ;Global $sTheme = 'Listview' ;Global $iThemePart = $LVP_GROUPHEADER ;Global $iThemeState = $LVGH_CLOSEMIXEDSELECTION Global $hTheme = DllCall($iDllUxtheme, 'ptr', 'OpenThemeData', 'hwnd', 0, 'wstr', $sTheme) $hTheme = $hTheme[0] ;global structs for WM_DRAWITEM - optimize speed ;rect, text buffer and LVITEM structures Global $tLVRect = DllStructCreate($tagRECT) Global $tLVText = DllStructCreate("wchar[4096]") Global $tLVITEM = DllStructCreate($tagLVITEM) Global $pLVITEM = DllStructGetPtr($tLVITEM) DllStructSetData($tLVITEM, "TextMax", 4096) DllStructSetData($tLVITEM, "SubItem", 0) DllStructSetData($tLVITEM, "Text", DllStructGetPtr($tLVText)) ; WM_MEASUREITEM allows setting the row height Global $iListView_row_height = 130 Global $hListView ;must be declared before listview created GUIRegisterMsg($WM_MEASUREITEM, "WM_MEASUREITEM") ; place before listview creation - message sent once for each ownerdrawn control created GUIRegisterMsg($WM_DRAWITEM, "WM_DRAWITEM") ;placed here, WM_MEASUREITEM can now be unregistered in the handler (deleting or adding items after unregistering maintains row height setting this way) ; --------------------------------------------------- $hGUI = GUICreate("Ownerdrawn multiline ListView", 324, 425) $cListView = GUICtrlCreateListView("", 2, 2, 320, 268, BitOR($LVS_REPORT, $LVS_NOCOLUMNHEADER, $LVS_OWNERDRAWFIXED, $LVS_SHOWSELALWAYS)) $hListView = GUICtrlGetHandle($cListView) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) ;double buffer improves performance _GUICtrlListView_AddColumn($hListView, "", 298) Global $aTextHdr[4] = ["From:", "Sent:", "To:", "Subject:"] For $row = 1 To 10 _GUICtrlListView_AddItem($hListView, "Rover - AutoIt Forums|Thursday, April 19, 2012 05:0" & $row - 1 & "AM|footswitch|Re: Multiline listview like Outlook|" & _ "This is a rough mock-up of that Outlook listview" & @CRLF & "You will need to add code for the text metrics") Next ;adjust listview size for number of items shown - for efficient painting and to eliminate issue of a click on bottom item causing a jump to next item Local $iY = _GUICtrlListView_ApproximateViewHeight($hListView, _GUICtrlListView_GetCounterPage($hListView)) GUICtrlSetPos($cListView, 2, 2, 320, $iY + 4) Global $cSelect = GUICtrlCreateButton("Themed Select", 2, $iY + 8, 120, 23) Global $cTheme = GUICtrlCreateCombo("Button", 120+2, $iY + 9, 60) GUICtrlSetData(-1, "Listview", "Button") Global $cState = GUICtrlCreateCombo("1 NORMAL", 180+4, $iY + 9, 80) GUICtrlSetData(-1, "2 HOT|3 PRESSED|4 GREYED|5 DEFAULT", "1 NORMAL") Global $cLabel = GUICtrlCreateLabel("Select Item"&@CRLF&"Style", 260+8, $iY + 8) GUISetState() ; Loop until user exits While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $cTheme DllCall($iDllUxtheme, 'uint', 'CloseThemeData', 'ptr', $hTheme) Switch GUICtrlRead($cTheme) Case "Button" $sTheme = "Button" $iThemePart = $BP_PUSHBUTTON GUICtrlSetData($cState, "|1 NORMAL|2 HOT|3 PRESSED|4 GREYED|5 DEFAULT", "1 NORMAL") Case "Listview" $sTheme = "Listview" $iThemePart = $LVP_GROUPHEADER GUICtrlSetData($cState, "|10|11|12|13", "11") EndSwitch $hTheme = DllCall($iDllUxtheme, 'ptr', 'OpenThemeData', 'hwnd', 0, 'wstr', GUICtrlRead($cTheme)) $hTheme = $hTheme[0] $iThemeState = Number(StringLeft(GUICtrlRead($cState), 2)) _WinAPI_InvalidateRect($hListView) Case $cState $iThemeState = Number(StringLeft(GUICtrlRead($cState), 2)) _WinAPI_InvalidateRect($hListView) Case $cSelect If Not $hTheme Then GUICtrlSetData($cSelect, "Themed Select") $hTheme = DllCall($iDllUxtheme, 'ptr', 'OpenThemeData', 'hwnd', 0, 'wstr', $sTheme) $hTheme = $hTheme[0] Else GUICtrlSetData($cSelect, "Unthemed Select") DllCall($iDllUxtheme, 'uint', 'CloseThemeData', 'ptr', $hTheme) $hTheme = 0 EndIf _WinAPI_InvalidateRect($hListView) EndSwitch WEnd GUIDelete() DllCall($iDllUxtheme, 'uint', 'CloseThemeData', 'ptr', $hTheme) _WinAPI_DeleteObject($hPen1) _WinAPI_DeleteObject($hPen2) _WinAPI_DeleteObject($hBrush) For $i = 0 To UBound($aFont) - 1 If $aFont[$i] Then _WinAPI_DeleteObject($aFont[$i]) Next Exit Func WM_MEASUREITEM($hWnd, $Msg, $wParam, $lParam) Local $tMEASUREITEMS = DllStructCreate("uint cType;uint cID;uint itmID;uint itmW;uint itmH;ulong_ptr itmData", $lParam) If DllStructGetData($tMEASUREITEMS, "cType") <> $ODT_LISTVIEW Then Return $GUI_RUNDEFMSG DllStructSetData($tMEASUREITEMS, "itmH", $iListView_row_height) ; row height GUIRegisterMsg($WM_MEASUREITEM, "") ; unregister message handler call this after last ownerdrawn listview created - message no longer sent Return 1 EndFunc ;==>WM_MEASUREITEM Func WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam) Local $tDRAWITEMSTRUCT, $cID, $itmID, $itmAction, $itmState, $hItm, $hDC $tDRAWITEMSTRUCT = DllStructCreate( _ "uint cType;" & _ "uint cID;" & _ "uint itmID;" & _ "uint itmAction;" & _ "uint itmState;" & _ "hwnd hItm;" & _ "handle hDC;" & _ "long itmRect[4];" & _ "ulong_ptr itmData" _ , $lParam) If DllStructGetData($tDRAWITEMSTRUCT, "cType") <> $ODT_LISTVIEW Then Return $GUI_RUNDEFMSG $cID = DllStructGetData($tDRAWITEMSTRUCT, "cID") $itmID = DllStructGetData($tDRAWITEMSTRUCT, "itmID") $itmAction = DllStructGetData($tDRAWITEMSTRUCT, "itmAction") $itmState = DllStructGetData($tDRAWITEMSTRUCT, "itmState") $hItm = DllStructGetData($tDRAWITEMSTRUCT, "hItm") $hDC = DllStructGetData($tDRAWITEMSTRUCT, "hDC") Switch $cID ; will look for ControlID, not window handle. Case $cListView Switch $itmAction Case $ODA_DRAWENTIRE __WM_DRAWITEM_ListView($hItm, $tDRAWITEMSTRUCT, $cID, $itmID, $itmAction, $itmState, $hDC) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_DRAWITEM Func __WM_DRAWITEM_ListView(ByRef $hLV, ByRef $tDRAWITEMSTRUCT, ByRef $cID, ByRef $itmID, ByRef $itmAction, ByRef $itmState, ByRef $hDC) Local $iTxtCol, $bSelected = BitAND($itmState, $ODS_SELECTED), $iTextFormatting = BitOR($DT_LEFT, $DT_WORDBREAK) If Not $bSelected Then $iTxtCol = 0xB79588 Else ;selected $iTxtCol = 0x494949 ;Theme Parts and States ;http://msdn.microsoft.com/en-us/library/windows/desktop/bb773210%28v=vs.85%29.aspx Local $pItemRect = DllStructGetPtr($tDRAWITEMSTRUCT, "itmRect") If $hTheme Then If $sTheme = "Listview" Then Local $tItemRect = DllStructCreate($tagRect, $pItemRect) DllStructSetData($tItemRect, 1, DllStructGetData($tItemRect, 1)+1) DllStructSetData($tItemRect, 2, DllStructGetData($tItemRect, 2)+1) DllStructSetData($tItemRect, 3, DllStructGetData($tItemRect, 3)-1) DllStructSetData($tItemRect, 4, DllStructGetData($tItemRect, 4)-1) $pItemRect = DllStructGetPtr($tItemRect) EndIf DllCall($iDllUxtheme, 'uint', 'DrawThemeBackground', 'ptr', $hTheme, 'hwnd', $hDC, 'int', $iThemePart, 'int', $iThemeState, 'ptr', $pItemRect, 'ptr', 0) Else DllCall($iDllUSER32, "int", "FillRect", "handle", $hDC, "ptr", DllStructGetPtr($tDRAWITEMSTRUCT, "itmRect"), "handle", $hBrush) EndIf EndIf GUICtrlSendMsg($cID, $LVM_GETITEMTEXTW, $itmID, $pLVITEM) Local $aSubItmText = StringSplit(DllStructGetData($tLVText, 1), "|", 2) DllStructSetData($tLVText, 1, "") DllStructSetData($tLVRect, "Top", 0) DllStructSetData($tLVRect, "Left", $LVIR_BOUNDS) GUICtrlSendMsg($cID, $LVM_GETSUBITEMRECT, $itmID, DllStructGetPtr($tLVRect)) Local $iLeft = DllStructGetData($tLVRect, 1) + 6 ;Left Local $iTop = DllStructGetData($tLVRect, 2) ;Top DllStructSetData($tLVRect, 1, $iLeft) ;Left Switch $hLV Case $hListView Local $iColPrev = __WinAPI_SetTextColor($hDC, 0x000000) ;save previous font and text colour Local $hFontOld = __WinAPI_SelectObject($hDC, $aFont[0]) ;Bold ;------------------------------------------------------------ ;multiline, but no per line indentation or colour ;DllStructSetData($tLVRect, 2, $iTop+2) ;__WinAPI_DrawText($hDC, "From:"&@CRLF&"Sent:"&@CRLF&"To:"&@CRLF&"Subject:", $tLVRect, $iTextFormatting) ;------------------------------------------------------------ DllStructSetData($tLVRect, 2, $iTop + 2) __WinAPI_DrawText($hDC, $aTextHdr[0], $tLVRect, $iTextFormatting) DllStructSetData($tLVRect, 2, $iTop + 20) __WinAPI_DrawText($hDC, $aTextHdr[1], $tLVRect, $iTextFormatting) DllStructSetData($tLVRect, 2, $iTop + 38) __WinAPI_DrawText($hDC, $aTextHdr[2], $tLVRect, $iTextFormatting) DllStructSetData($tLVRect, 2, $iTop + 56) __WinAPI_DrawText($hDC, $aTextHdr[3], $tLVRect, $iTextFormatting) __WinAPI_SelectObject($hDC, $aFont[1]) ;Normal ;------------------------------------------------------------ ;multiline, but no per line indentation or colour ;__WinAPI_SetTextColor($hDC, 0x494949) ;DllStructSetData($tLVRect, 1, $iLeft+50) ;DllStructSetData($tLVRect, 2, $iTop+2) ;__WinAPI_DrawText($hDC, $aSubItmText[0]&@CRLF&$aSubItmText[1]&@CRLF&$aSubItmText[2]&@CRLF&$aSubItmText[3], $tLVRect, $iTextFormatting) ;------------------------------------------------------------ __WinAPI_SetTextColor($hDC, 0xFF0000) DllStructSetData($tLVRect, 1, $iLeft + __GUICtrlListView_GetStringWidth($cID, $aTextHdr[0]) + 5) DllStructSetData($tLVRect, 2, $iTop + 2) __WinAPI_DrawText($hDC, $aSubItmText[0], $tLVRect, $iTextFormatting) __WinAPI_SetTextColor($hDC, 0x494949) DllStructSetData($tLVRect, 1, $iLeft + __GUICtrlListView_GetStringWidth($cID, $aTextHdr[1]) + 5) DllStructSetData($tLVRect, 2, $iTop + 20) __WinAPI_DrawText($hDC, $aSubItmText[1], $tLVRect, $iTextFormatting) DllStructSetData($tLVRect, 1, $iLeft + __GUICtrlListView_GetStringWidth($cID, $aTextHdr[2]) + 5) DllStructSetData($tLVRect, 2, $iTop + 38) __WinAPI_DrawText($hDC, $aSubItmText[2], $tLVRect, $iTextFormatting) DllStructSetData($tLVRect, 1, $iLeft + __GUICtrlListView_GetStringWidth($cID, $aTextHdr[3]) + 5) DllStructSetData($tLVRect, 2, $iTop + 56) __WinAPI_DrawText($hDC, $aSubItmText[3], $tLVRect, $iTextFormatting) __WinAPI_SetTextColor($hDC, $iTxtCol) DllStructSetData($tLVRect, 1, $iLeft + 2) DllStructSetData($tLVRect, 2, $iTop + 80) __WinAPI_DrawText($hDC, $aSubItmText[4], $tLVRect, $iTextFormatting) If $bSelected And $hTheme Then Return ;optional - don't paint lines when item selected - in this example only for benefit of themed selected items Local $obj_orig = __WinAPI_SelectObject($hDC, $hPen1) __WinAPI_DrawLine($hDC, $iLeft, DllStructGetData($tLVRect, 4) - 2, 320 - ($iLeft * 2) - 16, DllStructGetData($tLVRect, 4) - 2) __WinAPI_SelectObject($hDC, $hPen2) __WinAPI_DrawLine($hDC, $iLeft, DllStructGetData($tLVRect, 4) - 3, 320 - ($iLeft * 2) - 16, DllStructGetData($tLVRect, 4) - 3) __WinAPI_SelectObject($hDC, $obj_orig) ;__WinAPI_SelectObject($hDC, $hFontOld) ;__WinAPI_SetTextColor($hDC, $iColPrev) EndSwitch Return EndFunc ;==>__WM_DRAWITEM_ListView Func __WinAPI_DrawLine($hDC, $iX1, $iY1, $iX2, $iY2) DllCall($iDllGDI, "bool", "MoveToEx", "handle", $hDC, "int", $iX1, "int", $iY1, "ptr", 0) If @error Then Return SetError(@error, @extended, False) DllCall($iDllGDI, "bool", "LineTo", "handle", $hDC, "int", $iX2, "int", $iY2) If @error Then Return SetError(@error, @extended, False) Return True EndFunc ;==>__WinAPI_DrawLine Func __WinAPI_DrawText(ByRef $hDC, $sText, ByRef $tRect, ByRef $iFlags) DllCall($iDllUSER32, "int", "DrawTextW", "hwnd", $hDC, "wstr", $sText, "int", StringLen($sText), "struct*", $tRect, "int", $iFlags) EndFunc ;==>__WinAPI_DrawText Func __WinAPI_SetTextColor($hDC, $iColor) Local $aResult = DllCall($iDllGDI, "INT", "SetTextColor", "handle", $hDC, "dword", $iColor) If @error Then Return SetError(@error, @extended, -1) Return $aResult[0] EndFunc ;==>__WinAPI_SetTextColor Func __WinAPI_SelectObject($hDC, $hGDIObj) Local $aResult = DllCall($iDllGDI, "handle", "SelectObject", "handle", $hDC, "handle", $hGDIObj) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc ;==>__WinAPI_SelectObject Func __GUICtrlListView_GetStringWidth($hWnd, $sString) Local $tBuffer = DllStructCreate("wchar Text[" & StringLen($sString) + 1 & "]") DllStructSetData($tBuffer, "Text", $sString) Local $iRet = GUICtrlSendMsg($hWnd, $LVM_GETSTRINGWIDTHW, 0, DllStructGetPtr($tBuffer)) Return $iRet EndFunc ;==>__GUICtrlListView_GetStringWidth
    1 point
  8. Unfortunately, it's still not working for me. I tried ports 0-3 as suggested, and anything other than 0 it's not asking for which camera to use any longer, but it still won't turn the camera on. What if you're camera is attached to a different screen than the main one? I have a laptop with the webcam built into the display but I use a 17" monitor as my main screen. The GUI shows up on the monitor but my camera is off to the side.
    1 point
  9. Windows 7 x86 here as well and it even has a dialog popup asking me for what device to use.
    1 point
×
×
  • Create New...