Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/09/2017 in all areas

  1. It is fairly easy to do it using AutoIt. I recommend that you try out AutoIt yourself, the wiki has some good resources: https://www.autoitscript.com/wiki/Tutorials Or if you are feeling lazy, you can hire a freelancer... like me (LOL, advertising) .
    1 point
  2. Even shorter! Func CreatePath1() Return FileExists("C:\test") ? DirMove("C:\test", "C:\testnew", 1) : DirCreate("C:\testnew") EndFunc ;==>CreatePath
    1 point
  3. Alright, I've worked out that this is an issue with the iFrames on stackoverflow. You will get an Access Denied error like so: err.number is: 0x80020009 err.windescription: Exception occurred. err.description is: Access is denied. err.source is: err.helpfile is: C:\Windows\System32\mshtml.hlp err.helpcontext is: 0 err.lastdllerror is: 0 err.scriptline is: 1899 err.retcode is: 0x80070005 if you try to access the elements in the iframe. Apparently this is due to an XSS restriction, the iframe might be hosted on another url, but I can't find the link anywhere. Here's my code in case someone else wants to give it a shot: #AutoIt3Wrapper_UseX64=Y #include <IE.au3> _IEErrorHandlerRegister(_User_ErrFunc) $oIE = _IECreate('https://stackoverflow.com/questions/901712/how-to-check-whether-a-checkbox-is-checked-in-jquery', 0) _IELoadWait($oIE) WinSetState("[ACTIVE]", "", @SW_MAXIMIZE) $oIE.document.parentwindow.scroll(0, $oIE.document.body.scrollHeight/(10)) ;;;get to the button area $oButtons = _IETagnameGetCollection($oIE, "button") For $oButton in $oButtons If String($oButton.innertext) = " Run code snippet" Then _IEAction($oButton, "click") EndIf Next Sleep(2000) $oIE = _IEAttach("Stack Overflow") $oFrames = _IEFrameGetCollection($oIE) ;It is the first frame itself $iLength = $oFrames.length ;MsgBox(64, "Test", ".length = " & $iLength) Local $checkBox Local $oFrame For $i=0 To $iLength-1 $oFrame = _IEFrameGetCollection($oIE, $i) If @error Then MsgBox(0, "d", @error) EndIf If(IsObj($oFrame)) Then If (_IEGetObjById($oFrame, "isAgeSelected")) Then If Not $checkBox.checked Then $checkBox.checked = True EndIf ExitLoop EndIf EndIf Next ;_IEAction($input, "click") ;;;gives an error in the previous statement only!!!!! ; User's COM error function. ; After SetUp with ObjEvent("AutoIt.Error", ....) will be called if COM error occurs Func _User_ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptFullPath & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_User_ErrFunc It fails on the line "If (_IEGetObjById($oFrame, "isAgeSelected")) Then"
    1 point
  4. Hm. This may be a bit more difficult than initially thought. Here is the info for the button you want to click: No name or ID property. You may have to reference it by index....
    1 point
  5. You are getting help, but you also need to follow the rules of the forum. Posting your question multiple times makes it more difficult for people trying to help you..."bruh"
    1 point
  6. $array = ProcessList("AutoIt3.exe") $iPID = $array[1][1] $sProcess = $iPID ;PID number for test process name ;~ $sProcess = "Idle" ;Other test process names ;~ $sProcess = "_Total" ;funny one ;~ $sProcess = "ntvdm" ;DOS process ;~ $sProcess = "AutoIt3" ;do not assign .exe to process name While 1 $iProcessCPU = _ProcessGetCPU($sProcess, 300 ) $sTip = "Process " & $sProcess & " CPU: " & $iProcessCPU & "%" traytip("", $sTip ,1) ;~ sleep(1000) ;set your own sleep time for LOOP mode WEnd Func _ProcessGetCPU($strProcess = "Idle", $iSampleTime = 500, $sComputerName = @ComputerName) ;~ All Parameters are optional: ;~ - Idle process will be measured if first parameter is not set ;~ - 500 ms is default sample time ;~ - This computer will be measured by default ;~ Process could be string ("Name") or PID number (1234) ;~ When more processes are runing with identical name, then the last opened is measured (use PID for other) ;~ For NORMAL MODE(one time measuring): set Sample value to more than 0 ms ;~ ( average CPU usage will be measured during sleep time within function) ;~ For LOOP MODE (continuous measuring): set Sample value to 0 ms ;~ ( average CPU usage will be measured between two function calls ) ;~ Total CPU usage is: ( 100 - _ProcessGetCPU()) ;~ Success: Returns process CPU usage in percent ;~ (Sample times below 100ms may return inaccurate results) ;~ (First result in Loop Mode may be inaccurate, ;~ because first call in Loop Mode is only used to trigger counters) ;~ Failure: Returns -1 ( wrong process name or PID ) ;~ : Returns -2 ( WMI service not found or Computer not found) if $strProcess = "" then $strProcess = "Idle" if $iSampleTime = "" AND IsString($iSampleTime) then $iSampleTime = 500 if $sComputerName = "" then $sComputerName = @ComputerName if not IsDeclared("iP1") AND $iSampleTime = 0 then ;first time in loop mode $bFirstTimeInLoopMode = 1 else $bFirstTimeInLoopMode = 0 endif if not IsDeclared("iP1") then assign("iP1", 0, 2) ;forced global declaration first time assign("iT1", 0, 2) endif $objWMIService = ObjGet("winmgmts:\\" & $sComputerName & "\root\CIMV2") if @error then return -2 if number($strProcess) then $strProcess = " WHERE IDProcess = '" & $strProcess & "'" else $strProcess = " WHERE Name = '" & $strProcess & "'" endif if $iSampleTime OR $bFirstTimeInLoopMode = 1 then ;skip if Loop Mode, but not First time $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_PerfRawData_PerfProc_Process" & $strProcess) For $objItem In $colItems $iT1 = $objItem.TimeStamp_Sys100NS $iP1 = $objItem.PercentProcessorTime next if $objItem = "" then return -1 ;process not found sleep($iSampleTime) endif $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_PerfRawData_PerfProc_Process" & $strProcess) For $objItem In $colItems $iP2 = $objItem.PercentProcessorTime $iT2 = $objItem.TimeStamp_Sys100NS next if $objItem = "" then return -1 ;process not found $iPP = ($iP2 - $iP1) $iTT = ($iT2 - $iT1) if $iTT = 0 Then return 100 ;do not divide by 0 $iCPU = round( ($iPP/$iTT) * 100, 0) $iP1 = $iP2 $iT1 = $iT2 Return $iCPU EndFunc ;==>_ProcessGetCPU() by novaTek ...ver 0.11 This function could measure only one process at a time. For monitoring all processes, or more processes under identical name, look for this function: Func _ProcessListCPU() Enjoy!
    1 point
  7. I knocked up a function that should do what you're looking for as far as commenting a section in an ini file. See the code below, it includes error checking as well as the ability to add the comments before or after the section name. Note that when adding a comment to the ini file, if you are adding it before the section name, it will start at the line just before the section name then inserts the comments, then adds the section name and the rest of the ini file's contents. If adding a comment to a section after the section name, it will start at the next line after the name, insert the comments, and then the rest of the ini file's contents. The only reason this is mentioned is because you may want to split the comments into easily handled chunks and if you're not aware of how the comments are added, you may end up with the comments in the wrong order. Also, this function does include the ability to add multi-line comments by separating the lines with the pipe ("|") character in the comment string. I included a very short example script to demonstrate how it works, it will create a file called Test.ini in the scriptdir folder, populate it, then write the comments into it. #include-once #include <File.au3> #include <array.au3> ;Test function to write comments to an ini file Global $IniFile = @ScriptDir & "\Test.ini" FileOpen($IniFile, 2) IniWrite($IniFile, "Test1", 1, 1) IniWrite($IniFile, "Test1", 2, 2) IniWrite($IniFile, "Test1", 3, 3) IniWrite($IniFile, "Test1", 4, 4) IniWrite($IniFile, "Test2", 1, 1) IniWrite($IniFile, "Test2", 2, 2) IniWrite($IniFile, "Test2", 3, 3) IniWrite($IniFile, "Test3", 1, 1) IniWrite($IniFile, "Test3", 2, 2) IniWrite($IniFile, "Test3", 3, 3) Global $Test = _IniWriteSectionComment($IniFile, "Test1", "This is a comment that comes before a section name", 1) $Test = _IniWriteSectionComment($IniFile, "Test2", "This is a comment that comes after a section name", 0) $Test = _IniWriteSectionComment($IniFile, "Test3", "This is a multi-line comment|that comes after a section name", 0) $Test = _IniWriteSectionComment($IniFile, "Test4", "This will cause an error by referencing a non-existent section name", 0) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Test = ' & $Test & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniWriteSectionComment ; Description ...: Writes comment(s) to an .ini file ; Syntax.........: _IniWriteSectionComment($IWSC_FileName, $IWSC_SectionName, $IWSC_Comment[, $IWSC_ForeAft = 1]) ; Parameters ....: $IWSC_FileName - String path of the file to write to. ; $IWSC_SectionName - The section of the ini file to comment. ; $IWSC_Comment - String that contains the comment for the section name. ; $IWSC_ForeAft - Optional: Specifies where to put the comment in relation to the section name ; default is before the section name. ; Return values .: Success - Returns a 1 ; Failure - Returns a 0 ; @Error - 0 = No error. ; |1 = file not found ; |2 = Could not read/split file ; |3 = Not an .ini file ; |4 = Section Name not found ; Author ........: Bob Marotte (BrewManNH) ; Modified.......: ; Remarks .......: $IWSC_ForeAft specifies whether to put the comments before or after the section name, 1 = before/0 = after ; To write multiline comments, separate the lines with the "|" (pipe) character, see example below. ; Related .......: ; Link ..........: ; Example .......: $Test = _IniWriteSectionComment($IniFile, "Settings", "Now is the time for all good|men to come to the aid of their country", 1) ; =============================================================================================================================== Func _IniWriteSectionComment($IWSC_FileName, $IWSC_SectionName, $IWSC_Comment, $IWSC_ForeAft = 1) Local $aFileRead If FileExists($IWSC_FileName) Then Local $IWSC_fHnd = FileOpen($IWSC_FileName, 0) If $IWSC_fHnd = -1 Then Return SetError(2, 0, 0) EndIf Local $Return = _FileReadToArray($IniFile, $aFileRead) If $Return = 0 Then Return SetError(2, 0, 0) EndIf Local $aSectionNames = IniReadSectionNames($IniFile) If @error Then Return SetError(3, 0, 0) EndIf If _ArraySearch($aSectionNames, $IWSC_SectionName) < 0 Then Return SetError(4, 0, 0) EndIf Local $aTempArray = StringSplit($IWSC_Comment, "|") Local $IWSC_Index = _ArraySearch($aFileRead, "[" & $IWSC_SectionName & "]") Local $aHolder[UBound($aFileRead) + UBound($aTempArray) - 1] If $IWSC_ForeAft Then For $I = 0 To $IWSC_Index - 1 $aHolder[$I] = $aFileRead[$I] Next For $I = $IWSC_Index To $aTempArray[0] + $IWSC_Index - 1 $aHolder[$I] = "; " & $aTempArray[$I - ($IWSC_Index - 1)] Next For $I = $IWSC_Index To $aFileRead[0] $aHolder[$I + $aTempArray[0]] = $aFileRead[$I] Next Else For $I = 0 To $IWSC_Index $aHolder[$I] = $aFileRead[$I] Next For $I = $IWSC_Index + 1 To $aTempArray[0] + $IWSC_Index $aHolder[$I] = "; " & $aTempArray[$I - ($IWSC_Index)] Next For $I = $IWSC_Index + 1 To $aFileRead[0] $aHolder[$I + $aTempArray[0]] = $aFileRead[$I] Next EndIf _ArrayDelete($aHolder, 0) _FileWriteFromArray($IniFile, $aHolder) Else Return SetError(1, 0, 0) EndIf Return SetError(0, 0, 1) EndFunc ;==>_IniWriteSectionComment
    1 point
  8. Thanks for the replies. But what I really want to be able to get is this kind of result: ; valid modifier keys include ; ^ for Control ; ! for Alt ; # for WinKey ; ; LButton left mouse button ; MButton middle mouse button ; RButton right mouse button ; ; Example: !^MButton would be ; Alt and Control while pressing ; Middle Mouse Button ; [settings] MouseHotkey=^MButton KeyboardHotkey=!F8 PasteFilename=0 UseGlass=1 DesktopDir=C:\Utils ; Other comment ; Yet another comment [NewSection] yadda=yadda Having the comments all mixed up with the settings just seems confusing. Better for documentation if I could put several lines just above a section.
    1 point
×
×
  • Create New...