Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/15/2016 in Posts

  1. Here is a way : #include <GUIConstantsEx.au3> #include <WinAPI.au3> GUICreate("gui", 280, 170) $b1 = GUICtrlCreateButton("Bouton1", 10, 10, 100, 25) $b2 = GUICtrlCreateButton("Bouton2", 10, 50, 100, 25) $b3 = GUICtrlCreateButton("Bouton3", 10, 90, 100, 25) $bQuit = GUICtrlCreateButton("Exit", 170, 130, 100, 25 ) $bTabOrder = GUICtrlCreateButton("Arrange tab order", 10, 130, 150, 25 ) $i1 = GUICtrlCreateInput("", 120, 10, 150, 25) $i2 = GUICtrlCreateInput("", 120, 50, 150, 25) $i3 = GUICtrlCreateInput("", 120, 90, 150, 25) Local $aOrder = [$b1, $i1, $b2, $i2, $b3, $i3, $bTabOrder, $bQuit] GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $bTabOrder _GUISetTabOrder($aOrder) EndSwitch WEnd Func _GUISetTabOrder($aId) Local $hCtrl For $i = 0 To UBound($aId) - 1 $hCtrl = (IsHWnd($aId[$i]) ? $aId[$i] : GUICtrlGetHandle($aId[$i])) _WinAPI_SetWindowPos($hCtrl, $HWND_BOTTOM, 0, 0, 0, 0, BitOr($SWP_NOMOVE, $SWP_NOSIZE) ) Next EndFunc
    2 points
  2. *** FREE*** April 9, 2007 Download XProtec.au3 - Free Original XProTec - v1.0.5 - March 18, 2007 XProTec.au3 Previous downloads = 820 +/- Protect and get Paid for.... Your Program Features: *New* Limited Freeware Option Example end user must register. automated email notifications to developer. trial period. user license. registration price. registration reminder. automated registration and acceptance of payment. ( your paypal account ) Syntax: Must be compiled #include<XProTec.au3> ; MUST BE AN INCLUDE $D_Mail = "developer@msn.com " ; your email $D_Program = "My_Program_Name" ; your program name $U_Price = "20.00" ; the amount of money you wish to be payed by the user $U_Trial = "30" ; amount of days for the trial period $U_License = "3" ; 3 = one computer only - see license notes $D_License = "123456789" ; developers license # $D_PayPal = "www.paypal.com/my account-link to paypal" ; - paypal link $D_Link = "www.mywebsite.com/.../" ; looks for "www.mywebsite.com/.../Blacklist.txt" ; see Blacklist $U_Return = 1 ; pay or quit .... or $U_Return = 0 ; will return control to developer with @extended = 6 [Limited Freeware Option] XProTec($D_Mail, $D_Program, $U_Price, $U_Trial, $U_License, $D_License, $D_PayPal, $D_Link, $U_Return) ; your script starts here ..............
    1 point
  3. Post code, and use translator for your question.
    1 point
  4. Or compile older scripts.
    1 point
  5. You can run different versions of AutoIt while you are upgrading your scripts. Extract the zip files for the older AutoIt3 versions with their older libraries and use them. Use the following to set the AutoIt3Wrapper directive to set AutoIt Directory. #AutoIt3Wrapper_Autoit3Dir=C:\Program Files\AutoIt3\3.3.8.1 ;Optionally override the AutoIt3 install directory to use. Adam
    1 point
  6. @Mosses do you think, perhaps, that it would help us help you if you posted your script?
    1 point
  7. Perfect! Posting code takes away a lot of the guessing game and I don't have to spend the time putting together the GUI myself Here's a way to use WM_NOTIFY to get the index of the tab. It appears that WM_MBUTTONDOWN (and UP) are not being received when on a tab so I used the _IsPressed. #include <GUIConstantsEx.au3> #include <Misc.au3> #include <WindowsConstants.au3> #include <GUITab.au3> Global $iTabIndex = -1 Global $hGUI = GUICreate("Window with Tabs", 500, 500) Global $lblId = GUICtrlCreateLabel("ID of clicked control:", 200, 1) Global $hTab = GUICtrlCreateTab(10, 10, 480, 480) For $i = 0 To 2 GUICtrlCreateTabItem("Tab " & $i) GUICtrlCreateButton("Button " & $i, 20 + ($i * 100), 40 + ($i * 50), 80, 30) Next GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch If (_IsPressed(4)) Then DeleteTabItem() WEnd Func DeleteTabItem() If ($iTabIndex > -1) Then _GUICtrlTab_DeleteItem(GUICtrlGetHandle($hTab), $iTabIndex) $iTabIndex = -1 EndIf EndFunc ;==>DeleteTabItem Func WM_NOTIFY($hWndFrom, $iMsg, $wParam, $lParam) #forceref $hWndFrom, $iMsg, $wParam, $lParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $iCode = DllStructGetData($tNMHDR, "Code") Local $iIdFrom = DllStructGetData($tNMHDR, "IDFrom") Switch ($hWndFrom) Case $hGUI Switch ($iCode) Case -530 $iTabIndex = $iIdFrom EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY I'll test a WNDPROC tomorrow, see if it captures the middle mouse click Also, the -530 is used to parse the application for the tooltip text to display. It's in the ToolTipConstants.au3 Global Const $TTN_GETDISPINFOW = $TTN_FIRST - 10 ; [Unicode] Sent to retrieve information needed to display a ToolTip We're not displaying a tooltip but it's a good enough value to use to determine that the tab is being highlighted.
    1 point
  8. Not sure, but maybe something like this ? $var = "aBc$eFg" $res = "" $split = StringSplit($var, "") For $i = 1 to $split[0] If StringIsUpper($split[$i]) or StringRegExp($split[$i], '\W') Then $res &= "{SHIFTDOWN}" & $split[$i] & "{SHIFTUP}" ContinueLoop EndIf $res &= $split[$i] Next Msgbox(0,"", $res)
    1 point
  9. LarsJ

    CustomDraw TreeView

    By drawing the selected item in the postpaint stage: #include <GuiListView.au3> #include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <SQLite.au3> #include <Math.au3> Global Const $tagNMLVCACHEHINT = $tagNMHDR & ";int iFrom;int iTo" Global $aListView, $hListView, $TreeView_SelTitle, $aTreeViewState[19][8] = [[18,"","","","","","",""]], $sSelectedTVIndex = 3 Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 881, 516, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") Global $TreeView = _GUICtrlTreeView_Create($Form1, 8, 16, 319, 489, BitOR($GUI_SS_DEFAULT_TREEVIEW,$WS_HSCROLL,$WS_VSCROLL,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE)) $TreeView_Root_1 = _GUICtrlTreeView_Add($TreeView, 0, "Root - 1") _GUICtrlTreeView_SetIcon($TreeView, $TreeView_Root_1, "shell32.dll", 4) $TreeView_Root_2 = _GUICtrlTreeView_Add($TreeView, 0, "Root - 2") _GUICtrlTreeView_SetIcon($TreeView, $TreeView_Root_2, "shell32.dll", 4) Global $ListView = GUICtrlCreateListView("Rowid|Name|Time|Category", 336, 16, 538, 486, $LVS_OWNERDATA, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE)) ; $LVS_OWNERDATA must be included for a virtual listview _GUICtrlListView_SetExtendedListViewStyle( $ListView, $LVS_EX_DOUBLEBUFFER+$LVS_EX_FULLROWSELECT ) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 88) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 112) GUICtrlSetOnEvent(-1, "ListViewClick") ;------------------------------------------------------------------------------------------ ; Get the font of the TreeView control ; Copied from the _GUICtrlGetFont example by KaFu ; See http://www.autoitscript.com/forum/index.php?showtopic=124526 Local $hDC = _WinAPI_GetDC( $TreeView ) $hFont = _SendMessage( $TreeView, $WM_GETFONT ) Local $hObject = _WinAPI_SelectObject( $hDC, $hFont ) Local $lvLOGFONT = DllStructCreate( $tagLOGFONT ) DllCall( 'gdi32.dll', 'int', 'GetObjectW', 'ptr', $hFont, 'int', DllStructGetSize( $lvLOGFONT ), 'ptr', DllStructGetPtr( $lvLOGFONT ) ) _WinAPI_SelectObject( $hDC, $hObject ) _WinAPI_ReleaseDC( $TreeView, $hDC ) $TreeViewFont = _WinAPI_CreateFontIndirect( $lvLOGFONT ) Local $iWeight = BitOR( DllStructGetData( $lvLOGFONT, "Weight" ), $FW_BOLD ) DllStructSetData( $lvLOGFONT, "Weight", $iWeight ) $TreeViewFontBold = _WinAPI_CreateFontIndirect( $lvLOGFONT ) ;------------------------------------------------------------------------------------------ Local $idTVContextMenu = GUICtrlCreateContextMenu(GUICtrlCreateDummy()) $hTVContextMenu = GUICtrlGetHandle($idTVContextMenu) Local $idTVContextMenu_Refresh = GUICtrlCreateMenuItem("Refresh", $idTVContextMenu) Local $idTVContextMenu_Rename = GUICtrlCreateMenuItem("Rename", $idTVContextMenu) GUICtrlCreateMenuItem("", $idTVContextMenu) ; separator Local $idTVContextMenu_MarkALLRead = GUICtrlCreateMenuItem("Mark ALL Items Read", $idTVContextMenu) Local $idTVContextMenu_MarkALLUnRead = GUICtrlCreateMenuItem("Mark ALL Items UnRead", $idTVContextMenu) ;------------------------------------------------------------------------------------------ GUIRegisterMsg($WM_NOTIFY, "LWS_WM_NOTIFY") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### SubFunction_FillTreeView() While 1 Sleep(100) WEnd Func Form1Close() GUIRegisterMsg( $WM_NOTIFY, "" ) ; Exit EndFunc ;========================================================================================== Func ListViewClick() EndFunc ;========================================================================================== Func TreeView1Click() Local $sQuery, $aResult, $iRows, $iColumns Static Local $TreeView_SelTitlePRE = "" If $TreeView_SelTitlePRE == "" Then $TreeView_Selected = _GUICtrlTreeView_GetFirstChild($TreeView, $TreeView_Root_1) _GUICtrlTreeView_ClickItem($TreeView, $TreeView_Selected, "left") Else $TreeView_Selected = _GUICtrlTreeView_GetSelection($TreeView) EndIf $TreeView_SelTitle = _GUICtrlTreeView_GetText($TreeView, $TreeView_Selected) If $TreeView_SelTitle == $TreeView_SelTitlePRE Then Return Else $TreeView_SelTitlePRE = $TreeView_SelTitle EndIf ConsoleWrite($TreeView_SelTitle & @CRLF) EndFunc ;========================================================================================== Func SubFunction_FillTreeView() ConsoleWrite(" > $sSelected TV Index = " & $sSelectedTVIndex & @CRLF) ConsoleWrite(" > $sSelected TV Name = " & $aTreeViewState[$sSelectedTVIndex][5] & @CRLF) Local $idTVItem[$aTreeViewState[0][0]+1] = [$aTreeViewState[0][0]] _GUICtrlTreeView_BeginUpdate($TreeView) _GUICtrlTreeView_DeleteChildren($TreeView, $TreeView_Root_1) _GUICtrlTreeView_DeleteChildren($TreeView, $TreeView_Root_2) _GUICtrlTreeView_SetTextColor($TreeView, 0x77B5FE) ; color of additional text For $i = 1 To $aTreeViewState[0][0] $aTreeViewState[$i][0] = 3 ; icon num in "shell32.dll" $aTreeViewState[$i][1] = 0x000000 ; item text color $aTreeViewState[$i][2] = 0 ; text is bold (or not) $aTreeViewState[$i][3] = "some info" ; some additional text $aTreeViewState[$i][5] = String("item " & $i); item name Switch Mod($i,2) Case 0 $idTVItem[$i] = _GUICtrlTreeView_AddChild($TreeView,$TreeView_Root_2, $aTreeViewState[$i][5]) Case Else $idTVItem[$i] = _GUICtrlTreeView_AddChild($TreeView,$TreeView_Root_1, $aTreeViewState[$i][5]) EndSwitch Switch Mod($i,3) Case 0 $aTreeViewState[$i][2] = 0 Case Else $aTreeViewState[$i][2] = 1 EndSwitch _GUICtrlTreeView_SetItemParam($TreeView, $idTVItem[$i], $i) _GUICtrlTreeView_SetIcon($TreeView, $idTVItem[$i], "shell32.dll", $aTreeViewState[$i][0]) Next _GUICtrlTreeView_Expand($TreeView, $TreeView_Root_1, True) _GUICtrlTreeView_EndUpdate($TreeView) _GUICtrlTreeView_ClickItem($TreeView, $idTVItem[$sSelectedTVIndex]) SubFunction_FillListView() EndFunc ;========================================================================================== Func SubFunction_FillListView_Delayed() AdlibUnRegister("SubFunction_FillListView_Delayed") SubFunction_FillListView() EndFunc ;========================================================================================== Func SubFunction_FillListView() _GUICtrlListView_BeginUpdate ($ListView) _GUICtrlListView_DeleteAllItems ($ListView) For $i = 0 To 63 $ret = _GUICtrlListView_AddItem($ListView, "Row "&$i&": Col 0") ;ConsoleWrite($i & @TAB & "$ret = " & $ret & @CRLF) _GUICtrlListView_AddSubItem($ListView, $i, "Row "&$i&": Col 1", 1) _GUICtrlListView_AddSubItem($ListView, $i, "Row "&$i&": Col 2", 2) _GUICtrlListView_AddSubItem($ListView, $i, "Row "&$i&": Col 3", 3) Next _GUICtrlListView_EndUpdate ($ListView) EndFunc ;========================================================================================== Func LWS_WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Local Static $tText = DllStructCreate( "wchar[512]" ) Local Static $pText = DllStructGetPtr( $tText ) Local Static $aResult, $iRows, $iFrom Local $tNMHDR, $hWndFrom, $iCode, $tInfo, $VKey $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $TreeView Switch $iCode Case $NM_CUSTOMDRAW Local $tNMTVCUSTOMDRAW = DllStructCreate($tagNMTVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMTVCUSTOMDRAW, "DrawStage") Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any item-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Local $hItemSpec = DllStructGetData($tNMTVCUSTOMDRAW, "ItemSpec") ; $hItemSpec = $hItem Local $iItemState = DllStructGetData($tNMTVCUSTOMDRAW, "ItemState") Local $iItemParam = DllStructGetData($tNMTVCUSTOMDRAW, "ItemParam") ; ItemParam = index in array Local $hDC = DllStructGetData($tNMTVCUSTOMDRAW, "HDC") ; Handle to the item's device context $iSelected = DllCall( "user32.dll", "lresult", "SendMessageW", "hwnd", $TreeView, "uint", $TVM_GETITEMSTATE, "wparam", $hItemSpec, "lparam", $TVIS_SELECTED )[0] ; Selected state If BitAND( $iSelected, $TVIS_SELECTED ) Then Return $CDRF_NOTIFYPOSTPAINT ;If Not BitAnd( $iItemState, $CDIS_FOCUS ) Then DllStructSetData( $tNMTVCUSTOMDRAW, "ClrText", $aTreeViewState[$iItemParam][1] ) ; Forecolor of item text ;DllStructSetData( $tNMTVCUSTOMDRAW, "clrTextBk",$aTreeViewState[$iItemParam][1] ) ; Backcolor of item text Local $tRECT = _GUICtrlTreeView_DisplayRectEx ( $TreeView, $hItemSpec, True) DllStructSetData( $tRECT, "Left", DllStructGetData( $tRECT, "Right") + 7) DllStructSetData( $tRECT, "Right", DllStructGetData( $tRECT, "Right") + 188) _WinAPI_DrawText( $hDC, $aTreeViewState[$iItemParam][3], $tRECT, $DT_LEFT ) ; and background color of the device context. _GUICtrlTreeView_SetBold ($TreeView, $hItemSpec, $aTreeViewState[$iItemParam][2]) ;Else ;_GUICtrlTreeView_SetBold ($TreeView, $hItemSpec, $aTreeViewState[$iItemParam][2]) ;EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors Case $CDDS_ITEMPOSTPAINT Local $hItemSpec = DllStructGetData($tNMTVCUSTOMDRAW, "ItemSpec") ; $hItemSpec = $hItem Local $iItemState = DllStructGetData($tNMTVCUSTOMDRAW, "ItemState") Local $iItemParam = DllStructGetData($tNMTVCUSTOMDRAW, "ItemParam") ; ItemParam = index in array Local $hDC = DllStructGetData($tNMTVCUSTOMDRAW, "HDC") ; Handle to the item's device context Local $tRECT = _GUICtrlTreeView_DisplayRectEx( $TreeView, $hItemSpec, True) DllStructSetData( $tRECT, "Left", DllStructGetData( $tRECT, "Right") + 7) DllStructSetData( $tRECT, "Right", DllStructGetData( $tRECT, "Right") + 188) ;DllStructSetData( $tNMTVCUSTOMDRAW, "ClrText", $aTreeViewState[$iItemParam][1] ) ; Forecolor of item text DllCall( "gdi32.dll", "int", "SetTextColor", "handle", $hDC, "int", 0xFEB577 ) ; 0x77B5FE _WinAPI_SelectObject( $hDC, $aTreeViewState[$iItemParam][2] ? $TreeViewFontBold : $hFont ) ; Bold/normal font _WinAPI_DrawText( $hDC, $aTreeViewState[$iItemParam][3], $tRECT, $DT_LEFT ) ; and background color of the device context. _GUICtrlTreeView_SetBold ($TreeView, $hItemSpec, $aTreeViewState[$iItemParam][2]) Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch Case $TVN_SELCHANGEDA, $TVN_SELCHANGEDW AdlibRegister("SubFunction_FillListView_Delayed",300) _WinAPI_RedrawWindow($TreeView) Case $NM_RCLICK Local $tMPos = _WinAPI_GetMousePos(True, $hWndFrom) ; ?????????? ???????????? ???????? Local $hItem = _GUICtrlTreeView_HitTestItem($hWndFrom, DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2)) ; ???????? ?????????? ?????? If $hItem <> -1 And $hItem <> 0x0 Then DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hTVContextMenu, "int", 0, "int", MouseGetPos(0), "int", MouseGetPos(1), "hwnd", $Form1, "ptr", 0) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc
    1 point
  10. Fun topic. Made an example in VBA Algorithm I would propose to you when you write it in AutoIT (Nice in the future another coworker will not ask for a password but for a decompiler on the exe you distribute) a. Create basic csv file from AutoIT with right headers b. Just remotely control xlApp to read the file c. All you then have to do is apply formatting and calculation of lastrow and lastcolumn (including alpha column character) Option Explicit Dim strFileName As String 'Filename with basic salesdata with or without header Dim xlApp As Application Dim xlWbSales As Workbook 'Workbook with the results Dim ws As Worksheet 'short reference to first worksheet of salesworkbook Dim tData 'Just a variant for easy title / splitting array directly to range of cells Dim lastRow As Long Dim lastCol As Long Dim lastColAlpha As String 'Column character Dim strRange As String Dim strFormula As String Dim tCell As Range 'short naming references for easy reading Dim tRange As Range 'short naming references for easy reading 'CSV sample layout 'Site;Supplier name;HPL;Item-type;Item number;Quantity ' 49500;s1 ;asdf ;123 ;;1 ' 49500;s1 ;asdf ;123 ;;2 ' 49500;s1 ;asdf ;123 ;;3 ' 49500;s1 ;asdf ;123 ;;4 ' 49500;s1 ;asdf ;123 ;;5 ' 49500;s1 ;asdf ;123 ;;6 ' 49500;s1 ;asdf ;123 ;;7 ' 49500;s1 ;asdf ;123 ;;8 ' 49500;s1 ;asdf ;123 ;;9 ' 49500;s1 ;asdf ;123 ;;10 Sub MakeSalesReport() Set xlApp = Application 'For easy translation to AutoIt strFileName = Environ("TEMP") & "\salesdata.csv" 'I did put the CSV in my temp location 'Import the CSV data Set xlWbSales = xlApp.Workbooks.Open(Filename:=strFileName, local:=True) 'Just a new workbook based on the csv read in and local makes it split csv directyl 'Find the last row and last column Set ws = xlWbSales.Worksheets(1) 'Tricky this should be possible in a different way ws.Activate ActiveWindow.DisplayGridlines = False lastRow = ws.Cells(1, 1).SpecialCells(xlLastCell).Row + 1 lastCol = ws.Cells(1, 1).SpecialCells(xlLastCell).Column lastColAlpha = Chr(65 + lastCol - 1) 'For easy range making assuming less then 26 columns 'Do the formatting ws.Rows(1).Insert lastRow = lastRow + 1 'Add the title header either with a cells or range reference ws.Cells(1, 1).Value = "Purchase Price Variance report as on " & Format(Now(), "dd-mmm-yyyy") With ws.Range("A1").Font .Name = "Arial Black" .Size = 14 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ThemeColor = xlThemeColorLight1 .TintAndShade = 0 .ThemeFont = xlThemeFontNone End With 'Suppose titles are specific and not in the csvfile tData = Split("Site;Supplier name;HPL;Item-Type;Item Number;Quantity", ";") 'Check if no header and insert it If UCase(Trim(ws.Cells(2, 1))) <> "SITE" Then ws.Rows(2).Insert lastRow = lastRow + 1 ws.Range("A2:" & lastColAlpha & "2") = tData End If 'Format the header strRange = "A2:" & lastColAlpha & "2" With ws.Range(strRange).Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .Color = 12611584 .TintAndShade = 0 .PatternTintAndShade = 0 End With With ws.Range(strRange).Font .Name = "Arial Black" .Size = 14 .ThemeColor = xlThemeColorDark1 .TintAndShade = 0 End With 'Add total and sum on last row Set tCell = ws.Cells(lastRow, 1) tCell.Value = "Total" With tCell.Font .Name = "Arial Black" .Size = 14 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ThemeColor = xlThemeColorLight1 .TintAndShade = 0 .ThemeFont = xlThemeFontNone End With 'Sum cell Set tCell = ws.Cells(lastRow, lastCol) strFormula = "=SUM(" & lastColAlpha & "3:" & lastColAlpha & lastRow - 1 & ")" tCell.Formula = strFormula With tCell.Font .Name = "Arial Black" .Size = 14 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ThemeColor = xlThemeColorLight1 .TintAndShade = 0 .ThemeFont = xlThemeFontNone End With tCell.Style = "Comma" tCell.NumberFormat = "_ * #,##0_ ;_ * -#,##0_ ;_ * ""-""??_ ;_ @_ " 'Do all the formatting stuff setStyle tCell, xlEdgeLeft setStyle tCell, xlEdgeTop setStyle tCell, xlEdgeBottom setStyle tCell, xlEdgeRight setStyle tCell, xlInsideVertical setStyle tCell, xlInsideHorizontal strRange = "A2:" & lastColAlpha & lastRow - 1 Set tRange = ws.Range(strRange) setStyle tRange, xlEdgeLeft setStyle tRange, xlEdgeTop setStyle tRange, xlEdgeBottom setStyle tRange, xlEdgeRight setStyle tRange, xlInsideVertical setStyle tRange, xlInsideHorizontal 'Add an empty row and empty column ws.Columns(1).Insert ws.Rows(1).Insert ws.Columns.AutoFit ws.Columns(2).EntireColumn.ColumnWidth = 12 End Sub Sub setStyle(r As Range, c As Long) With r.Borders(c) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With End Sub
    1 point
  11. Thanks for sharing. Let me share with you another example using WinHTTP.au3 > https://www.autoitscript.com/forum/topic/84133-winhttp-functions/ A friend gave this code to me a while ago while helping me. #include "WinHttp.au3" ; Download some gif ;~ http://33.media.tumblr.com/dd3ffab90cc338666f192fd86f6a4f8f/tumblr_n0pefhIpss1swyb6ao1_500.gif ; Initialize and get session handle $hOpen = _WinHttpOpen() ; Get connection handle $hConnect = _WinHttpConnect($hOpen, "http://33.media.tumblr.com") ; Specify the reguest $hRequest = _WinHttpOpenRequest($hConnect, Default, "dd3ffab90cc338666f192fd86f6a4f8f/tumblr_n0pefhIpss1swyb6ao1_500.gif") ; Send request _WinHttpSendRequest($hRequest) ; Wait for the response _WinHttpReceiveResponse($hRequest) ;~ ConsoleWrite(_WinHttpQueryHeaders($hRequest) & @CRLF) ProgressOn("Downloading", "In Progress...") Progress(_WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_CONTENT_LENGTH)) Local $sData ; Check if there is data available... If _WinHttpQueryDataAvailable($hRequest) Then While 1 $sChunk = _WinHttpReadData_Ex($hRequest, Default, Default, Default, Progress) If @error Then ExitLoop $sData &= $sChunk Sleep(20) WEnd Else MsgBox(48, "Error", "Site is experiencing problems (or you).") EndIf Sleep(1000) ProgressOff() ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Do whatever with data, write to some file or whatnot. I'll just print it to console here: ConsoleWrite($sData & @CRLF) Local $hFile = FileOpen(@DesktopDir & "\test.gif", 26) FileWrite($hFile, $sData) FileClose($hFile) Func Progress($iSizeAll, $iSizeChunk = 0) Local Static $iMax, $iCurrentSize If $iSizeAll Then $iMax = $iSizeAll $iCurrentSize += $iSizeChunk Local $iPercent = Round($iCurrentSize / $iMax * 100, 0) ProgressSet($iPercent, $iPercent & " %") EndFunc Func _WinHttpReadData_Ex($hRequest, $iMode = Default, $iNumberOfBytesToRead = Default, $pBuffer = Default, $vFunc = Default) __WinHttpDefault($iMode, 0) __WinHttpDefault($iNumberOfBytesToRead, 8192) __WinHttpDefault($vFunc, 0) Local $tBuffer, $vOutOnError = "" If $iMode = 2 Then $vOutOnError = Binary($vOutOnError) Switch $iMode Case 1, 2 If $pBuffer And $pBuffer <> Default Then $tBuffer = DllStructCreate("byte[" & $iNumberOfBytesToRead & "]", $pBuffer) Else $tBuffer = DllStructCreate("byte[" & $iNumberOfBytesToRead & "]") EndIf Case Else $iMode = 0 If $pBuffer And $pBuffer <> Default Then $tBuffer = DllStructCreate("char[" & $iNumberOfBytesToRead & "]", $pBuffer) Else $tBuffer = DllStructCreate("char[" & $iNumberOfBytesToRead & "]") EndIf EndSwitch Local $sReadType = "dword*" If BitAND(_WinHttpQueryOption(_WinHttpQueryOption(_WinHttpQueryOption($hRequest, $WINHTTP_OPTION_PARENT_HANDLE), $WINHTTP_OPTION_PARENT_HANDLE), $WINHTTP_OPTION_CONTEXT_VALUE), $WINHTTP_FLAG_ASYNC) Then $sReadType = "ptr" Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpReadData", _ "handle", $hRequest, _ "struct*", $tBuffer, _ "dword", $iNumberOfBytesToRead, _ $sReadType, 0) If @error Or Not $aCall[0] Then Return SetError(1, 0, "") If Not $aCall[4] Then Return SetError(-1, 0, $vOutOnError) If IsFunc($vFunc) Then $vFunc(0, $aCall[4]) If $aCall[4] < $iNumberOfBytesToRead Then Switch $iMode Case 0 Return SetExtended($aCall[4], StringLeft(DllStructGetData($tBuffer, 1), $aCall[4])) Case 1 Return SetExtended($aCall[4], BinaryToString(BinaryMid(DllStructGetData($tBuffer, 1), 1, $aCall[4]), 4)) Case 2 Return SetExtended($aCall[4], BinaryMid(DllStructGetData($tBuffer, 1), 1, $aCall[4])) EndSwitch Else Switch $iMode Case 0, 2 Return SetExtended($aCall[4], DllStructGetData($tBuffer, 1)) Case 1 Return SetExtended($aCall[4], BinaryToString(DllStructGetData($tBuffer, 1), 4)) EndSwitch EndIf EndFunc Now this is how you download a file with progessbar
    1 point
  12. I changed the Case statement from : Case 7 to: Case 6,7,8 $gobjWMI_CIMV2 = ObjGet("winmgmts:\\.\root\cimv2") $gobjWMI_PowerEVT_Sink = ObjCreate("WbemScripting.SWbemSink") ObjEvent($gobjWMI_PowerEVT_Sink, "__PowerEVT_SINK_") $gobjWMI_CIMV2.ExecNotificationQueryAsync($gobjWMI_PowerEVT_Sink, "Select EventType from Win32_PowerManagementEvent") While Sleep(100) WEnd Func __PowerEVT_SINK_OnObjectReady($wmiObject, $wmiAsyncContext) Switch $wmiObject.EventType Case 6,7,8 ; RESUME CRITICAL/SUSPEND/STANDBY = 6/7/8 MsgBox(64+262144, Default, "OS reports resume from suspend is complete", 0) ShellExecute(@ScriptDir & "\force_start_wifi.exe") EndSwitch EndFunc ;==>__PowerEVT_SINK_OnObjectReady
    1 point
  13. It is a lot easier if you post your effert here. Question: Did you try and compile your script as CUI and run the exe? Example: #AutoIt3Wrapper_Change2CUI=y $sResponse = $cmdLine[1] ConsoleWrite("You Entered: " & $sResponse & @CRLF)
    1 point
×
×
  • Create New...