Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/16/2018 in all areas

  1. I automate an older client-server application a lot, and I know from experience that if I try to process a lot of records one after the other, the app/system starts to slow down and eventually stops responding. To get around that, my scripts pause every 200th record (before it normally starts slowing down), logs out of, and closes the application. Then relaunches, logs in, and picks up where it left off. That process takes a bit of extra time so I wanted to find a way to identify when the app is about to experience slowdown and only then perform the close/open. These functions can be used to watch a specific process and warn you when it has exceeded a set usage% of the initial baseline value. Start by launching the application and get the PID for the .exe You then run the Init function to get an initial memory usage of the specified applications PID. You need to then run the Diff function typically at the end or beginning of a main loop to get the % difference between the current memory usage and the initial values. You can set the Init function so a .txt file will be generated by the functions. this is useful so you can watch the normal usage of the app so you know what to set your % thresholds at. The App I was using while testing this out was Chrome since it shows pretty good Mem usage change depending on the site you're in. Looking at that, I set the default Max% at 150 for each. The actual app I'm using this for needs the Max% set to 450, possibly higher as I have additional testing to do. This is my first attempt at Performance stuff and I'm not totally sure if I'm on the right track, so if any of you see any big issues with this please let me know. $iPID = 10816 ;Using a Chrome PID from task manager to test with since its resources change a lot $aMemLeak = _ProcessMemLeakInit($iPID, True) ;Pass in the PID and True to create baseline for testing If @error Then ConsoleWrite("Error pulling INIT" & @CRLF) Exit EndIf ConsoleWrite("Initial Function Completed" & @CRLF) For $i = 1 to 10 sleep(3000) ;give it a few seconds to allow you to make some changes in chrome $aMemDiff = _ProcessMemLeakGetDiff($aMemLeak, "Diff record #" & $i) If $aMemDiff[1] > 300 or $aMemDiff[2] > 300 or $aMemDiff[3] > 300 Then ;If any of the Memory starts using > 300% of the initial Mem, then restart it ;Func to Restart the app EndIf Next ;========================================================================== ;=== _ProcessMemLeakGetDiff() ;=== Return an array containing the differences between the _ProcessMemLeakInit() and current values ;=== The array returned from _ProcessMemLeakInit() must be passed into this function as $aRet ;=== Optional Value = $sLog, this value will be added to the Consolewrite, and the log file if you are running a baseline ; ;=== Returns an Array[4] ;=== $aDiff[0] = The same PID that was passed into as $aRet[0] ;=== $aDiff[1] = The % difference between the init $aRet[1] and the current value PoolNonpagedBytes ;=== $aDiff[2] = The % difference between the init $aRet[2] and the current value PoolPagedBytes ;=== $aDiff[3] = The % difference between the init $aRet[3] and the current value PageFileBytes ;========================================================================== Func _ProcessMemLeakGetDiff($aRet, $sLog = "") Local $aDiff[4] ;Using 4 so I can keep the [#] the same for ease of use Local $spacer = " " If IsObj($aRet[4] ) Then If IsObj($aRet[5]) Then $colProcs = $aRet[5].AddEnum($aRet[4] , "Win32_PerfFormattedData_PerfProc_Process" ).objectSet $aRet[5].Refresh For $oProc In $colProcs If $oProc.IDProcess = $aRet[0] Then $iNewVal1 = $oProc.PoolNonpagedBytes $iNewVal2 = $oProc.PoolPagedBytes $iNewVal3 = $oProc.PageFileBytes $aDiff[0] = $aRet[0] $aDiff[1] = Round(($iNewVal1 / $aRet[1]) * 100, 2) $aDiff[2] = Round(($iNewVal2 / $aRet[2]) * 100, 2) $aDiff[3] = Round(($iNewVal3 / $aRet[3]) * 100, 2) If $isMemLeakBaseline = True Then ;If = True then write this info to a log file to identify a good max value later FileWriteLine(@ScriptDir & "\MemLeakBaseline.txt", StringLeft($iNewVal1 & $spacer, 20) & StringLeft($aDiff[1] & "%" & $spacer, 10) & StringLeft($iNewVal2 & $spacer, 20) & StringLeft($aDiff[2] & "%" & $spacer, 10) & StringLeft($iNewVal3 & $spacer, 20) & StringLeft($aDiff[3] & "%" & $spacer, 10) & $sLog) EndIf ConsoleWrite("DIFF: PoolNonpagedBytes = (" & $aDiff[1] & "%), PoolPagedBytes = (" & $aDiff[2] & "%), PageFileBytes = (" & $aDiff[3] & "%) " & $sLog & @CRLF) Return $aDiff EndIf Next Else SetError(1) ;Error connecting to SWbemRefresher EndIf Else SetError(1) ; Error connecting to WMI EndIf SetError(1) ;If it got this far, then the ProcessID wasn't found EndFunc ;========================================================================== ;=== _ProcessMemLeakInit() ;=== This function will take an initial snapshot of those items microsoft suggest to watch to find resources with a memory leak ;=== $iPID is the PID that would normally be returned from a Run or ShellExecute ;=== $isBaseline, If True, then this will create a log file in the @ScriptDir to save all of the diff values and log text so you can better understand when issues may occur ;=== Default = False, no log will be created ;=== Return an array that needs to be passed to the _ProcessMemLeakGetDiff() ;=== [0] = ProcessID ;=== [1] = Pool Nonpaged Bytes ;=== [2] = Pool Paged Bytes ;=== [3] = Paging file in use ;=== [4] = PrivateBytes ;=== [5] = VirtualBytes ;=== [6] = wmi object ;=== [7] = Wbem object ;=== ;=== On Error @error returns one of the following ;=== 2 = Error connecting into the SWbemRefresher ;=== 3 = Error connecting to WMI ;=== 4 = The specified PID could not be found ;=== ;=== https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/determining-whether-a-leak-exists ;========================================================================== Func _ProcessMemLeakInit($iPID, $isBaseline = False) Local $aRet[8] if Not IsDeclared("isMemLeakBaseline") Then Global $isMemLeakBaseline = False ;if not declared in the global scope, then default to False to not create the baseline output file. EndIf $isMemLeakBaseline = $isBaseline ;If this is declared as a baseline run, then update the global variable to the same $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy, (Debug)}!\\.\root\cimv2") If IsObj($oWMI) Then Local $oRefresher = ObjCreate("WbemScripting.SWbemRefresher") If IsObj($oRefresher) Then $colProcs = $oRefresher.AddEnum($oWMI, "Win32_PerfFormattedData_PerfProc_Process" ).objectSet $oRefresher.Refresh For $oProc In $colProcs If $oProc.IDProcess = $iPID Then $aRet[0] = $iPID $aRet[1] = $oProc.PoolNonpagedBytes $aRet[2] = $oProc.PoolPagedBytes $aRet[3] = $oProc.PageFileBytes $aRet[4] = $oProc.PrivateBytes ; indicates the total amount of memory that a process has allocated, not including memory shared with other processes. $aRet[5] = $oProc.VirtualBytes ; indicates the current size of the virtual address space that the process is using. $aRet[6] = $oWMI $aRet[7] = $oRefresher ConsoleWrite("Process Name = (" & $oProc.name & ")" & @CRLF) ConsoleWrite(@TAB & "PoolNonpagedBytes = (" & $aRet[1] & "), PoolPagedBytes = (" & $aRet[2] & "), PageFileBytes = (" & $aRet[3] & "), PrivateBytes = (" & $aRet[4] & "), VirtualBytes = (" & $aRet[5] & ")" & @CRLF) If $isMemLeakBaseline = True Then Local $spacer = " " If FileExists(@ScriptDir & "\MemLeakBaseline.txt") Then FileDelete(@ScriptDir & "\MemLeakBaseline.txt") ;Remove the existing log file FileWriteLine(@ScriptDir & "\MemLeakBaseline.txt", "PoolNonpagedBytes PoolPagedBytes PageFileBytes PrivateBytes VirtualBytes Record Description") FileWriteLine(@ScriptDir & "\MemLeakBaseline.txt", StringLeft($aRet[1] & $spacer, 20) & StringLeft($aRet[2] & $spacer, 20) & StringLeft($aRet[3] & $spacer, 20) & StringLeft($aRet[4] & $spacer, 20) & StringLeft($aRet[5] & $spacer, 20) & "Initial value row! All rows below this are the Diff's from these initial values.") ;Write the Diff amounts and the log string (Should show loop# or what you are doing) to the file EndIf $colProcs = "" Return $aRet EndIf Next Else Return SetError(2) ;Error connecting to SWbemRefresher EndIf Else Return SetError(3) ; Error connecting to WMI EndIf Return SetError(4) ;If it got this far, then the ProcessID wasn't found EndFunc edit: Updated the Diff function to return the % diff value of the 3 mem items it looks at. This was working well for me, but i'm no longer using it as the added time the Diff function takes far exceeds the time it would take to restart my app every 200 records. This would be better used just to identify when a problem starts to occur.
    2 points
  2. I access a lot of Network shares with scripts and I always use UNC paths. NEVER drive letters as they can be different between systems. \\domain\server\share\drive\Drive\
    2 points
  3. water

    OutlookEX

    Version 1.7.0.1

    10,055 downloads

    Extensive library to control and manipulate Microsoft Outlook. This UDF holds the functions to automate items (folders, mails, contacts ...) in the background. Can be seen like an API. There are other UDFs available to automate Outlook: OutlookEX_GUI: This UDF holds the functions to automate the Outlook GUI. OutlookTools: Allows to import/export contacts and events to VCF/ICS files and much more. Threads: Development - General Help & Support - Example Scripts - Wiki BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort KNOWN BUGS (last changed: 2020-02-09) None
    1 point
  4. Note: my first UDF. This allows sending (BSD) messages to a syslog server using UDP. It has been tested with SnmpSoft Syslog Watcher, Synology DSM 4.2 and DSM 6.0, Kiwi Syslog Server. Uses the BSD syslog protocol (https://tools.ietf.org/html/rfc3164), except for Facility and Severity levels, which incorporates the extended (newer) values as well. To the best of my knowledge, this is how most basic syslog senders do it today anyway. Target IP, Facility, Severity level, Tag, Hostname, Port can be specified. Also includes a ping feature to give an error if server doesn't respond. Feedback appreciated. #include-once Global $__SyslogSendPing ; this allows global access to the ping result (in ms) Global $__SyslogSendPacket ; this allows global access to the entire syslog packet: PRI, HEADER and MSG. ; #FUNCTION# ==================================================================================================================== ; Name ..........: SyslogSend v1.0.3 ; Modified ......: 2018.10.09 ; Changelog......: v1.0.2 fixed $MDAY formatting, leading zero would not be correctly replaced by a space ; v1.0.3 added debug console output when packet is sent. Set global variable $_D=True to show debug output. ; Description ...: Sends syslog messages to a syslog server using UDP ; Syntax ........: SyslogSend($_Message, $_Target, $_Port, $_Facility, $_Severity, $_Tag, $_HostName) ; Parameters ....: $_Message - Text message to send. https://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6.4 ; $_Target - [optional] Target IP or host (IPv4 address or hostname). Default is "127.0.0.1". ; $_Facility - [optional] Facility value (integer 0..23). Default is 1. https://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6.2.1 ; $_Severity - [optional] Severity level (integer 0..7). Default is 7. https://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6.2.1 ; $_Tag - [optional] Name of program or process (a-zA-Z0-9). https://tools.ietf.org/html/rfc3164#section-4.1.3 ; $_HostName - [optional] Originator hostname. Default is @ComputerName. https://tools.ietf.org/html/rfc3164#section-4.1.2 ; $_Port - [optional] UDP port number (integer 0..65535). Default is 514. ; $_Ping - [optional] Ping the host before sending, with value as timeout. Function will exit and return an ; error message if host did not respond. Default is 0 (no ping). ; Return values .: 0 = Success ; Non-zero = error text message ; Author ........: Irios ; Remarks .......: Uses UDP only, and sticks to the BSD syslog protocol (https://tools.ietf.org/html/rfc3164), except for Facility ; and Severity levels, which incorporates the extended (newer) values as well. To the best of my knowledge, this ; is how most basic syslog senders do it today anyway. The syslog protocol does not provide acknowledgement of message ; delivery, the ping feature is for convenience only. Most syslog servers will use the first word in the MSG field as ; TAG if you do not specify a tag yourself. This is by design, and not a bug. ; Example .......: SyslogSend("A test message", "192.168.0.1", 514, 3, 5, "SyslogSend", "fooServer", 1000) ; This would send the text string "<29> Oct 1 00:36:23 fooServer SyslogSend: A test message" to host 192.168.0.1:514 (including a ping, 1000ms timeout). ; ; =============================================================================================================================== Func SyslogSend($_Message, $_Target = "127.0.0.1", $_Facility = 1, $_Severity = 7, $_Tag = "", $_HostName = @ComputerName, $_Port = 514, $_Ping = 0) Local $_UDPStartup = False If (StringStripWS($_Message, 8) = "") Then Return "Error. Nothing to send (no message content)." If ($_Target = "") Or (Int($_Port) < 0) Or (Int($_Port) > 65535) Or (Int($_Facility) < 0) Or (Int($_Facility) > 23) Or (Int($_Severity) < 0) Or (Int($_Severity) > 7) Then Return "Argument(s) error." ; quick check to make sure most of the parameters have valid values ; Strip accidental spaces from target IP, HOSTNAME, and TAG. Adding a colon and space to the TAG field (https://tools.ietf.org/html/rfc3164#section-4.1.3) $_Target = StringStripWS($_Target, 8) $_HostName = StringStripWS($_HostName, 8) If ($_Tag <> "") Then $_Tag = StringStripWS($_Tag, 8) & ": " ; Ping the target host, and return an error if not responding If (Int($_Ping) <> 0) Then $__SyslogSendPing = Ping($_Target, $_Ping) Switch @error Case 1 $__SyslogSendPing = "" Return "Ping error. Host is offline." Case 2 $__SyslogSendPing = "" Return "Ping error. Host is unreachable." Case 3 $__SyslogSendPing = "" Return "Ping error. Bad destination." Case 4 $__SyslogSendPing = "" Return "Ping error. Other error." EndSwitch EndIf ; Format the TIMESTAMP field. Month number converted to Mmm format (https://tools.ietf.org/html/rfc3164#section-4.1.2). Replace leading zero in day with a space. Switch @MON Case 1 $MON = "Jan" Case 2 $MON = "Feb" Case 3 $MON = "Mar" Case 4 $MON = "Apr" Case 5 $MON = "May" Case 6 $MON = "Jun" Case 7 $MON = "Jul" Case 8 $MON = "Aug" Case 9 $MON = "Sep" Case 10 $MON = "Oct" Case 11 $MON = "Nov" Case 12 $MON = "Dec" EndSwitch $MDAY = " " & @MDAY ; we add a leading space for easier processing/formatting... $MDAY = StringReplace($MDAY, " 0", " ", 1) ; ...here we make sure the MDAY variable always has the same length (incl. a trailing space). Value such as "03" is illegal, and must be formatted as " 3". Local $_TimeStampNow = $MON & $MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC ; the complete TIMESTAMP field (https://tools.ietf.org/html/rfc3339) Local $_Prival = Int(($_Facility * 8) + $_Severity) ; generating the <PRIVAL> for the PRI field. Multiply the Facility number by 8 and add the numerical value of the Severity (https://tools.ietf.org/html/rfc5424#section-6.2.1) $__SyslogSendPacket = "<" & $_Prival & "> " & $_TimeStampNow & " " & $_HostName & " " & $_Tag & $_Message ; the complete syslog packet (https://tools.ietf.org/html/rfc3164#section-4.1.3) If (Eval("_D")=True) Then ConsoleWrite('DEBUG SyslogSend(): "'& $__SyslogSendPacket & '"' & @CRLF) ; debug output, uses $_D as trigger UDPStartup() ; starting the UDP service If @error Then Return "Could not start UDP service. Error " & @error Else $_UDPStartup = True EndIf Local $_Socket = UDPOpen($_Target, $_Port) ; the socket for the UDP connection If @error Then If $_UDPStartup Then UDPShutdown() Return "Could not connect. Error " & @error EndIf UDPSend($_Socket, $__SyslogSendPacket) ; sending the packet If @error Then If $_UDPStartup Then UDPShutdown() Return "Could not send the data. Error " & @error EndIf UDPCloseSocket($_Socket) ; closing the socket If @error Then If $_UDPStartup Then UDPShutdown() Return "Could not close socket. Error " & @error EndIf If $_UDPStartup Then UDPShutdown() ; Close the UDP service. EndFunc ;==>SyslogSend Changelog: v1.0.1 added #include-once v1.0.2 fixed $MDAY formatting, leading zero would not be correctly replaced by a space v1.0.3 added $_D option for debug output, see source comment for usage SyslogSend_udf.au3
    1 point
  5. Always post your code that lead to a very faster way to help.
    1 point
  6. Yeah dont worry. Not saying you trying to hack . It's difficult to explain. I mean ....For exemple: I made codes with more than 3 month of work. These scripts was very very userfull for everyone. Less Time/work/efforts spend. But for security reasons the script was refused and sent to trash. Just saying, it is sometime looking very ridiculus since you dev in open source( Sure you would do same if that can allow you to dev .) but yeah they dont allow little actions or others actions. But there is always a purpose on each security. It seem ridiculus but it is not. Until the IT is'nt validate it. But who know ? May it's not your problem. Maybe it is technical issue. Seem like it 's not. But take care . To reply about the main question. You can do that yes. If you run you script compiled as exe. It will use the curent user rigths. And not autoIT/Scite rights. So it wont have admin/elevated permition. And you will be able to Try the script comportement with user's rights. But if you map something with rights for someone who dont have the rigths = IDEM = Face palm.
    1 point
  7. Man... I work iṇ IT since 12 year. No offence but, You dont got it. I wont discuss about it since i am not working with you. IT security does not allow users to dev. Even in a free style environement the reasons are very very obvius.... Well... You can do whatever you want until you got the rigths to do that. If you got rights for one drive with one user. you can map it from anywhere under that user's rights. Exept if the computer gpo/&Or/policy does not allow you to do so. (yes it is possible to disable that). In a classic environement you wont be able to élévate without IT. Not gonna fall in a deep dark subject. Ask what you can do. Dont do something if you dont know if it s allowed. I mean we can give you 50 solutions if it s not allowed. The result will be always same. PARTICULARY In closed environnement where security is main subject. Fail about this can make big problems for you
    1 point
  8. Jos

    Loop if, else, then

    The only difference is that the first one will do the loop evaluation at the beginning and the second at the end.Other than that there is no difference, so it really depends on the use-case. Jos
    1 point
  9. @hausl78 Maybe this could help you #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) ; Ctrl + F HotKeySet("^f", "SearchTrack") #Region ### START Koda GUI section ### Form= Global $frmMainForm = GUICreate("frmMainForm", 405, 293, -1, -1) GUISetFont(10, 400, 0, "Arial") GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApplication") Global $lvwListView = GUICtrlCreateListView("Artist|Track|Video Path|Video Pos", 7, 9, 394, 278, BitOR($LVS_REPORT, $GUI_SS_DEFAULT_LISTVIEW), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) Global $hdlListView = GUICtrlGetHandle($lvwListView) _GUICtrlListView_SetColumnWidth($lvwListView, 0, 100) _GUICtrlListView_SetColumnWidth($lvwListView, 1, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($lvwListView, 2, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($lvwListView, 3, $LVSCW_AUTOSIZE) GUISetState(@SW_SHOW, $frmMainForm) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") #EndRegion ### END Koda GUI section ### Global $strINIFile = @ScriptDir & "\Tracks.ini" ; Create Tracks.ini with 200 Tracks ( to run only once ) ; CreateTracksFile() ; Adding some tracks to the ListView AddTracksToListView() While 1 Sleep(100) WEnd Func ExitApplication() Exit EndFunc Func CreateTracksFile() Local $arrSectionValues[1][2], _ $strArrayItem = "" If FileExists($strINIFile) Then FileDelete($strINIFile) _FileCreate($strINIFile) _GUICtrlListView_BeginUpdate($lvwListView) For $i = 1 To 200 Step 1 $arrSectionValues[0][0] = 4 $arrSectionValues[0][1] = "" $strArrayItem = "Artist"& "|" & "Artist " & $i & @CRLF & _ "Track"& "|" & "Track " & $i & @CRLF & _ "VideoPath"& "|" & "Video Path " & $i & @CRLF & _ "VideoPos"& "|" & "Video Pos " & $i _ArrayAdd($arrSectionValues, $strArrayItem) If @error Then Return ConsoleWrite("Error while adding the item '" & $strArrayItem & "' in the array. Error: " & @error & @CRLF) IniWriteSection($strINIFile, "Track" & $i, $arrSectionValues) If @error Then ConsoleWrite("Error while creating the section. Error: " & @error & @CRLF) Local $arrSectionValues[1][2] Next _GUICtrlListView_EndUpdate($lvwListView) EndFunc Func AddTracksToListView() Local $arrSections, _ $arrSectionValues, _ $strListViewItem = "" $arrSections = IniReadSectionNames($strINIFile) If @error Then ConsoleWrite("Error while reading the section names in the file '" & $strINIFile & "'. Error: " & @error & @CRLF) Else _GUICtrlListView_BeginUpdate($lvwListView) For $i = 1 To $arrSections[0] Step 1 $arrSectionValues = IniReadSection($strINIFile, $arrSections[$i]) If @error Then ConsoleWrite("Error while reading the section '" & $arrSections[$i] & "'. Error: " & @error & @CRLF) Else For $j = 1 To $arrSectionValues[0][0] Step 1 $strListViewItem &= $arrSectionValues[$j][1] & "|" Next GUICtrlCreateListViewItem($strListViewItem, $lvwListView) $strListViewItem = "" EndIf Next _GUICtrlListView_EndUpdate($lvwListView) EndIf EndFunc Func SearchTrack() Local $strSearchText = "", _ $intItemIndex = 0 $strSearchText = InputBox("Search Track:", "Enter the string you want to look for:", "") If @error = 1 Then MsgBox($MB_ICONINFORMATION, "", "No text entered.", 5) Return ElseIf Not @error Then $intItemIndex = _GUICtrlListView_FindInText($lvwListView, $strSearchText) If $intItemIndex = -1 Then MsgBox($MB_ICONWARNING, "", "The text '" & $strSearchText & "' has not been found.") Else _GUICtrlListView_SetItemSelected($lvwListView, $intItemIndex, True, True) If @error Then ConsoleWrite("Error while selecting the item #" & $intItemIndex & " in the ListView. Error: " & @error & @CRLF) Else _GUICtrlListView_EnsureVisible($lvwListView, $intItemIndex) EndIf EndIf EndIf EndFunc Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR, _ $hdlWindowFrom, _ $intControlID_From, _ $intMessageCode, _ $tNMLISTVIEW $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If @error Then Return $hdlWindowFrom = DllStructGetData($tNMHDR, "hWndFrom") $intMessageCode = DllStructGetData($tNMHDR, "Code") Switch $hdlWindowFrom Case $hdlListView Switch $intMessageCode ; Column Click Case $LVN_COLUMNCLICK $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam) If @error Then Return ConsoleWrite("Item: " & DllStructGetData($tNMLISTVIEW, "Item") & @CRLF & _ "SubItem: " & DllStructGetData($tNMLISTVIEW, "SubItem") & @CRLF & _ ; This parameter tells you the Column clicked "New State: " & DllStructGetData($tNMLISTVIEW, "NewState") & @CRLF & _ "Old State: " & DllStructGetData($tNMLISTVIEW, "OldState") & @CRLF & _ "Changed: " & DllStructGetData($tNMLISTVIEW, "Changed") & @CRLF & _ "Action X: " & DllStructGetData($tNMLISTVIEW, "ActionX") & @CRLF & _ "Action Y: " & DllStructGetData($tNMLISTVIEW, "ActionY") & @CRLF & _ "Param: " & DllStructGetData($tNMLISTVIEW, "Param") & @CRLF) ; ListView Click Case $NM_CLICK ConsoleWrite("Item clicked!" & @CRLF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc
    1 point
  10. ; ----------------------------------------------------------------------------- ; S T A R T O P T I O N S ; ----------------------------------------------------------------------------- ; no tray-icon #NoTrayIcon ; OnEvent Modus AutoItSetOption('GUIOnEventMode', 1) ; ~ option explicit AutoItSetOption('MustDeclareVars', 1) ; ESC trigger $GUI_EVENT_CLOSE ? AutoItSetOption('GUICloseOnESC', 1) ; ----------------------------------------------------------------------------- ; I N C L U D E S ; ----------------------------------------------------------------------------- #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> ; ----------------------------------------------------------------------------- ; S T A R T P R O G R A M ; ----------------------------------------------------------------------------- GUIMain() While 1 Sleep(1000) WEnd ; ----------------------------------------------------------------------------- ; G U I ; ----------------------------------------------------------------------------- Func GUIMain() Global $aSectionArray, $aSectionNameArray Global $Artist, $Title, $Path, $Time Local $hGUIMain = GUICreate('Video Launcher', 500, 300, 300, 150, -1) GUISetOnEvent($GUI_EVENT_CLOSE, 'exitProgramm', $hGUIMain) Local $idListview = GUICtrlCreateListView('Interpret|Titel|Datei|Timecode', 20, 50, 450, 200) Global $sFilePath = @ScriptDir & '\songs.ini' GUISetState(@SW_SHOW) ;============================================================================= $aSectionNameArray = IniReadSectionNames($sFilePath) For $A = 1 To $aSectionNameArray[0] $Artist = IniRead($sFilePath, $aSectionNameArray[$A], 'artist', 'error') $Title = IniRead($sFilePath, $aSectionNameArray[$A], 'title', 'error') $Path = IniRead($sFilePath, $aSectionNameArray[$A], 'filepath', 'error') $Time = IniRead($sFilePath, $aSectionNameArray[$A], 'timecode', 'error') GUICtrlCreateListViewItem($Artist & '|' & $Title & '|' & $Path & '|' & $Time, $idListview) Next ;============================================================================= EndFunc ;==>GUIMain ; ---------------------------------------------------------------------------- ; F U N C T I O N S ; ----------------------------------------------------------------------------- ; Handle event Func exitProgramm() Exit EndFunc ;==>exitProgramm
    1 point
  11. Compare the position with the position you want, if = then skip the setwindowpos func, else, reposition the window. This is how you avoid the flickering which is the constant and repeated window position set.
    1 point
  12. I use the CSV.au3 written by ProgAnd:
    1 point
  13. @B4l4 Slight modification, seems to work #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> BackgroundImage() Func BackgroundImage() $hWnd = GUICreate("My background image", 1000, 300, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) ; will create a dialog box that when displayed is centered Sleep(1000) ;~ $hWnd = WinGetHandle("[ACTIVE]") ;~ WinActivate($hWnd) GUISetBkColor(0xE0FFFF) Local $idPic = GUICtrlCreatePic("C:\Users\b4l4\Documents\misc\test.jpg", -1, -1, 1000, 1000) GUISetState(@SW_SHOW) _WinAPI_SetWindowPos($hWnd, $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE)) If @error Then ConsoleWrite("Error: " & @error & @CRLF) ; Loop until the user exits. While 1 _WinAPI_SetWindowPos($hWnd, $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE)) If @error Then ConsoleWrite("Error: " & @error & @CRLF) ;WinActivate("Program Manager") Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>Example
    1 point
  14. Click the "Latest version" link in my signature to navigate to the Github site, which is where you will always find the most recent code. FYI, the file webdriver.au3 no longer exists. It was split into two different files -- wd_core.au3 containing the core webdriver functionality wd_helper.au3 containing additional "helper" functions
    1 point
  15. Welcome to the forum! As a note to both new and current members and as mentioned above, please read the FAQs on the AutoIt Wiki before posting. This will save you time, as the answers to many common questions are out there. Most importantly for new forum members, please see the section on Why isn't my thread getting any replies? Forum members are here, volunteering their time to help you with your questions, and we will always do our best to assist. Below are just a few of the items we need from you in order to provide the best help, please see the FAQ section for more: First, foremost and always, know and follow the forum rules: Every member of this forum is expected to know and adhere to the forum rules. The rules are based on common sense and should not be daunting for anyone to follow. Doing so will ensure you receive assistance and will prevent any necessary sanctions by the Moderation team. We would much rather help you with your scripts than have to attend to the unpleasant business of suspending or banning accounts. Add a meaningful title to your thread: "HELP!!" tells no one anything, and will often delay your receiving assistance. Include a detailed description of what you are trying to do, what you have tried on your own, and what problem/error you are experiencing: "Doesn't work" or "AutoIt's broke" doesn't cut it. Forum members are also here to help you write and improve your own scripts; this is not a forum where you put in an order and someone writes the code for you. Always Post Code: Even if the code is not doing what you want it to, posting the code you are working from rather than asking forum members to guess is always going to result in more rapid assistance. If you cannot post the code for business reasons, create a script that reproduces the issue you are seeing.
    1 point
  16. So my idea was this, if possible (not always) wrap/replace Global variables with functions and use the Static keyword instead. Without the use of a Global variable: #include <Constants.au3> Example() Func Example() OpenFilePath(@ScriptFullPath) MsgBox($MB_SYSTEMMODAL, '', GetOpenFileName()) EndFunc Func OpenFilePath($sFilePath = Default) ; Similar to usin a Global variable called $g_sOpenFilePath Local Static $sAPIFilePath = '' If Not IsKeyword($sFilePath) Then ; Or IsKeyWord(...) = 0 $sAPIFilePath = $sFilePath EndIf Return $sAPIFilePath EndFunc ;==>SomeFunc Func GetOpenFileName() Return StringTrimLeft(OpenFilePath(), StringInStr(OpenFilePath(), '\', Default, -1)) EndFunc ;==>SomeFuncSame example but with a Global variable: #include <Constants.au3> Global $g_sOpenFilePath = '' Example() Func Example() $g_sOpenFilePath = @ScriptFullPath MsgBox($MB_SYSTEMMODAL, '', GetOpenFileName()) EndFunc Func GetOpenFileName() Return StringTrimLeft($g_sOpenFilePath, StringInStr($g_sOpenFilePath, '\', Default, -1)) EndFunc ;==>SomeFunc If you want a better example (I tried to keep it simple for now) then provide an example using Global variables and I will convert it.
    1 point
  17. May, or may not, have been mentioned already. UDF Specification wiki page: http://www.autoitscript.com/wiki/UDF-spec
    1 point
  18. I could, but learncpp.com does a better job. Read the section labelled Where to declare variables. Source: http://www.learncpp.com/cpp-tutorial/21-basic-addressing-and-variable-declaration/
    1 point
  19. Minikori

    Virus?

    That's what we call READ THE STICKIES http://www.autoitscript.com/forum/index.php?showtopic=34658
    1 point
×
×
  • Create New...