Jump to content

[SOLVED] How to perform a Subtotal in Excel using Autoit


Recommended Posts

I need to perform a subtotal in excel and I would like to automate this process using Autoit if possible like always any and all help will be greatly appreciated. 

I can not find a good example but the two from Microsoft. Here is one of the two from msdn.microsoft.com/en-us/vba/excel-vba/articles/range-subtotal-method-excel

Quote

Worksheets("Sheet1").Activate Selection.Subtotal GroupBy:=1, Function:=xlSum, _ TotalList:=Array(2, 3)

I do not really understand how to translate this into AutoIt, but I gave it a try and here is what I have.

$OpenRange      = "A1:E200"
$xlSum          = -4157
$Added_Array[2] = [2, 3]
$OpenRange.Subtotal("B1", $xlSum, $Added_Array, True, False, True)

I just need to perform a subtotal on a range based on a header called department, and then perform a sum on the results.

Edited by nooneclose
Link to post
Share on other sites
  • Moderators

@nooneclose are you looking to enter the subtotal into the workbook, or just gather it for use elsewhere? If you are looking just to get the total, you could do something like this:

#include <Excel.au3>

Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, @DesktopDir & "\Test.xlsx")
Local $oRange = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("B:B"))
Local $iTotal = 0

_Excel_BookClose($oWorkbook)
_Excel_Close($oExcel)

    For $a = 1 To UBound($oRange) - 1
        $iTotal += $oRange[$a]
    Next

    ConsoleWrite($iTotal & @CRLF)

If you need to write that subtotal into a cell in the spreadsheet you can use _Excel_RangeWrite to do so. Also, in the future, posting an example of the text file or spreadsheet you're working on helps immensely, so we don't have to recreate them :)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

As AutoIt does not support parameters by name you need to specify them in the sequence as documented here:
https://msdn.microsoft.com/en-us/vba/excel-vba/articles/range-subtotal-method-excel

$OpenRange      = "A1:E200"
$xlSum          = -4157
$Added_Array[2] = [2, 3]
$oExcel.Worksheets("Sheet1").Range($OpenRange).Subtotal("B1", $xlSum, $Added_Array, True, False, True)

BTW: I'm not sure "B1" is correct. I think it should be 2 (according to the docu I mentiond above). Can't test at the moment so everything I posted might be wrong ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (NEW 2021-07-28 - Version 1.1.0.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites

I was able to Jerry-rig a way to find the cell locations and delete them though I do not like having to manually enter in all names that should be deleted I could not think of another way to do it. Here is how I did it: 

Local $NameToDelete1  = _Excel_RangeFind($OpenWorkbook, "Smith, Bill")
Local $NameCell       = $NameToDelete1[0][2]
Local $CellNumber     = StringSplit($NameCell, "A, B, C, D, E")
Local $CellRange      = $NameCell & ":E" & $CellNumber[2]
_Excel_RangeDelete($OpenWorkbook.ActiveSheet, $CellRange, $xlShiftUp)

I can now focus on the subtotal. :) 

Link to post
Share on other sites

@JLogan3o13 I am trying to perform a subtotal on every used row in columns A-I and every change in the header at B1. I also want this subtotal to perform the "Sum" function. 

Basically, this subtotal should take my roster (A1-I200, row 1 is the Headers so I must include them) break it down by the employee sub-departments and then add up how many are in each department.

I can manually do this in excel but I REALLY want to automate these last few processes.    

Link to post
Share on other sites

