Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/08/2021 in all areas

  1. Hi I was looking for a way to detect if the workstation is locked on all Windows platforms and could not find a working solution in this thread. The original thread seems to have diverted from its original topic, so I thought a new topic would be more appropriate. So after reading this and this and this and this and this and this, I wrote the following which seems to work, and I'd like to hear your opinion (perhaps it can be improved). Btw, IsWorkstationLockedModern() seems more resource consuming than IsWorkstationLockedLegacy() but if, for some reason, it is preferred over the latter, it may still be used on Windows 7 and Windows Server 2008 R2, by excluding them from IsLegacyOS(), and checking for SessionFlags==1 instead of 0 (due to a Windows bug; this is explained in the last "this" link). Func IsWorkstationLocked() If (IsLegacyOS()) Then Return IsWorkstationLockedLegacy() Else Return IsWorkstationLockedModern() EndIf EndFunc Func IsLegacyOS() Return ((@OSVersion == "WIN_2008R2") OR (@OSVersion == "WIN_2008") OR (@OSVersion == "WIN_7") OR (@OSVersion == "WIN_VISTA") OR (@OSVersion == "WIN_2003") OR (@OSVersion == "WIN_XP") OR (@OSVersion == "WIN_XPe") OR (@OSVersion == "WIN_2000")) EndFunc Func IsWorkstationLockedLegacy() Local Const $DESKTOP_SWITCHDESKTOP = 0x100 Local $hUser32dll = DllOpen("user32.dll") Local $hDesktop = DllCall($hUser32dll, "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", $DESKTOP_SWITCHDESKTOP) If ((@error) OR ($hDesktop[0] == 0)) Then Return SetError(1, 0, False) EndIf Local $result = DllCall($hUser32dll, "int", "SwitchDesktop", "int", $hDesktop[0]) Local $isLocked = ($result[0] == 0) DllCall($hUser32dll, "int", "CloseDesktop", "int", $hDesktop[0]) DllClose($hUser32dll) Return $isLocked EndFunc Func IsWorkstationLockedModern() Local Const $WTS_CURRENT_SERVER_HANDLE = 0 Local Const $WTS_CURRENT_SESSION = -1 Local Const $WTS_SESSION_INFO_EX = 25 Local $hWtsapi32dll = DllOpen("Wtsapi32.dll") Local $result = DllCall($hWtsapi32dll, "int", "WTSQuerySessionInformation", "int", $WTS_CURRENT_SERVER_HANDLE, "int", $WTS_CURRENT_SESSION, "int", $WTS_SESSION_INFO_EX, "ptr*", 0, "dword*", 0) If ((@error) OR ($result[0] == 0)) Then Return SetError(1, 0, False) EndIf Local $buffer_ptr = $result[4] Local $buffer_size = $result[5] Local $buffer = DllStructCreate("uint64 SessionId;uint64 SessionState;int SessionFlags;byte[" & $buffer_size - 20 & "]", $buffer_ptr) Local $isLocked = (DllStructGetData($buffer, "SessionFlags") == 0) $buffer = 0 DllCall($hWtsapi32dll, "int", "WTSFreeMemory", "ptr", $buffer_ptr) DllClose($hWtsapi32dll) Return $isLocked EndFunc
    2 points
  2. hwȳ dost thou twēo ...if you are really old. (i apologise for all of us for the off topic 😛 )
    2 points
  3. #Include <Array.au3> Global $Cookie[4] = ["Cookie: CookieCode001=a%3A4%3A%7Bi%3A0%%3A0%3B%7D; PHPSESSID=aaq4rde1ir38ei0bpmdr2hq2b7", _ "Cookie: PHPSESSID=aaq4rde1ir38ei0bpmdr2hq2b7; CookieCode002=b%3A4%3A%7Bi%3A0%%3A0%3B%7D", _ "Cookie: PHPSESSID=orju6tvclk878bsdp8l3uo9ri2", _ "Cookie: PHPSESSID=ppmgeudm7cdtnsk18fevp49743"] For $i = 0 To 3 $CookieRegExp = StringRegExp($Cookie[$i], '(\w+)=([a-z%0-9A-Z]+(?:; )?)', 3) If IsArray($CookieRegExp) Then ; _ArrayDisplay($CookieRegExp) $txt = "" For $j = 0 To UBound($CookieRegExp)-1 step 2 $txt &= $CookieRegExp[$j] & "=" & $CookieRegExp[$j+1] Next ConsoleWrite("Cookies : " & $txt & @CRLF) EndIf Next Edit Doubts, you still have ?
    2 points
  4. sudeepjd

    Excel Pivot Tables UDF

    I was looking for a UDF using which I could Add and Update Pivot tables and Pivot Charts in Excel easily and could not find one that I could use. So I build this UDF. It has the following functions : _ExcelPivot_CreateCache ; Easily Create a pivot table data cache from a Sheet _ExcelPivot_CreateTable ; Create a table from a cache at a specified location on the sheet _ExcelPivot_RefreshTable ; Refresh the datatable data with a new cache _ExcelPivot_AddField ; Add a Field and Aggregate function to the Datatable _ExcelPivot_AddFilter ; Adds in the Filter to a specific field _ExcelPivot_ClearFilter ; Removes the filter for a field or all the filters in the table _ExcelPivot_GetRange ; Get specific areas of a Pivot as a Range Object _ExcelPivot_AddChart ; Add a Pivot Chart linked to a specific Pivot table Attached the UDF to this post. Please do let me know if I can improve or add additional functions to it. A detailed example on the usage is below. The excel file and the example can be downloaded from the Example.zip file attached. #include "ExcelPivot.au3" $oExcel = _Excel_Open() $oBook = _Excel_BookOpen($oExcel, @ScriptDir & "\TestPivot.xlsx") ;Create a Sheet to put the pivot into $pSheet = _Excel_SheetAdd($oBook, -1, False, 1) $pSheet.Name = "Pivot" ;Get the cache for the pivot table $pCache = _ExcelPivot_CreateCache($oBook, "Data") ;Add in the Pivot Table from the Cache _ExcelPivot_CreateTable($pCache, $pSheet, "A1", "FruitsPivot") ;Add in the Fields into the Pivot _ExcelPivot_AddField($pSheet, "FruitsPivot", "Category", "Filter") _ExcelPivot_AddField($pSheet, "FruitsPivot", "Product", "Row") _ExcelPivot_AddField($pSheet, "FruitsPivot", "Amount", "Value", "Sum", 1) ;Add in a Running total to the Pivot _ExcelPivot_AddField($pSheet, "FruitsPivot", "Amount", "Value", "Sum", 2, "PercentageRunningTotal", "Product") ;Filter only the fruits _ExcelPivot_Filter($pSheet, "FruitsPivot", "Category", "Fruit") ;Draw a Paretto Chart $chart = _ExcelPivot_AddChart($oBook, $pSheet, "FruitsPivot", "ColumnClustered", "Paretto", "E2", 570) $chart.Chart.FullSeriesCollection(1).ApplyDataLabels $chart.Chart.FullSeriesCollection(2).ChartType = 4 ;Change the percentage to a line graph $chart.Chart.FullSeriesCollection(2).AxisGroup = 2 ;Move it to secondary axis $chart.Chart.Axes(2, 2).MaximumScale = 1 ;Adjust to scale to 100% max ExcelPivot.au3 Example.zip
    1 point
  5. Here is modification which reacts on each keypress: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #Region ### START Koda GUI section ### $Form1_1 = GUICreate("Form1", 372, 218, 192, 124) GUISetBkColor(0x008080) $idUsername = GUICtrlCreateInput("Username", 35, 56, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $idUseremail = GUICtrlCreateInput("email", 35, 84, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_LOWERCASE,$ES_READONLY)) $idPassword = GUICtrlCreateInput("password", 35, 112, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Computer = GUICtrlCreateLabel("Computer Setup", 80, 8, 213, 34) GUICtrlSetFont(-1, 18, 400, 0, "Showcard Gothic") $Exit = GUICtrlCreateButton("Exit", 216, 168, 123, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Exit Exit EndSwitch WEnd Func WM_COMMAND($hWinHandle, $iMsg, $wParam, $lParam) If _WinAPI_LoWord($wParam) = $idUsername And _WinAPI_HiWord($wParam) = $EN_CHANGE Then GUICtrlSetData($idUseremail, GUICtrlRead($idUsername) & "@email.com") EndIf EndFunc
    1 point
  6. Welcome, Great you need something so seems like you have a nice task ahead to make a translation! ....AND ... Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states: Moderation Team
    1 point
  7. Why have you doubts ? BTW the [^;]* thing is currently useless
    1 point
  8. Bot, Or this: #include <GUIConstantsEx.au3> #include <WinAPI.au3> $hGUI = GUICreate("Test", 500, 500) $hLabel = GUICtrlCreateLabel("Here", 10, 10, 80, 30) GUICtrlSetBkColor(-1, 0xFFCCCC) $hButton = GUICtrlCreateButton("Coords", 10, 50, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton $aPos = ControlGetPos($hGUI, "", $hLabel) MsgBox(0, "Position", "Relative to GUI:" & @CRLF & $aPos[0] & " - " & $aPos[1]) $tPoint = DllStructCreate("int X;int Y") DllStructSetData($tpoint, "X", $aPos[0]) DllStructSetData($tpoint, "Y", $aPos[1]) _WinAPI_ClientToScreen($hGUI, $tPoint) MsgBox(0, "Position", "Relative to Screen:" & @CRLF & DllStructGetData($tpoint, "X") & " - " & DllStructGetData($tpoint, "Y")) EndSwitch WEnd Move the GUI around and see how the results change! M23
    1 point
×
×
  • Create New...