Leaderboard
Popular Content
Showing content with the highest reputation on 07/31/2019 in all areas
-
ListUserSessions
BigDaddyO reacted to argumentum for a topic
..was looking for UserName from SessionID so I put this together #include <Debug.au3> ; for _DebugArrayDisplay() ; all you can get from _WTSQuerySessionInformation() Global $i = _WTSQuerySessionInformation(-1, 4) ; current user's SessionId Global $__a_WTS_INFO_CLASS = StringSplit("WTSInitialProgram,WTSApplicationName,WTSWorkingDirectory,WTSOEMId,WTSSessionId,WTSUserName," & _ "WTSWinStationName,WTSDomainName,WTSConnectState,WTSClientBuildNumber,WTSClientName,WTSClientDirectory,WTSClientProductId,WTSClientHardwareId," & _ "WTSClientAddress,WTSClientDisplay,WTSClientProtocolType,WTSIdleTime,WTSLogonTime,WTSIncomingBytes,WTSOutgoingBytes,WTSIncomingFrames," & _ "WTSOutgoingFrames,WTSClientInfo,WTSSessionInfo,WTSSessionInfoEx,WTSConfigInfo,WTSValidationInfo,WTSSessionAddressV4,WTSIsRemoteSession", ",", 2) For $n = 0 To UBound($__a_WTS_INFO_CLASS) -1 ConsoleWrite($n & @TAB & StringLeft($__a_WTS_INFO_CLASS[$n] & ' ________________', 24) & " " & _WTSQuerySessionInformation($i, $n, 1) & @CRLF) Next Global $a = ListUserSessions() _DebugArrayDisplay($a, "ListUserSessions()") Func ListUserSessions() ; mod. of https://www.autoitscript.com/forum/topic/139774-dllcall-and-returned-pointers/?do=findComment&comment=980850 Local $_Self_SessionId = _WTSQuerySessionInformation(-1, 4) ; -1 = current user ; 4 = WTSSessionId Local Enum $e_IsSelf_SessionId, $e_SessionName, $e_UserName, $e_SessionId, $e_StateName, $e_StateInt, $e_ClientName, $e_ClientIp, $e_Domain, $e_UBound Local Const $tagWTS_SESSION_INFO = 'dword SessionId;ptr WinStationName;uint State' Local $aResult = DllCall('wtsapi32.dll', 'int', 'WTSEnumerateSessionsW', 'ptr', 0, 'dword', 0, 'dword', 1, 'ptr*', 0, 'dword*', 0) If @error Or $aResult[0] = 0 Then Return SetError(1, 0, "") ; https://docs.microsoft.com/en-us/windows/desktop/api/wtsapi32/ne-wtsapi32-_wts_connectstate_class Local $aConnectionState = StringSplit("Active,Connected,ConnectQuery,Shadow,Disconnected,Idle,Listen,Reset,Down,Init", ",", 2) Local $tInfo, $Offset = 0, $c = 0, $aReturn[$aResult[5] + 1][$e_UBound] ; $e_UBound is the last enumerator, just to determine the size of the array $aReturn[0][$e_SessionId] = "ID" $aReturn[0][$e_SessionName] = "SessionName" $aReturn[0][$e_StateInt] = "StateInt" $aReturn[0][$e_StateName] = "State" $aReturn[0][$e_UserName] = "UserName" $aReturn[0][$e_ClientName] = "ClientName" $aReturn[0][$e_ClientIp] = "ClientIp" $aReturn[0][$e_Domain] = "Domain" For $i = 1 To $aResult[5] $tInfo = DllStructCreate($tagWTS_SESSION_INFO, $aResult[4] + $Offset) $Offset += DllStructGetSize($tInfo) $c += 1 $aReturn[$c][$e_SessionId] = DllStructGetData($tInfo, 'SessionId') $aReturn[$c][$e_SessionName] = DllStructGetData(DllStructCreate('wchar[1024]', DllStructGetData($tInfo, 'WinStationName')), 1) $aReturn[$c][$e_StateInt] = DllStructGetData($tInfo, 'State') If UBound($aConnectionState) > $aReturn[$c][$e_StateInt] Then $aReturn[$c][$e_StateName] = $aConnectionState[$aReturn[$c][$e_StateInt]] $aReturn[$c][$e_UserName] = _WTSQuerySessionInformation($aReturn[$c][$e_SessionId], 5) ; WTSUserName $aReturn[$c][$e_ClientName] = _WTSQuerySessionInformation($aReturn[$c][$e_SessionId], 10) ; WTSClientName $aReturn[$c][$e_ClientIp] = _WTSQuerySessionInformation($aReturn[$c][$e_SessionId], 14) ; WTSClientAddress $aReturn[$c][$e_Domain] = _WTSQuerySessionInformation($aReturn[$c][$e_SessionId], 7) ; WTSDomainName $aReturn[0][$e_IsSelf_SessionId] = $c If $_Self_SessionId = $aReturn[$c][$e_SessionId] Then $aReturn[$c][$e_IsSelf_SessionId] = 1 Else $aReturn[$c][$e_IsSelf_SessionId] = 0 EndIf Next DllCall('wtsapi32.dll', 'none', 'WTSFreeMemory', 'ptr', $aResult[4]) Return $aReturn EndFunc ;==>ListUserSessions Func _WTSQuerySessionInformation($SessionId, $WTSInfoClass = 10, $iReturnAsIs = 0) ; mod. of https://www.autoitscript.com/forum/topic/134679-get-hostname-of-the-client-connected-to-the-terminalserver-session/ Local $aResult = DllCall("Wtsapi32.dll", "int", "WTSQuerySessionInformation", "Ptr", 0, "int", $SessionId, "int", $WTSInfoClass, "ptr*", 0, "dword*", 0) If @error Or $aResult[0] = 0 Then Return SetError(1, 0, "") Local $ip = DllStructGetData(DllStructCreate("byte[" & $aResult[5] & "]", $aResult[4]), 1) DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $aResult[4]) If $iReturnAsIs Then Return $ip Switch $WTSInfoClass ; https://docs.microsoft.com/en-us/windows/desktop/api/wtsapi32/ns-wtsapi32-_wts_client_address Case 4 ; WTSSessionId Return Int('0x' & StringTrimRight(StringReverse($ip), 3)) Case 14 ; WTSClientAddress If Not (Int(StringLeft($ip, 4)) = 2) Then ; IPv4 $ip = "" Else $ip = Dec(StringMid($ip, 15, 2)) & '.' & Dec(StringMid($ip, 17, 2)) & '.' & Dec(StringMid($ip, 19, 2)) & '.' & Dec(StringMid($ip, 21, 2)) EndIf EndSwitch Return StringReplace(BinaryToString($ip), Chr(0), "") EndFunc ;==>_GetWTSClientName1 point -
$aTableData[Row][Column] nb: Use _ArrayDisplay($aTableData) to show the exact row/columns1 point
-
You will need to use something around this : #include <IE.au3> Local $oIE = _IECreate ("put your full url here") Local $oSubmit = _IEGetObjById($oIE, "filterButton") _IEAction($oSubmit, "click") _IELoadWait($oIE)1 point
-
1 point
-
ControlTreeView With x64 System
seadoggie01 reacted to Nine for a topic
I see. Then compile it as a .a3x. AV shouldn't detect virus in those...1 point -
i want to open all files(.ppt/.jpg/.png..)in a folder..
seadoggie01 reacted to JLogan3o13 for a topic
@pallavii please stop spamming the forum because you're impatient.1 point -
GuiCtrlRead + StringSplit on @CRLF or @LF1 point
-
Searching folder from different drive
FrancescoDiMuro reacted to Deye for a topic
Found some spare time to test it out, Came up with this * Will list all root folders to an $aArray then recursively search each instance For faster returns the trick is to include as much of folders to ignore especially if they are going to be searched first (alphabetically) and happen to contain many files and folders .. #include <File.au3> $sSearchFolder = "SomeUniqueFolderName " $sStartDir = "D:\" $sSkip = "doc*;desk*" ;ignore named MsgBox(0, '', _SerchFolder($sStartDir, $sSearchFolder)) Func _SerchFolder($sStartDir, $sSearchFolder) Local $aArray = _FileListToArrayRec($sStartDir, "*|" & $sSkip, $FLTAR_FOLDERS, Default, Default, 2), $atmp For $i = 1 To UBound($aArray) - 1 $atmp = _FileListToArrayRec($aArray[$i], $sSearchFolder, $FLTAR_FOLDERS, $FLTAR_RECUR, Default, 2) If $atmp <> "" Then Return $atmp[1] Next EndFunc ;==>_SerchFolder Edit: just noticed that you are probably only looking for root folders .. Then what Nine suggested .. That And that my example wont do anything for the root folders Deye1 point -
shake a window
badcoder123 reacted to Malkey for a topic
Yes Sir. Use Shift-Alt-s on this example. ; Modified version of "Shake Window" by Death Pax <death_pax@msn.com> from ; https://www.autoitscript.com/forum/topic/22277-new-scrap-shake-window/ ; Press Shift-Alt-a keys together and current window with focus will shake up and down. ; Press Shift-Alt-s keys together and current window with focus will shake circular. HotKeySet("{ESC}", "Terminate") HotKeySet("+!a", "_ShakeWindow") ; Shift-Alt-a HotKeySet("+!s", "_ShakeWindow2") ; Shift-Alt-s While Sleep(100) WEnd Func _ShakeWindow() Local $Window = WinGetTitle("", ""), $ShakeAmount = 5, $Win_pos = WinGetPos($Window) For $i = 0 To 100 WinMove($Window, "", $Win_pos[0], $Win_pos[1] + $ShakeAmount * Mod($i, 2)) Sleep(40) Next EndFunc ;==>_ShakeWindow Func _ShakeWindow2() Local $Window = WinGetTitle("", ""), $R = 50, $Win_pos = WinGetPos($Window), $pi = 4 * ATan(1) Local $Win_pos = WinGetPos($Window), $centerX = $Win_pos[0], $centerY = $Win_pos[1] For $i = 0 To 20 * $pi Step $pi / 8 WinMove($Window, "", $centerX + ($R * Cos($i)), $centerY + ($R * Sin($i))) Sleep(10) Next WinMove($Window, "", $centerX, $centerY) EndFunc ;==>_ShakeWindow2 Func Terminate() Exit EndFunc ;==>Terminate1 point -
Set width of your label to the same value as width of your GUI form and set label's style to SS_CENTER.1 point
-
mikell, You took the words right out of my mouth! Ebola57, Here is an example for you - you will need to play with the GUI size to exactly fill your screen: #include <GUIConstantsEx.au3> #include "GUIScrollbars_Ex.au3" $hGUI = GUICreate("Test", @DesktopWidth - 50, @DesktopHeight - 50) GUISetBkColor(0xFF0000, $hGUI) ; Create a 2000x2000 green label GUICtrlCreateLabel("", 0, 0, 2000, 2000) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlCreateLabel("", 1990, 1990, 10, 10) GUICtrlSetBkColor(-1, 0x0000FF) GUISetState() ; Generate scrollbars - Yes, this is all you need to do!!!!!!!!!!!!!!!!!!!! _GUIScrollbars_Generate($hGUI, 2000, 2000) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd M231 point
-
Just for fun, a weekend script that comes from 2 ideas: one idea is from this link (https://github.com/lukePeavey/quotable), that shows how to get a single random quote from a database, The other idea is to visualize the above quotes by a revisitation of a funny snipped I posted time ago here (https://www.autoitscript.com/forum/topic/159910-useless-code/?do=findComment&comment=1163490) that very rougly simulates a "Departure Mechanical Panel". Of course you could also use an array of your own phrases to send randomly to the _AsciiPanel() function. I hope you have fun and I wish you can use this "Departure Panel" to take a nice journey toward wisdom. Global $hGuiPanel HotKeySet("{ESC}", "_End") _Example() Func _Example() Local $bError = False, $aSplit Do If GUIGetMsg() = -3 Then ExitLoop $sQuote = InetRead("https://api.quotable.io/random", 1) If Not @error Then $aSplit = StringSplit(BinaryToString($sQuote), '"', 3) $sQuote = $aSplit[7] & " (" & $aSplit[11] & ")" Else $sQuote = "Sorry, no quotes for You." $bError = True EndIf _AsciiPanel($sQuote) Until $bError EndFunc ;==>_Example Func _AsciiPanel($sMsg, $iSeconds = 8, $iColumns = 30) ; only ascii chars allowed $sMsg = StringRegExpReplace($sMsg, "[^\x20-\x7F]+", " ") $sMsg = _StringColumn($sMsg, $iColumns) Local $aAsciiLines = StringSplit($sMsg, @CR, 3) Local $iRows = UBound($aAsciiLines) Local $aPanelLines[$iRows] Local $iTotChars = $iRows * $iColumns, $iMatches = 0, $sOutput = '' ; dimensions of the GUI based on Font Courier New 48 Local $iY = $iRows * 68, $iX = $iColumns * 38.33 $hGuiPanel = GUICreate('The talking oracle', $iX, $iY) Local $hPanel = GUICtrlCreateLabel('', 0, 0, $iX, $iY) GUICtrlSetFont(-1, 48, -1, -1, "Courier New") GUISetState() For $row = 0 To $iRows - 1 $aAsciiLines[$row] = StringToASCIIArray(StringFormat("%-" & $iColumns & "." & $iColumns & "s", $aAsciiLines[$row])) $aPanelLines[$row] = StringSplit(StringTrimRight(StringReplace(StringFormat('%' & $iColumns & 's', ""), ' ', '127,'), 1), ',', 3) ; 31 Next Do $iMatches = 0 For $row = 0 To UBound($aAsciiLines) - 1 For $col = 0 To $iColumns - 1 _SetInnerArray($aPanelLines[$row], $col, ($aPanelLines[$row])[$col] - (($aPanelLines[$row])[$col] <> ($aAsciiLines[$row])[$col])) $iMatches += (($aPanelLines[$row])[$col] = ($aAsciiLines[$row])[$col]) Next $sOutput &= StringFromASCIIArray($aPanelLines[$row]) & @CRLF Next ControlSetText('', '', $hPanel, $sOutput) $sOutput = '' Sleep(10) If GUIGetMsg() = -3 Then Exit Until $iMatches = $iTotChars Local $iTimer = TimerInit() Do If GUIGetMsg() = -3 Then Exit Until TimerDiff($iTimer) > (1000 * $iSeconds) GUIDelete($hGuiPanel) EndFunc ;==>_AsciiPanel ; to sets an element of an arry (within array) Func _SetInnerArray(ByRef $aArray, $iElement, $Value) $aArray[$iElement] = $Value EndFunc ;==>_SetInnerArray ; formats a long string within a column of n. chars without splitting words Func _StringColumn($sString, $x = 20) For $i = $x To StringLen($sString) Step $x $i = StringInStr($sString, " ", 0, -1, $i) If $i = 0 Then Return SetError(1, 0, "") $sString = StringReplace($sString, $i, @CR) Next If StringRight($sString, 1) = @CR Then $sString = StringTrimRight($sString, 1) Return $sString EndFunc ;==>_StringColumn Func _End() If WinActive("[ACTIVE]") = $hGuiPanel Then GUIDelete($hGuiPanel) Exit EndIf EndFunc ;==>_End1 point
-
Me too. That's why I didn't post the link to Wikipedia1 point
-
@water, yeah I found the same but wanted the OP to do the research as one might expect from anybody before posting a question.1 point
-
GUICtrlPic.au3 where to find this file?
pixelsearch reacted to FrancescoDiMuro for a topic
A quick research on the Forum GUICtrlPic.au31 point -
spikespaz, There are many posts (often by me) on the forum which explain why the rule exists as it does, so I am not going to explain it yet again. Suffice to say that the site owner, and author of AutoIt, wrote those rules personally - so if you want to post in his forum you need to obey them. If that does not meet with your personal feelings of what should be allowed - tough. We cannot, and indeed have no wish, to determine what use people make of AutoIt - but we do, and most certainly will, police what is discussed in this forum. And so to prevent yet another Oozlum bird meeting a premature end, this thread is locked. M231 point
-
Getting image dimensions
pixelsearch reacted to AutoBert for a topic
With GDI-funcs you can get this info: #include <GDIPlus.au3> $sImageName = "C:\Program Files\AutoIt3\Examples\GUI\mslogo.jpg" _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sImageName) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() MsgBox(64, $sImageName, 'Width: ' & $iX & @CRLF & 'Height: ' & $iY) Ps.: in the spoiler of https://autoit.de/index.php/Thread/21667-Beispiel-BMP-GIF-PNG-JPG-Viewer-Stand-10-02-2012/?page=Thread&threadID=21667 is a old example script of mine. A click on the "kopieren"-Icon helps copying the source. It's running still yet but in the newer versions of autoit the $WM_DROPFILES in line 31 must be deleted. You can drop BMP-, JPG-, GIF- and PNG images to the listview or add images by menu. Doubleclick on a lvitem will schow the image with the ratio of the original image. It's only very small commented in german, but i hope my old scriptcode is good enough for understanding by reading code. Added: BMP-Viewer.au3 and the included GUICtrlPic.au31 point -
JPEG/JPG image resize
pixelsearch reacted to UEZ for a topic
Try these lines at the end instead:: Global $sBitmap = "D:\test\poza.jpg" _GDIPlus_Startup() Global Const $iW = @DesktopWidth, $iH = @DesktopHeight Global $hBitmap = _GDIPlus_ImageLoadFromFile($sBitmap) Global $hBitmap_Resized = _GDIPlus_ImageResize($hBitmap, $iW / 4, $iH / 4) ;resize image _GDIPlus_ImageSaveToFile ($hBitmap_Resized, @ScriptDir & "\MyBitmap.jpg" ) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_ImageDispose($hBitmap_Resized) _GDIPlus_Shutdown()1 point -
Hey fellas, the time has come to seek your help once more . #FluffOn Our company recently had an attendance system build but the developers forgot to add one critical thing - the value of your current overtime. And as the fiddler that I am I decided to make a tool that would make it possible. I already made and excel version that does that but it requires the user to export an excel file from the site, then open it and then activate the calculation. Which is two steps more than I would like and hence I'm turning to you. #FluffOff Basically, there is data in a table on the site which I want to grab. I checked the forums and found this: #include <IE.au3> #include <Array.au3> $oIE = _IECreate("<a href='http://www.bts.gov/publications/national_transportation_statistics/html/table_01_37.html' class='bbc_url' title='External link' rel='nofollow external'>http://www.bts.gov/publications/national_transportation_statistics/html/table_01_37.html</a>", 0, 0) $oTable = _IETableGetCollection ($oIE) ; Get number of tables $iNumTables = @extended MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page") $oTable = _IETableGetCollection ($oIE, $iNumTables-1) ; Get last table $aTableData = _IETableWriteToArray ($oTable) _ArrayDisplay($aTableData) It works great, it shows me how many tables there are and the shows me the contents of the table. But, my site is a https site ending aspx so I cannot just _IECreate it. So I tried _IEAttach("partial name", "URL"). Now it tells me there is 397 tables on the site :-D How do I find the one I'm looking for? OK got it: $oIE = _IEAttach("bpowebtarget", "URL") $oTable = _IETableGetCollection ($oIE) ; Get number of tables $iNumTables = @extended MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page") For $i = 1 To $iNumTables+1 $oTable = _IETableGetCollection ($oIE, $i) ; Get last table $aTableData = _IETableWriteToArray ($oTable) _ArrayDisplay($aTableData) Next I'm fine for now, will report back once I get stuck again.1 point