
joe1981al
Members-
Posts
11 -
Joined
-
Last visited
joe1981al's Achievements

Seeker (1/7)
0
Reputation
-
If 2 NIC connected then disable 1 network adaptor
joe1981al replied to Mukhtar's topic in AutoIt General Help and Support
I'm using on Win7 perfectly, I wrote this to be cross platform, I call the AdapterKill function with variables from an INI file so a compiled file can be distributed and then customized with ini for the variables. It seems that all the stuff I want to do with autoit is out on the fringes and I have to come up with ways to make it happen... #RequireAdmin Func AdapterKill($AdaptDescription, $ConnectionName, $bEnable = false) ;$AdaptDescription = "' '" ;for Vista/Win7 Actual Adapter Name must be single quoted inside double-quotes ;$ConnectionName = " " ;for PreVista Connection Name in Net Connections if @OSType<>"WIN32_NT" then SetError(1) endif if @OSVersion="WIN_2000" then $strFolderName = "Network and Dial-up Connections" PreVistaDisable($ConnectionName,$strFolderName,$bEnable) Return 0 elseif StringInStr(@OSVersion, "WIN_XP") then $strFolderName = "Network Connections" PreVistaDisable($ConnectionName,$strFolderName,$bEnable) Return 0 else VistaDisable($AdaptDescription,$bEnable) Return 0 endif EndFunc Func VistaDisable($Adapter, $bEnable = false) $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") If $objWMIService.ExecQuery("SELECT Description FROM Win32_NetworkAdapter WHERE NetEnabled = True AND Description = " & $Adapter).Count > 0 Then $colItems = $objWMIService.ExecQuery("SELECT Description FROM Win32_NetworkAdapter WHERE NetEnabled = True AND Description = " & $Adapter) If IsObj($colItems) Then For $objItem In $colItems If $bEnable = False Then $objItem.Disable() Else $objItem.Enable() EndIf Next Return 0 EndIf EndIf EndFunc Func PreVistaDisable($oLanConnection,$strFolderName, $bEnable = false) ;$bEnable = false ; Change this to 'false' to DISABLE the network adapter Select Case StringInStr("0409,0809,0c09,1009,1409,1809,1c09,2009, 2409,2809,2c09,3009,3409", @OSLang) ; English (United States) $strEnableVerb = "En&able" $strDisableVerb = "Disa&ble" ; Add here the correct Verbs for your Operating System Language EndSelect ;Virtual folder containing icons for the Control Panel applications. (value = 3) Const $ssfCONTROLS = 3 $ShellApp = ObjCreate("Shell.Application") $oControlPanel = $shellApp.Namespace($ssfCONTROLS) ; Find 'Network connections' control panel item $oNetConnections="" For $FolderItem in $oControlPanel.Items If $FolderItem.Name = $strFolderName then $oNetConnections = $FolderItem.GetFolder Exitloop Endif Next If not IsObj($oNetConnections) Then SetError(1) EndIf For $FolderItem In $oNetConnections.Items If StringLower($FolderItem.Name) = StringLower($oLanConnection) Then $oLanConnection = $FolderItem Exitloop EndIf Next If not IsObj($oLanConnection) Then SetError(1) EndIf $oEnableVerb="" $oDisableVerb="" For $Verb In $oLanConnection.Verbs If $Verb.Name = $strEnableVerb Then $oEnableVerb = $Verb EndIf If $Verb.Name = $strDisableVerb Then $oDisableVerb = $Verb EndIf Next If $bEnable then If IsObj($oEnableVerb) Then $oEnableVerb.DoIt ; Enable network card Endif If not $bEnable then If IsObj($oDisableVerb) Then $oDisableVerb.DoIt; Disable network card EndIf Sleep(1000) EndFunc -
If 2 NIC connected then disable 1 network adaptor
joe1981al replied to Mukhtar's topic in AutoIt General Help and Support
UEZ not sure if your still looking at this but I did find out an easy way to do this in Vista+ check my modified code, uses a different WMI Class but its pretty simple. #RequireAdmin Global $ip = "localhost" If $CmdLine[0] > 0 Then $ip = $CmdLine[1] $AdaptDescription = "'Cisco Anyconnect VPN Virtual Miniport Adapter for Windows'" $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $ip & "\root\cimv2") GetWMI($ip) Func GetWMI($srv) Local $colItems If $objWMIService.ExecQuery("SELECT Description FROM Win32_NetworkAdapter WHERE NetEnabled = True AND Description = " & $AdaptDescription).Count > 0 Then $colItems = $objWMIService.ExecQuery("SELECT Description FROM Win32_NetworkAdapter WHERE NetEnabled = True AND Description = " & $AdaptDescription) If IsObj($colItems) Then For $objItem In $colItems $objItem.Disable() Next EndIf EndIf EndFunc -
Sorry that the attachment didn't post on, its on this one. I forgot to click "attach this file". Sorry if it was confusing, but did dig deeper and the combo box items are in a DIV element, just the div was not loaded until I clicked on the down arrow next to the input box. I have now wrote myself a little function to click that image and then find the correct DIV on the page to click on. BTW the "IEMyFullClick" just fires onmousedown, onmouseup, click so no matter what the javascript is watching it will find it. Func TechCriteria($oIE) _IEImgClick($oIE, "https://technet.csgsystems.com/chtr/wfx/00524105036/images/default/s.gif","src",18) Sleep(1000) $divs = _IETagNameGetCollection($oIE, "div") $techfilter = IniRead(".\WFXSettings.ini", "TechFilter", "filter", "NotFound") For $div in $divs If StringInstr($div.className, "x-combo-list-item") Then If $div.innertext = $techfilter Then IEMyFullClick($div) ExitLoop EndIf EndIf Next EndFunc I'm somewhat new to scripting, especially on this level. Your suggestions on this and my other post of worked great and searching the forums has helped me tremendously putting things together. Almost everything is done now and just finishing up with some error checks being put in.
-
Attached Capture.JPG is the toolbar created by the javascript above and show in HTML below it. I can _IEFormElementSetValue($orptframe, $techfilter) and the box will populate with "CUITECHS" (my filter variable). My issue is that its not a traditional HTML dropdown box and doesn't use the "onchange" event to perform action. The javascript above is waiting for a select record action to perform "on(select:onFilterSelect)", I know how use function to fire javascript but the issue I'm having is "new Ext.form.ComboBox" is not assigned to a variable so I can call it directly with something like combo.SelectValue("CUITECHS",True). My work around does function by making IE active window and tabbing to that box then typing in it. Probably more javascript in the background watching that box for input changes, but for some reason setting the value directly doesn't cause the action to fire.
-
*bump* Having a similar issue, I think using _IEHeadInsertEventScript is what I would need, but not sure how to script something to monitor the FileDownload event, and when it is fired capture the URL to a variable, pass it back to autoit, and cancel the download. Once its back in autoit I plan on either downloading nativly or opening directly in excel depending on which works easier. Can't wait until this final step of getting the file is done, no more having to script against this site wrote almost entirely off javascript. If it was a simple link on a page I could easily put in variable, but the site uses javascript to dynamically create a filename for each download attempt.
-
Still working on a complicated script to automate a file download here. I can make the "filterName" input box have my value in it, but it doesn't perform the action and there is no button to click to force the action. The loading of the panel is fired by the select listener in the javascript. The combo box is not assigned to a variable, so I can figure out how to fire the combobox.selectbyvalue to make it start. Any guidance would be appreciated, so close to completing the complicated portion of the script. This javascript combined with some HTML template creates a menu on a page: tbar:["WFX Data Export", '->', "Filter Name: ", new Ext.form.ComboBox( {id:'filterName', store:new wfx.Store(), mode:'local', triggerAction:'all', selectonfocus:true, displayField:'filter_name', valueField:'filter_name', listeners:{select:onFilterSelect, blur:adjustFilterButtons}, afterRender: function() { Ext.form.ComboBox.superclass.afterRender.call(this); this.el.setStyle('text-transform', 'uppercase'); this.el.set({'maxlength':20}); } }), ' ', ' ', {text:'Save', handler:saveFilter, icon:'images/disk.png', cls:'x-btn-text-icon', id:'save-fltr-btn', disabled:true}, {text:'Delete', handler:deleteFilter, icon:'images/delete.png', cls:'x-btn-text-icon', id:'del-fltr-btn', disabled:true} ], This is the HTML created by this: <DIV style="WIDTH: 741px" id=ext-comp-1088 class="x-toolbar x-small-editor x-toolbar-layout-ct"> <TABLE class=x-toolbar-ct cellSpacing=0> <TBODY> <TR> <TD class=x-toolbar-left align=left> <TABLE cellSpacing=0> <TBODY> <TR class=x-toolbar-left-row> <TD id=ext-gen117 class=x-toolbar-cell> <DIV id=ext-comp-1089 class=xtb-text>WFX Data Export</DIV></TD></TR></TBODY></TABLE></TD> <TD class=x-toolbar-right align=right> <TABLE class=x-toolbar-right-ct cellSpacing=0> <TBODY> <TR> <TD> <TABLE cellSpacing=0> <TBODY> <TR class=x-toolbar-right-row> <TD id=ext-gen119 class=x-toolbar-cell> <DIV id=ext-comp-1091 class=xtb-text>Filter Name: </DIV></TD> <TD id=ext-gen121 class=x-toolbar-cell> <DIV style="WIDTH: 165px" id=ext-gen123 class="x-form-field-wrap x-form-field-trigger-wrap"><INPUT style="TEXT-TRANSFORM: uppercase; WIDTH: 148px" id=filterName class=" x-form-text x-form-field" size=24 name=filterName autocomplete="off" maxlength="20"><IMG id=ext-gen124 class="x-form-trigger x-form-arrow-trigger" src="https://technet.csgsystems.com/chtr/wfx/00405082605/images/default/s.gif"></DIV></TD> <TD id=ext-gen125 class=x-toolbar-cell> <DIV id=ext-gen126 class=xtb-spacer></DIV></TD> <TD id=ext-gen127 class=x-toolbar-cell> <DIV id=ext-gen128 class=xtb-spacer></DIV></TD> <TD id=ext-gen129 class=x-toolbar-cell> <TABLE style="WIDTH: auto" id=save-fltr-btn class="x-btn x-btn-text-icon x-btn-text-icon x-item-disabled" disabled cellSpacing=0> <TBODY class="x-btn-small x-btn-icon-small-left"> <TR> <TD class=x-btn-tl><I> </I></TD> <TD class=x-btn-tc></TD> <TD class=x-btn-tr><I> </I></TD></TR> <TR> <TD class=x-btn-ml><I> </I></TD> <TD class=x-btn-mc><EM unselectable="on"><BUTTON style="BACKGROUND-IMAGE: url(images/disk.png)" id=ext-gen130 class=" x-btn-text">Save</BUTTON></EM></TD> <TD class=x-btn-mr><I> </I></TD></TR> <TR> <TD class=x-btn-bl><I> </I></TD> <TD class=x-btn-bc></TD> <TD class=x-btn-br><I> </I></TD></TR></TBODY></TABLE></TD> <TD id=ext-gen131 class=x-toolbar-cell> <TABLE style="WIDTH: auto" id=del-fltr-btn class="x-btn x-btn-text-icon x-btn-text-icon x-item-disabled" disabled cellSpacing=0> <TBODY class="x-btn-small x-btn-icon-small-left"> <TR> <TD class=x-btn-tl><I> </I></TD> <TD class=x-btn-tc></TD> <TD class=x-btn-tr><I> </I></TD></TR> <TR> <TD class=x-btn-ml><I> </I></TD> <TD class=x-btn-mc><EM unselectable="on"><BUTTON style="BACKGROUND-IMAGE: url(images/delete.png)" id=ext-gen132 class=" x-btn-text">Delete</BUTTON></EM></TD> <TD class=x-btn-mr><I> </I></TD></TR> <TR> <TD class=x-btn-bl><I> </I></TD> <TD class=x-btn-bc></TD> <TD class=x-btn-br><I> </I></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD> <TD> <TABLE cellSpacing=0> <TBODY> <TR class=x-toolbar-extras-row></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV>[/HTML]
-
It works and interacts perfectly with the javascript, and also had to look up your IEEVal() function from another thread that works great. Something to maybe add to the IEAction is "fullclick" or even replace click with all three actions, I add function to my script to do fullclick action every time just in case some javascript is watching it. Func _IEMyFullClick($oElement) ;Function to perform full click $oElement.fireEvent("onmousedown") $oElement.fireEvent("onmouseup") _IEAction($oElement, "click") EndFunc
-
Dale: Thanks Dale will give this a try. I've spent 3 days dealing with this site trying to automate a single file download, and got stuck because of the way someone wrote the site. Wouldn't be a bad idea to add a "fullclick" process to _IEAction that does the above. Volly: It requires login, but the details I see: They use a very large main javascript thats been minified, that stores a lot of functions while it loads a small file that monitors the individual page and waits for actions. I'm not sure how IE works, but I assume on "mousedown" IE creates variables for navigating to a link then acts upon those variables when it sees "click". The sites javascript fires an action on "mousedown" that loads ALOT of variables in two collections, one containing system variables, one dumping ie variables, in particular uses "t.id" to figure out the URL of the <a href> tag and execute code based upon its content to load a secondary frame with a javascript panel. Then fires on "click" and cancels IEs native link handling.
-
Dale: Thanks Dale will give this a try. I've spent 3 days dealing with this site trying to automate a single file download, and got stuck because of the way someone wrote the site. Wouldn't be a bad idea to add a "fullclick" process to _IEAction that does the above. Volly: It requires login, but the details I see: They use a very large main javascript thats been minified, that stores a lot of functions while it loads a small file that monitors the individual page and waits for actions. I'm not sure how IE works, but I assume on "mousedown" IE creates variables for navigating to a link then acts upon those variables when it sees "click". The sites javascript fires an action on "mousedown" that loads ALOT of variables in two collections, one containing system variables, one dumping ie variables, in particular uses "t.id" to figure out the URL of the <a href> tag and execute code based upon its content to load a secondary frame with a javascript panel. Then fires on "click" and cancels IEs native link handling.
-
Anybody know a workaround to get a script to fire the "mousedown" event? I'm even up for using mouseclick if there is a way to detect screen location of the link. I've tried a few things but no success, the javascript on a page i'm trying to automate uses a mousedown event to pull data and load a frame using some system IE variables associated with the a href link clicked, then uses a onclick to cancel the navigation to the a href. I've tried to throw together some navigate(javascript:action) stuff but doesn't work because the variables are not in memory that it needs to fire off the event.