Jump to content
Yodavish

Send data to a specific 3rd party application failing if it has been idle for awhile

Recommended Posts

My AutoIt script works fine, for the most part, however, if it goes idle for roughly 30 minutes, it will won't be able to send data to a 3rd party application window titled, "Case #". 

The problem lies within the function "SendFusion", it's able to see the handle for the "WinActivate" and "WinWaitActivate" (I've also tried putting in 10 seconds in the WinWaitActivate as well, doesn't work). However, if we have been idle, it will always fail to send data afterward. On what I've tried so far:

  • "Send" function with the data and a {ENTER} i.e. Send($CaseTxt & "{ENTER}"), this won't even hit the enter key
  •  ControlSetText, tried passing the handle from WinActivate, using the title "Case #" that was copied directly from the Autoit Window Info, hard coding the title, Using CLASS:WindowsForms10... always returns a 0
  • ControlCommand (same as above) always returns a 0
  • ControlGetFocus always returns a 0
  • ControlFocus, always returns a 0
  • Creating a new and simple Au3 script that just sends data to "Case #", also fails

NOTE: If I close the Au3 script and just scan the data directly into the "Case #" or even type it, it works fine with no issues. I'm confused as to why it would not work after a long idle period?

Below are the essential parts of the script, I can provide the entire thing if needed. Any suggestions would be greatly appreciated!

#include <AutoItConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <Process.au3>
#include <Misc.au3>
#include <IE.au3>

;---------------------------------------------------------------
; Only one instance can run
;---------------------------------------------------------------
If _Singleton("gross.exe", 1) = 0 Then
    MsgBox($MB_SYSTEMMODAL, "Warning", "Gross.exe is already running. Please exit the existing version first (check the icons in the lower right corner of your screen) before running it again.")
    Exit
EndIf

;---------------------------------------------------------------
; AutoIt Options
;---------------------------------------------------------------
Opt("GUIOnEventMode", 1)    ; Change to OnEvent mode
Opt("WinWaitDelay", 0)      ; Alters how long a script should briefly pause after a successful window-related operation. Time in milliseconds to pause (default=250).
Opt("WinTextMatchMode", 1)  ; Alters the method that is used to match window text during search operations. 2 = Quick mode
Opt("SendKeyDelay", 0)      ; Alters the length of the brief pause in between sent keystrokes. A value of 0 removes the delay completely. Time in milliseconds to pause (default=5).

if ($fusionWindowTitle="NONE" or $fusionCaseNumWinTitle="NONE" or $appWindowTitle="NONE" or $winActivateTimeout="NONE" or $winCloseTimeout="NONE" or $winWaitTimeout="NONE" or $pdfViewerWidth="NONE" or $pdfViewerHeight="NONE" or $pdfViewerLeft="NONE" or $pdfViewerWindowName="NONE" or $pdfViewerExeName="NONE" or $pdfUrl="NONE" or $pdfDownloadCommand="NONE") Then
    Msgbox(0,"ERROR", "gross.ini is missing or does not contain all settings.  Please contact Help Desk with this information")
    Exit -1
EndIf


;---------------------------------------------------------------
; application settings/constants
;---------------------------------------------------------------
Global Const $[VARIABLE] = IniRead("gross.ini", "default", "[TitleOfVariable]", "NONE")
Global Const $[VARIABLE] = IniRead("gross.ini", "default", "[TitleOfVariable]", "NONE")
Global Const $[VARIABLE] = IniRead("gross.ini", "default", "[TitleOfVariable]", "NONE")
Global Const $[VARIABLE] = IniRead("gross.ini", "default", "[TitleOfVariable]", "NONE")

;---------------------------------------------------------------
; create the main window
;---------------------------------------------------------------

Local $mainWindow = GUICreate($appWindowTitle, 380, 190)        ; create the main GUI window
GUISetOnEvent($GUI_EVENT_CLOSE, "handleCloseClick")             ; when the click the windows close button call handleCloseClick()
WinSetOnTop($appWindowTitle, '', 1)                             ; Sets main GUI always on top