But what should get written to the Excel sheet? The formula (so it changes whenever you modify the sheet) or just the result as a numeric value?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (NEW 2021-07-28 - Version 1.1.0.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites

@waterThe results of the subtotal should be written to the excel sheet. I'll show you want I'm trying to automate. I changed the names on purpose. 

EMP. TYPE SUB-DEPT NAME HOURS AS TIME HOURS AS GEN.
Staff Warehouse Smith, Bill Smith, Bill 40:00
Staff HVAC Smith, Bill Smith, Bill 42:45:00
Staff General Maint. Smith, Bill Smith, Bill 50:30:00
Staff Construction Smith, Bill Smith, Bill 64:30:00
Staff Plumber Smith, Bill Smith, Bill 25:00

 I need to go from the above example to the below example. A subtotal based on the sub-debt which is Colum B1

EMP. TYPE SUB-DEPT NAME HOURS AS TIME HOURS AS GEN.
  Appliance Total     103.25
  Construction Total     541
  Electrician Total     320.5
  General Maint. Total     591.25
  HVAC Total     377
         
Edited by nooneclose
Link to post
Share on other sites

I'm on vacation right now. Will test, when I return :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (NEW 2021-07-28 - Version 1.1.0.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites

Can you please post a real life example so we can check that our calculation is correct?

Example: You mention SUB-DEPT "Appliance Total" in your result matrix but it isn't mentioned in the source matrix.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (NEW 2021-07-28 - Version 1.1.0.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites

I think I understand what you're asking for.  @water

5b8054f765811_Screenshot(60)_LI.thumb.jpg.ed41f07ff42c8a75747e7230746913d1.jpg

Here is what I get from a fresh report and I have to do a bunch of stuff and a subtotal to make it look like the below image. 

5b805536be09a_Screenshot(58).thumb.png.2ef6669983851b11aa4c914a10d8edce.png

I do some inserts and stuff and then I perform some sorts then I do a subtotal. I have mouse clicks doing the subtotal now but I want to automate that process. 

to see how I perform the subtotal see the image below.  

5b805677e65f4_Screenshot(61)_LI.jpg.1d3c3fa2ab871df1038de1cebdc3a9f3.jpg

Did these images answer your question? I do an FTE report. 

Link to post
Share on other sites
  • Moderators

@nooneclose it would help immensely if you post an actual file, rather than pictures (redacting your company data of course). Otherwise we have to spend a lot of time recreating your spreadsheet.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites
8 hours ago, junkew said:

Any reason to do it from AutoIt and not straight from VBA itself?

...should be the question of 90% of all the Excel-relating requests in this forum. 

 

*OT-mode ON*

The only (for me) meaningful use of AutoIt with Excel is to extract or to put in/out Data from/to extern (3rd) Programs. Or control processes of other Programs from Excel/Word/any other VBA controllable software.

I cannot understand why people use a programming language like AutoIt (with whom they have no experience, otherwise they would not ask the simplest tasks here in the forum) instead of using the also "BASIC-like" build in programming language. Don´t they know what the "B "in VBA means?! 

I think it would be a good idea to show how easy most of the here posted "Excel-related problems" could be solved with some lines of VBA-code. Some links to a friendly VBA forum anyone? :) Could be the start of a cooperation of two forums with mutual participation. (BIG smilie here ^^)

I bet that even experienced VBA-programmers would like AutoIt because of its wonderful possibilities!

*OT-mode OFF*

Edited by AndyG
Link to post
Share on other sites

Anyway it would be something close to

$Added_Array[5] = [5,6,7,8,9] 'Totals added to these columns
'vba worksheets(1).Cells().Subtotal GroupBy:=2, Function:=$xlSum, TotalList:=Array(5,6,7,8,9), Replace:=True, PageBreaks:=False, SummaryBelowData:=True
$oWorkbook.worksheets(1).Cells().Subtotal 2, $xlSum, $added_Array, True, False, True

Advice: First record a vba macro and attach to your question it will be easier to translate

Deleting you can do more efficient by applying delete on a filteredrange

https://danwagner.co/how-to-delete-rows-with-range-autofilter/

Link to post
Share on other sites

@AndyG if it is so easy then why don't you show me? There is no reason or need to be a puffed up nerd here. I came for help. And Yes, I do not know much about this language but I also did not know about VBA trust me if I knew an easier way I would have done it that way. 

Here is the file you asked for you @JLogan3o13 

Data.xlsx

Edited by nooneclose
Link to post
Share on other sites

Based on your last answer vba is much easier to solve your problem.

  1. Alt F11 and record macro are your friends
  2. Start record
  3. Do your things
  4. Stop record
  5. Check your vba code and modify
  6. Save as xlsm file

In my previous post you see the vba one liner commented out to add your subtotals

Link to post
Share on other sites

I downloaded your xlsx and its really a one liner recorded in VBA. Watch some instructions on youtube to get more instructed on vba and macro's

My advice is allways to record a VBA macro before transforming to another language like AutoIt

Details recorded

  1. menu view, macros, record macro
  2. menu data, subtotals, follow wizard
  3. menu view, macros, stop macro
  4. menu view, macros, edit macro to change 

Recorded

Sub Macro1()
'
' Macro1 Macro
'

'
    Cells.Select
    Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(4, 5), _
        Replace:=True, PageBreaks:=False, SummaryBelowData:=True
End Sub

Changed to

Worksheets(1).Cells.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(4, 5), Replace:=True, PageBreaks:=False, SummaryBelowData:=True

