-
Posts
280 -
Joined
-
Last visited
-
Days Won
1
Community Answers
-
Neutro's post in Clicking on button of a website in IE stops working overnight for no reason was marked as the answer
I found a workaround doing this with powershell instead:
$oIE = new-object -com internetexplorer.application $oIE.visible = $true $oIE.navigate2("https://intranetwebsite.com") $control = $oIE.document.IHTMLDocument3_getElementsByTagName('button') | where-object { $_.innerText -eq 'Update' } $control.click() Translated into autoit:
$sPSCmd = " ""$oIE = new-object -com internetexplorer.application;$oIE.visible = $true;$oIE.navigate2('https://ourintranetwebsite'); sleep -Milliseconds 10000; $control = $oIE.document.IHTMLDocument3_getElementsByTagName('button'); $control = $oIE.document.IHTMLDocument3_getElementsByTagName('button') | where-object { $_.innerText -eq 'Update' };$control.click()"" " RunWait(@comspec & ' /c powershell.exe -executionpolicy bypass -NoProfile -WindowStyle hidden -command ' & $sPSCmd) The double quotes at the start and end of the command are required to avoid syntax error with the windows prompt shell (cmd window)
PS: the below solution also works to create the IE window using autoIT and use powershell to click the button, so you can do other things with the IE window with autoIT after:
#include <IE.au3> $oIE = _IECreate("https://ourintranetwebsite, 1, 1, 1) $sPSCmd = " ""$PSIE = (New-Object -ComObject 'Shell.Application').Windows() | Where-Object { $_.Name -eq 'Internet Explorer' }; $control = $PSIE.document.IHTMLDocument3_getElementsByTagName('button') | where-object { $_.innerText -eq 'Update' };$control.click()"" " RunWait(@comspec & ' /c powershell.exe -executionpolicy bypass -NoProfile -WindowStyle hidden -command ' & $sPSCmd, "", @SW_HIDE) ;do other things regularly using _IE functions with autoIT if required here _IEQuit($oIE)
-
Neutro's post in Disable button if input is empty and checkbox unchecked was marked as the answer
Hello,
You just needed to split this:
If BitAnd(GUICtrlRead($Checkbox1),$GUI_UNCHECKED) = $GUI_UNCHECKED And GUICtrlRead($Input1) = "" And $i = 1 Then Into 2 seperate if statements:
If GUICtrlRead($Input1) = "" And $button_enabled = 1 Then GUICtrlSetState($Button1, $GUI_DISABLE) $button_enabled = 0 Elseif BitAnd(GUICtrlRead($Checkbox1),$GUI_UNCHECKED) = $GUI_UNCHECKED and $button_enabled = 1 Then GUICtrlSetState($Button1, $GUI_DISABLE) $button_enabled = 0 Full code:
#NoTrayIcon #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### $Form1 = GUICreate("Form1", 401, 193, 192, 124) $Input1 = GUICtrlCreateInput("", 120, 16, 160, 21) $Button1 = GUICtrlCreateButton("Button1", 120, 72, 160, 25) GUICtrlSetState($Button1, $GUI_DISABLE) $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 122, 128, 97, 17) GUICtrlSetState($Checkbox1, $GUI_CheckED) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### $button_enabled = 1 While 1 If GUICtrlRead($Input1) = "" And $button_enabled = 1 Then GUICtrlSetState($Button1, $GUI_DISABLE) $button_enabled = 0 Elseif BitAnd(GUICtrlRead($Checkbox1),$GUI_UNCHECKED) = $GUI_UNCHECKED and $button_enabled = 1 Then GUICtrlSetState($Button1, $GUI_DISABLE) $button_enabled = 0 ElseIf $button_enabled = 0 And BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED) = $GUI_CHECKED And GUICtrlRead($Input1) <> "" Then GUICtrlSetState($Button1, $GUI_ENABLE) $button_enabled = 1 EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; do your thing EndSwitch WEnd