;---------------------------------------------------------------
; create the controls on the main window
;---------------------------------------------------------------
Local $okButton = GUICtrlCreateButton("OK", 160, 160, 54,24)    ; create OK button
GUICtrlSetOnEvent($okButton, "validateInput")                   ; when they click ok, call handleInputProcessRequest()
GUICtrlCreateLabel("Scan Input", 10, 10)                        ; create a label
Global $inputScan = GUICtrlCreateInput("", 10,134,358)          ; create the input scan box
GUICtrlSetOnEvent($inputScan, "validateInput")                  ; when they press enter in the scan input box, call handleInputProcessRequest()
GUICtrlSetState($inputScan,$GUI_FOCUS)                          ; automatically sets focus on the input field
GUISetState(@SW_SHOW)

; main GUI loop that runs at all times
;---------------------------------------------------------------
While 1
    ;----------------------------------------------------------
    ; If sumatraPDF active, resets focus back to GUI
    ;----------------------------------------------------------
    If WinActive($pdfViewerWindowName) Then
        consoleWrite('While Loop sumatraPDF was active' & @CRLF)
        setMainWindow()
    ;----------------------------------------------------------
    ; After data sent to ProTracker, check for mismatch
    ; save button to trigger the event handler when clicked
    ;----------------------------------------------------------
    ElseIf WinActive($proTrackerWindowTitle) Then
        $ie = _IEAttach("ProTracker")
        $mismatchButton = _IEGetObjByName($ie, $proTrackerMisMatchButtonId)
        $oEvent = ObjEvent($mismatchButton, "mismatchButton_")
        If @error Then setMainWindow()
    ;---------------------------------------------------------------------
    ; If Fusion is prompting for the case #, focus back to main GUI input
    ; If second GUI 'Unknown' detect do nothing
    ;---------------------------------------------------------------------
    ElseIf WinExists($fusionWindowTitle) and WinExists($fusionCaseNumWinTitle) and Not WinActive($mainWindow) and Not WinExists('Unknown Input') Then
        setMainWindow()
    EndIF
    ;---------------------------------------------------------------------
    ; Checks if $processFlag = Done, if so, shows PDF viewer and clears
    ; processFlag for next iteration
    ;---------------------------------------------------------------------
    IF WinExists($pdfViewerWindowName) and $processFlag == 'Done' Then
        WinSetState ($pdfViewerWindowName, '', @SW_SHOW)
        $processFlag = ''
        setMainWindow()
    EndIF
    Sleep(100) ; Sleep to reduce CPU usage
WEnd

Func handleInputProcessRequest($input)
    $processFlag = True
    Local $hTimer = TimerInit()
    consoleWrite('> handleInputProcessRequest: ' & @CRLF)
    Local $idInput = identifyInput($input)
    ; Select a proccess to run based on id input
    Select
        Case $idInput = "container"
            ; regex that captures only the case number
            $caseTxt = StringUpper(StringRegExpReplace($strippedInputData, '\??(\w*\d*-\d*|\d*).*$','$1'))
            If WinExists($fusionWindowTitle) and WinExists($fusionCaseNumWinTitle) Then
                sendProTracker(StringUpper($strippedInputData))
                sendFusion($caseTxt)
                ; gets pdf for sumatraPDF in seperate script, since that function is the slowest
                Run("viewPDF.exe " & $caseTxt)
                ;getSumatraPDF($caseTxt)
                $lastCaseNum = $caseTxt
            Else
                ; Checks to make sure the previous "Container" case num is the same
                ; to the current Container case num, before sending to ProTracker
                If($lastCaseNum <> $caseTxt) Then
                    ; If not the same case number send alert sound
                    SoundPlay("error.wav")
                Else
                    sendProTracker($strippedInputData)
                EndIf
            EndIf
        Case $idInput = "user"
            sendProTracker($strippedInputData)
        Case $idInput = "cassette"
            sendProTracker(StringUpper($strippedInputData))
        Case $idInput = "unknown"
            selectUnknown()
    EndSelect
    Local $fDiff = TimerDiff($hTimer)
    $processFlag = 'Done'
    consoleWrite('> handleInputProcessRequest Completed Total time: ' & $fDiff & ' ' &@CRLF&@CRLF&@CRLF)