based on post 3 you should be able to transform to Autoit

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By DJ143
      I have a autoit exe file which is used in upload/browse file functionality.  This has been integrated with selenium framework and I am invoking the autoit exe using Java process and runtime. 
      Now the issue is when I run the scripts and invoke the autoit exe in local it works perfectly.  But when I use selenium grid or jenkins to run the scripts in another windows server it is not working.
      Can anyone please suggest any solution for this?
    • By Hermes
      Hello, the script below will read column A from an excel file - and if a value matches in the browser, it will click the corresponding link and click on a specific button to paste the data, then writes "Completed" in Column B. It will continue to read from the excel file and do the same thing for all the remaining rows.
      #Include "Chrome.au3" #Include "wd_core.au3" #Include "wd_helper.au3" #Include "WinHttp.au3" #include <MsgBoxConstants.au3> #include <File.au3> #include <IE.au3> #include <Array.au3> #include <INet.au3> #include <AutoItConstants.au3> #include <WinAPIFiles.au3> #include <GDIPlus.au3> #include <Excel.au3> #Include "WinHttp.au3" #Include "_HtmlTable2Array.au3" Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_LoadWait($sSession) _WD_Navigate($sSession, "table1.html") _WD_LoadWait($sSession) _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//table[@class='main']") Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//table[@class='main']") ;ConsoleWrite ("mat-table " & $sElement & @CRLF) Local $aArray1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//td[contains(@class,'data')]", $sElement, True) sleep(1000) For $i = 0 to UBound($aArray1) - 1 $aArray1[$i] = _WD_ElementAction($sSession, $aArray1[$i], 'text') Next ;_ArrayDisplay($aArray1) ;Email variables $SmtpServer = "" ; address for the smtp-server to use - REQUIRED $FromName = "Hermes" ; name from who the email was sent $FromAddress = "sender@gmail.com" ; address from where the mail should come $ToAddress = "recipient@gmail.com" ; destination address of the email - REQUIRED, use commas (,) to add more email addresses $Subject = "File not found" ; subject from the email - can be anything you want it to be $Body = "File not found!" ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed $CcAddress = "" ; address for cc - leave blank if not needed $BccAddress = "" ; address for bcc - leave blank if not needed $Importance = "High" ; Send message priority: "High", "Normal", "Low" $Username = "" ; username for the account used from where the mail gets sent - REQUIRED $Password = "" ; password for the account used from where the mail gets sent - REQUIRED $IPPort = 25 ; port used for sending the mail $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS $tls = 0 ; enables/disables TLS when required Local $oAppl = _Excel_Open() Local $sWorkbook = "c:\test.xlsx" Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook) ;open excel and pass both parameters If FileExists($sWorkbook) Then ;Check if the file exist. Local $oAppl = _Excel_Open() Local $sWorkbook = "c:\test.xlsx" Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook) ;open excel and pass both parameters Local $aArray2 = _Excel_RangeRead($oWorkbook,Default,$oWorkbook.ActiveSheet.Usedrange.Columns("A:A")) Local $iIdx Local $Skipline = 0 ;0==> first line Do Local $temprf For $i = 0 To UBound($aArray2) - 1 $temprf &= $aArray2[$i] _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, ".//a[contains(@class,'edit') and contains(text(),'Edit')]") Local $aElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//a[contains(@class,'edit') and contains(text(),'Edit')]", $sElement, True) $iIdx = _ArraySearch($aArray1, $aArray2[$i]) If @error Then ContinueLoop _WD_ElementAction($sSession, $aElement[$iIdx], 'click') If $i < $Skipline Then ContinueLoop $oRange = $oWorkbook.ActiveSheet.Range("B" & $i + 1 & ":XFD" & $i + 1) _Excel_RangeCopyPaste($oWorkbook.Activesheet, $oRange) ;Paste Local $oTest4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "pastebutton") _WD_ElementAction($sSession, $oTest4, 'click') Sleep(1000) ;Save Button Local $save3 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "button.button") _WD_ElementAction($sSession, $save3, 'click') _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "Completed", "B" & $i+1) sleep(1000) Next Until (Not @error) _Excel_Close($oWorkbook) Else _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl, $tls) Exit EndIf _WD_LoadWait($sSession) ;Attaching files to emails Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0, $tls = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 then $IPPort = 25 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf ; Set security params If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True If $tls Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendtls") = True ;Update settings $objEmail.Configuration.Fields.Update ; Set Email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update ; Sent the Message $objEmail.Send $objEmail="" EndFunc ;==>_INetSmtpMailCom Local $aDir = _FileListToArrayRec(@TempDir, "scoped_dir*;chrome_*", $FLTAR_FOLDERS, $FLTAR_NORECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) Sleep(2000) For $i = 1 To $aDir[0] DirRemove($aDir[$i], $DIR_REMOVE) Next _WD_LoadWait($sSession) _WD_Shutdown() Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}' EndFunc ;==>SetupChrome If the excel file doesn't exists in the folder, it will send an email to a specific recipient.
      What i am trying figure out now is if the excel crashes while the script/loop is running, I want to relaunch the excel file continue to the last row before the excel crashed. So if the value of column B is not marked as "completed", it should continue from that row
      Appreciate any help that I can get to achieve this.
      table1.html test.xlsx
    • By adityaparakh
      Hello ,
      I am trying to use Websockets in AutoIt.
      It is to fetch live stock market prices , API is provided and documentation available for python language.
      The link for the code snippet is :
      https://symphonyfintech.com/xts-market-data-front-end-api-v2/#tag/Introduction
      https://symphonyfintech.com/xts-market-data-front-end-api-v2/#tag/Instruments/paths/~1instruments~1subscription/post
       
      https://github.com/symphonyfintech/xts-pythonclient-api-sdk
       
      Second Link is to subscribe to a list of ExchangeInstruments.
      Now I would like to get live stock ltp (LastTradedPrice) for a few stocks whose "ExchangeInstrumentID" I know.
      I am able to use the WinHttp object to perform actions using simple codes like below :
      I have the secretKey and appkey and can generate the needed token. And get the unique ExchangeInstrumentID.

      Below code is just for example of how I am using WinHttp. Unrelated to socket part.
      Global $InteractiveAPItoken = IniRead(@ScriptDir & "\Config.ini", "token", "InteractiveAPItoken", "NA") $baseurl = "https://brokerlink.com/interactive/" $functionurl = "orders" $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", $baseurl & $functionurl, False) $oHTTP.SetRequestHeader("Content-Type", "application/json;charset=UTF-8") $oHTTP.SetRequestHeader("authorization", $InteractiveAPItoken) $pD = '{ "exchangeSegment": "NSEFO", "exchangeInstrumentID": ' & $exchangeInstrumentID & ', "productType": "' & $producttype & '", "orderType": "MARKET", "orderSide": "' & $orderside & '", "timeInForce": "DAY", "disclosedQuantity": 0, "orderQuantity": ' & $qty & ', "limitPrice": 0, "stopPrice": 0, "orderUniqueIdentifier": "' & $orderidentifier & '"}' $oHTTP.Send($pD) $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status
          
          
      But am struggling to understand and use socket.
      Would be of great help if you can have a look at the link mentioned above and help with the code sample for AutoIt.
      To connect and listen to a socket.
      Thanks a lot
       
    • By Hermes
      Hi, I have a site that has the following elements below: 
      <div>More element here</div> <div>More element here</div> <div>More element here</div> When I do this in Auto It:
      Local $oSelectDiv = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "div") _WD_HighlightElement($sSession, $oSelectDiv, 1) I also tried to add [3], but it doesnt seems to work:
      Local $oSelectDiv = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "div[3]") _WD_HighlightElement($sSession, $oSelectDiv, 1) It always highlight the first one, but I am trying to highlight the 3rd in the list. Is there anyway to select the 3rd div without having to add any class/id in the divs, and without using XPATH? The structure of the elements in that site were built that way.
    • By meety
      My au3 script program needs administrator privileges on win10 to be executed correctly, because it needs to be added to the boot---Script code:RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName, "REG_SZ", @ScriptFullPath)
      I need to let the program automatically get administrator privileges, so I use a function of #RequireAdmin. Although the program can be added to the boot, but does not execute after system boot up? why is that?
      What should I do?
      --------------------------------------------------------------------
      Update:
      I found that after using the #RequireAdmin function, the program cannot be executed after system boot up.
      An example is given below. after it is compiled, it will not be executed after system boot up in the following two ways.
      1. C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\
      2. RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName, "REG_SZ", @ScriptFullPath)
      why is that?
      example
      #include <MsgBoxConstants.au3>
      #RequireAdmin
      Func test()
          MsgBox(0, "", "this is test message")
      EndFunc   ;==>test
      test()
       
       
×
×
  • Create New...