EndFunc

Func sendFusion($caseTxt)
    Local $hTimer = TimerInit()
    consoleWrite('+ sendFusion initiated: ' & $caseTxt & @CRLF)
    If $caseTxt = "" Then
        MsgBox(0, "Error", "Not a valid case number")
    Else
        ;$fusionCaseNumWinTitle = "Case #"
        $retVal1 = WinActivate($fusionCaseNumWinTitle, "")
        consoleWrite("ReturnValue WinActivate " & $retVal1 & @CRLF)
        $retVal2 = WinWaitActive($fusionCaseNumWinTitle,"",$winActivateTimeout)
        consoleWrite("ReturnValue WinWaitActive: " & $retVal2 & @CRLF)
        $retVal3 = ControlSetText($fusionCaseNumWinTitle, "", "", $caseTxt)
        ;$retVal3 = ControlCommand($fusionCaseNumWinTitle, "", "", "EditPaste", $caseTxt)
        consoleWrite("ReturnValue ControlSetText: " & $retVal3 & @CRLF)
        ;Send($caseTxt & "{ENTER}")
        WinWaitClose($fusionCaseNumWinTitle, "", $winCloseTimeout)
        consoleWrite('+ sendFusion WinWaitClose: ' & @CRLF)
    EndIf
    Local $fDiff = TimerDiff($hTimer)
    ConsoleWrite('+ sendFusion Completed Total time:' & $fDiff & ' ' & @CRLF)
EndFunc


Console logs from the SciTLE

Quote
 
 
 
 
Quote

+ sendFusion initiated: SS10-55555
ReturnValue WinActivate 0x000E09CE
ReturnValue WinWaitActive: 0x000E09CE
ReturnValue ControlSetText: 0
+ sendFusion WinWaitClose: 
+ sendFusion Completed Total time:1025.2186 
> handleInputProcessRequest Completed Total time: 1218.5205 

Window (x86) Info matches the correct handle for the WinActivate and WinWaitActivate

image.png.c5157339bb0a2ec699523d67e08ad887.png

Window Control (x86) Info, I've tried the CLASS, the ID, also I just noticed that the "handle" in "Control" and "Window" appear to be different as well.

image.png.ff553eb18543822b046343d6bb76fe54.png

 

So far the only work-around is to close down the 3rd party application and the AutoIt script, re-open them and it works all completely fine. But this is a pain for the end-user since it's all touch screen and it slows down their workflow, which they can be extremely sensitive about.

 

Edited by Yodavish
Tested time, it appears to be anything longer than 30 minutes related.

Share this post


Link to post
Share on other sites

@Danp2 Thanks for the reply, everything runs fine when the system has not been idle for 30 minutes. But when it has been 30+ minutes, the "WinActivate("Case #")" i.e. WinActivate($fusionCaseNumWinTitle, "") works as I can see the handle being properly returned. However, the data will not be inputted nor will the "Enter" key be sentI've tried hard coding in the "ControlID" after it's been idle for 30 minutes as well, but it still will not work. The code I've tried:

ControlSetText("Case #","", "[ID:2362094]", $caseTxt)
Send("{ENTER}")


I've also tried giving the ControlSetText the handle, but none of these work for the 30-minute idle issue.

$hwnd = WinActivate("Case #", "")
ControlSetText($hwnd,"", "[ID:2362094]", $caseTxt)
Send("{ENTER}")

Here is the current Control ID of the field in question. 

image.png.8a5c33b3d90a0115c4154a1a33fe787d.png

 

One thing to note is that the "Case #" windows will open and close depending on the end-user as they perform a task. This produces a new Control ID each time a "Case #" window appears and since I didn't have a reliable way to get that control ID, I used the ( TEXT = "" ) which I found from the AutoIt Window Info above. This is always consistent rather than CLASS or CLASSNN which can also change when the 3rd party application is loaded for each end-user.  Hence the code below:

ControlSetText("Case #","", "", $data)

My reasoning for this was from the AutoIT Help documentation listed under "Controls" says TEXT is an option to use.

 

Quote

 

  • Control ID
  • ClassNameNN
  • Text

TEXT - The text on a control, for example "&Next" on a button.

 

 

I've tried also to use the "CLASSNN" as well, but yet again on when the application has been idle for 30 minutes it will not send the data or hit enter.

$hwnd = WinActivate("Case #", "")
ControlSetText($hwnd,"", "[CLASSNN:WindowsForms10.Window.8.app.0.33c0d9d1]", $caseTxt)
Send("{ENTER}")

 

Edited by Yodavish
Updated to match the corrected CLASSNN from the AutoIT Window Info

Share this post


Link to post
Share on other sites

At that point, is it better to try restarting the "Case #" application? It might be the one not responding instead of AutoIt.


All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts

Share this post


Link to post
Share on other sites

Really hard to say without a script that replicates the problem.  But my first reflex (and I might be completely wrong) would be to check credentials conflict between the script and the end-user.  You say that shutting down the script and restarting it (with the current user) solves the issue.  I would try to put #RequireAdmin at first, see if it is working.

Share this post


Link to post
Share on other sites

@seadoggie01 So this is where I'm not entirely sure which one is the bug, however, when it's idle for 30 minutes, I've closed down the Au3 script and then just manually enter or scan in the data to the 3rd party application "Case #" and it works as normal. But when I open up the script again, it still won't send the data or hit the enter key.  The best method so far is to close down the 3rd party application and opening it up again for everything to work.

 

As a possible workaround, I'm thinking of doing an idle time check and just sending a blank enter key to the Case # and if possible delete that Case to open up the "Case #" again. My idea below:
 

Global $idleFlag = False

While 1
   If WinExists($fusionWindowTitle) and WinExists($fusionCaseNumWinTitle) Then
      If $idleFlag == False Then
         $idleTimeStart = TimerInit()
         consoleWrite("IDLE TIME START: "& $idleTimeStart & @CRLF)
         $idleFlag = True
      Else
        $fDiff = TimerDiff($idleTimeStart)
        If $fDiff > '1500000' Then ; <== Greater than 25 minutes
            WinActivate($fusionCaseNumWinTitle, "")
            WinWaitActive($fusionCaseNumWinTitle)
            Send("{ENTER}")
            $idleFlag = False
        EndIf
      EndIf
   EndIF
WEnd


 

 

Edited by Yodavish
Updated message

Share this post


Link to post
Share on other sites

OK, I have just been informed of some crucial information that I was unaware of before. This issue only occurs when the user first logins, which then points me to a different au3 script that must be the problem. As it is responsible for running a few batch files, then it will launch the 3rd party application and calls the script that I've been trying to troubleshoot. After 30 minutes the Case # window will not work. But, this is never a problem again, when the user closes both the 3rd party ap and script and reopens them again. Even with an hour break between it works still.

All it does is run scripts with admin rights. So I'm not sure why it would cause this issue. The initial launch script is below:

;Elevate with the Admin account. **** DO NOT MODIFY THIS CODE BLOCK, IT IS FOR MAKING THE SCRIPT RUN AS ADMIN ****
If @UserName <> $sAdminUser And Not IsAdmin() Then
    $sParameters = ""
    If Not @Compiled Then
        $sParameters = ' "' & @ScriptFullPath & '"'
    EndIf
    If RunAs($sAdminUser, $sDomain, $sAdminPassword, $iLogOnFlag, @AutoItExe & $sParameters) Then
        Exit
    Else
        Exit MsgBox(16 + 262144, "ERROR!", "Unable to run under administrator account.")
    EndIf
EndIf

;Run with Admin Token in Windows Vista and Higher.  **** DO NOT MODIFY THIS CODE BLOCK, IT IS FOR MAKING THE SCRIPT RUN AS ADMIN ****
If @UserName = $sAdminUser And Not IsAdmin() And Not StringRegExp(@OSVersion, "_(XP|200(0|3))") Then
    $sParameters = ""
    If Not @Compiled Then
        $sParameters = '"' & @ScriptFullPath & '"'
    EndIf
    If ShellExecute(@AutoItExe, $sParameters, "", "runas") Then
        Exit
    Else
        Exit MsgBox(16 + 262144, "ERROR!", "Unable to elevate to Admin due to UAC.")
   EndIf
EndIf

$fusionServerNameCmd = "cmd.exe /c sc queryex type= service state= all | find /i ""SERVICE_NAME: FUSION"" > fusionServiceName.txt"
RunWait($fusionServerNameCmd, @ScriptDir)

$cleanFusionFoldersCmd = "cmd.exe /c "& @ScriptDir & "\cleanFusionFolder.bat"
RunWait($cleanFusionFoldersCmd, @ScriptDir)

$setFusionFilesCmd = "cmd.exe /c "& @ScriptDir & "\setFusionFiles.bat"
RunWait($setFusionFilesCmd, @ScriptDir)

$setDefaultSound = "cmd.exe /c "& @ScriptDir & "\setDefaultSound.bat"
RunWait($setDefaultSound, @ScriptDir)

Run("C:\Program Files (x86)\Fusion Dictate\FusionDictate.exe")
Do
   Sleep(250)
Until WinExists("Case #")

; Shell execute used to ensure shortcut.lnk works and is able to fetch its ini file
ShellExecute("C:\gross\Gross shortcut.lnk")

 

Edited by Yodavish
added more detail

Share this post


Link to post
Share on other sites

Something I do not understand with this above script :

If RunAs($sAdminUser, $sDomain, $sAdminPassword, $iLogOnFlag, @AutoItExe & $sParameters) Then
        Exit
    Else
        Exit MsgBox(16 + 262144, "ERROR!", "Unable to run under administrator account.")
    EndIf

and

If ShellExecute(@AutoItExe, $sParameters, "", "runas") Then
        Exit
    Else
        Exit MsgBox(16 + 262144, "ERROR!", "Unable to elevate to Admin due to UAC.")
   EndIf

Both will exit the script whether it is successful or not ! 

How this script is launched at user logon ?

Share this post


Link to post
Share on other sites

@Nine Yep only when the user first logs into windows, I've placed the script in the Windows startup folder to run once to run all those batch files.

Share this post


Link to post
Share on other sites

I still do not understand the way the script is build.  Do you understand it ? Because if the user is not an Admin, then the script should exit like I showed you.  And how the end-user restarts both app and script when they stop working properly ? 

Share this post


Link to post
Share on other sites

@Nine Unfortunately, that bit of code was given to me as I didn't write it. I wrote the primary script it calls at the end and all the batch files.

Share this post


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 diff
      Hello,
      still learning and trying to understand AutoIT but having problem in filling my PDF file.
       
      So my code looks like similar to this:
      Global $1 = "text text 44444444" Global $2 = "texting2 texting2" Global $3 = "newtext3 next3" ShellExecute ("C:\Users\XXX\Desktop\myPDF.pdf") WinWaitActive("MyPDF.pdf - Adobe Acrobat Reader DC") Send ("{TAB}") ClipPut($1) Send ("^v") Send ("{TAB 3}") ClipPut($2) Send("^v") Send ("{TAB}") ClipPut($3) Send("^v") So its fill my PDF form, the first field looks good, the code add the text text 4444, then second should be $2 with texting2 texting2 but for some reason the code uses for second and third field after TAB only variable $3.
      So, I receive in $2 and $3 for some reason same newtext3 next3 in both, why its skipping the variable $2? Maybe there also much better solution for instant text? Because Send writes with delay by letters which I don't like.
      Thanks!
    • By kingjacob90
      Hi
      So I am trying to click the green button, this button is not always in the same place. So fare I am trying to click it by finding the color but there is also something else with the same color on the screen (circled in yellow) that is causing issues. Is there a way to use the Title and Class of the window (can't be just the window as there are more than one with the same name).
      How does AutoIt Info get this information?

    • By Mariog2000
      I've tried for a few days to simply open a url in IE and click an IE object that I can't "TAB" to and don't want to use a mouse-click if at all possible.  I've read up on things like using IEAction and IETagNameGetCollection to find the object but not smart enough to figure out how that works with my url or how to tell if my url is "basic" or a "form", "frameset", "iframe", etc.
      The other problem is I've tried using the "Run" and "ShellExecute" commands to open the browser, which works, but it opens it in a way that doesn't include my currently logged in user account.  For example, if I just click IE or Chrome for that matter and open my default homepage of google, the page that opens knows I'm logged in.  When I use "Send" "ShellExecute" or "_IE_Create" they always open pages generically which would require a login.
      So questions are, if I have a URL I'm trying to open, that's passes the currently logged on users credentials when opening the page (no clue where that happens)
      1.  Are there any code examples someone is willing to share that opens my IE maximized, with logged in credentials, and
      2.  Once that works, can someone suggest a technique a non-developer can find which IE Objects I need to send a "click" to so it opens the correct menu, pop-up, url, etc., associated with that object.  I've copied what doesn't work and sure I'm way off but it's not for a lack of effort. I'll keep trying and post updates but not looking good 🙂
      #include <IE.au3>
      Call ("selection")
      Func selection ()
      Global $oIE = _IECreate ("https://internal-webpage.aspx")
      Local $selectid = _IEGetObjByName ($oIE, "signageNo")
      Local $button = _IEGetObjByName ($oIE, "GO")

      _IEFormElementOptionSelect ($selectid, "3")
      _IEAction ($button,"click")
      EndFunc
      #include <IE.au3> Call ("selection") Func selection () Global $oIE = _IECreate ("https://internal-webpage.aspx") Local $selectid = _IEGetObjByName ($oIE, "signageNo") Local $button = _IEGetObjByName ($oIE, "GO") _IEFormElementOptionSelect ($selectid, "3") _IEAction ($button,"click") EndFunc 1. 
    • By Skysnake
      Hi guys
      AutoIt content - Microsoft thinks any AutoIt content is unwanted.
      What it does is simply delete any EXEs. No option of do you want to continue...
      The March 2020 updated has substantially changed the Defender Virus Protection logic and layout.
      I found three pages relevant to the help, and lots of outdated content. Is there a quick and easy way to set folder exclusions? Any help is appreciated and simply using google is not good enough, as this is a new problem, caused by the update.
      Any ideas please?
      ____________________________
      ANSWER
      Found it.
      Accessing the menu through the Control Panel does not work
      Click the Defender shield in the icon tray.
      Scroll down to Virus & threat protection settings click Manage Settings Scroll down to Exclusions click Add or remove exclusions then click the + for Add an exclusion, and select File / Folder / File type / Process 
      Select Folder and browse to select. 😥
       
      Skysnake
    • By jantograaf
      Hi all,
      I'm trying to automate the install of a specific networking device. All goes well, I can install the driver on both Windows 7 & 10, rescan for hardware, set the IP-settings and all, but there's one issue. In Windows 10, I can disable all connection protocols using Powershell, but Windows 7 does not offer this Powershell-Cmdlet. So I programmed a way (two years ago) to let AutoIt open the network-adapter properties and then deselect all checkboxes except for the TCP/IP-V4. I recovered this snippet somewhere in my old files and tried to reintegrate this into my latest script, but it doesn't seem to work. On Windows 10 I get a blank screen for a few seconds and that's it, on Windows 7 it makes explorer crash. 
      I think it's quite safe to test this on your own system as long as you're not using IPv6 to connect to the internet and as long as you return to check all the boxes again (so you don't break your connectivity).
      If  anyone has any idea, I'd be glad to hear from you!
      Thanks in advance and stay safe in these Corona-ridden times 🙂
      Kind regards,
      Jan
       

      There are three functions involved:
      DisableAllProtocols($AdapterName)
      This one is the main function that 'should' uncheck all the checkboxes in the adapter's Properties-window.
      Func DisableAllProtocols($AdapterName) OpenNetConnToAdapter($AdapterName) ;Find the IDs of all relevant controls Local $Handle_Window_Properties = WinWaitActive($Adaptername & " Properties","") Local $Handle_Listview_Protocols = ControlGetHandle($Adaptername & " Properties","","[CLASSNN:SysListView321]") Local $Handle_OK_Button = ControlGetHandle($Adaptername & " Properties","","[CLASSNN:Button6]") Local $List_CMN_ID = ControlListView($Adaptername & " Properties","","[CLASSNN:SysListView321]","FindItem","Client for Microsoft Networks") Local $List_FPSMN_ID = ControlListView($Adaptername & " Properties","","[CLASSNN:SysListView321]","FindItem","File and Printer Sharing for Microsoft Networks") Local $List_QOS_ID = ControlListView($Adaptername & " Properties","","[CLASSNN:SysListView321]","FindItem","QoS Packet Scheduler") Local $List_MNAMP_ID = ControlListView($Adaptername & " Properties","","[CLASSNN:SysListView321]","FindItem","Microsoft Network Adapter Multiplexor Protocol") Local $List_MLLDPPD_ID = ControlListView($Adaptername & " Properties","","[CLASSNN:SysListView321]","FindItem","Microsoft LLDP Protocol Driver") Local $List_IPV6_ID = ControlListView($Adaptername & " Properties","","[CLASSNN:SysListView321]","FindItem","Internet Protocol Version 6 (TCP/IPv6)") Local $List_LLTDR_ID = ControlListView($Adaptername & " Properties","","[CLASSNN:SysListView321]","FindItem","Link-Layer Topology Discovery Responder") Local $List_LLTDMIOD_ID = ControlListView($Adaptername & " Properties","","[CLASSNN:SysListView321]","FindItem","Link-Layer Topology Discovery Mapper I/O Driver") ; Disable All Protocols Except IPV4 SetCheckboxState($Handle_Listview_Protocols,$List_CMN_ID,3) SetCheckboxState($Handle_Listview_Protocols,$List_FPSMN_ID,3) SetCheckboxState($Handle_Listview_Protocols,$List_QOS_ID,3) SetCheckboxState($Handle_Listview_Protocols,$List_MNAMP_ID,3) SetCheckBoxState($Handle_Listview_Protocols,$List_MLLDPPD_ID,3) SetCheckboxState($Handle_Listview_Protocols,$List_IPV6_ID,3) SetCheckboxState($Handle_Listview_Protocols,$List_LLTDR_ID,3) SetCheckboxState($Handle_Listview_Protocols,$List_LLTDMIOD_ID,3) ;Click OK ControlClick($Handle_Window_Properties,"","Button6") Sleep(50) WinClose("Network Connections") EndFunc OpenNetConnToAdapter($AdapterName)
      This function opens the network adapter's Properties-page
      Func OpenNetConnToAdapter($AdapterName) ShellExecute("control.exe","ncpa.cpl",@WindowsDir,"",@SW_SHOW) WinWait("Network Connections","") WinActivate("Network Connections","") Local $Handle_Window_NetworkConnections = WinWaitActive("Network Connections","") Send("{F5}") Sleep(250) Local $AdapterNameArray = StringSplit($AdapterName,"") For $i = 1 To $AdapterNameArray[0] Step 1 Send($AdapterNameArray[$i]) Sleep(10) Next Sleep(50) Send("{APPSKEY}") Sleep(50) Send("{R}") Sleep(500) Return EndFunc SetCheckboxState($Handle,$checkbox_id,$wantedstate)
      This function changes the state of a checkbox
      Func SetCheckboxState($handle,$checkbox_id,$wantedstate) ;$handle : SysListView32-handle ;$checkbox_id : The ID of the checkbox you want to control ;$wantedstate : The wanted status (2 for checked, 3 for unchecked) Local $currentstate = _GUICtrlListView_GetItemStateImage($handle,$checkbox_id) If $currentstate = $wantedstate Then Return Else _GUICtrlListView_SetItemSelected($handle,$checkbox_id,True,True) Send("{Space}") Sleep(50) Return EndIf EndFunc  
×
×
  • Create New...