1 post in this topic
r not working
I'm working on a relatively complex automation program and I need it to call a specific function when it is closed by a user. Ive resorted to "OnAutoItExitRegister" as i believe that's the only option available.
This command works perfectly fine in a small scale test application I wrote, but once implemented in the final program that's much larger and divided over many files in many directories it no longer works. I don't get any error messages.
My question is has anyone encountered an issue where implementation of this command in a large scale program gave them trouble? Does it matter where "OnAutoItExitRegister" is called and where the function is located? Currently they are both places in the main file that runs the whole program but it still doesn't work.
Any help is appreciated
Exit / Stop Script
Ctrl+Break stops script only if AutoIt window is active. It doesn't work while automation is going on elsewhere.
Is there a way to stop the script regardless of where the automation is happening?
Open webpages by checking boxes
Hello everyone, don't even know how to ask. My code is:
#include <String.au3> #include <IE.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 700, 500, 192, 124) $Button1 = GUICtrlCreateButton("View", 576, 24, 89, 41) Global $oIE = _IECreate("https://www.youtube.com/playlist?list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z", 1, 1, 0) Sleep(1000) Global $sHTML = _IEDocReadHTML($oIE) $FirstChunks = _StringBetween($sHTML, 'pl-video-title-link yt-uix-tile-link yt-uix-sessionlink', '<div class="pl-video-owner') $x = 16 For $a In $FirstChunks $actualdata = _StringBetween($a, '">', '</a>') ;$actualdata2 = _StringBetween($a, 'href="', '&') $Checkbox1 = GUICtrlCreateCheckbox($actualdata, 24, $x, 500, 17) $x = $x + 20 Next GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Somehow I need to open webpages where checkbox is checked by presing button view, I think I need somehow asign $actualdata with $actualdata2. Any ideas would be very appreciated
Exit function from "outsite" with button press
I have written a little loop program that counts to whatever you choose in "Rounds".
(this is just a short version of my program, but it should cover what I try to achieve)
I now want to be able to stop the counting by pressing the start/stop button. Unfortunately, autoit only registers my click on my button AFTER the func has ended.
Do you guys have an idea how to stop the function? Maybe check if button was pressed in the loop?
#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <IE.au3> #include <Array.au3> #include <File.au3> $Form1 = GUICreate("Looper", 355, 229, 435, 293) $StartStop = GUICtrlCreateButton("Start", 136, 184, 75, 25) $Rounds = GUICtrlCreateInput("1", 210, 40, 80, 21) $lRounds = GUICtrlCreateLabel("Rounds", 298, 42, 52, 18) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $StartStop If GUICtrlRead($StartStop) = "Start" Then GUICtrlSetData($StartStop, "Stop") GUICtrlSetState($Rounds, $GUI_DISABLE) Call("Loop") ElseIf GUICtrlRead($StartStop) = "Stop" Then ExitLoop MsgBox(0, "Info", "Stopped") Else MsgBox(0, "Info", "Error") EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Loop() $LoopTimes = GUICtrlRead($Rounds) For $i = 1 To $LoopTimes MsgBox(0, "Info", "LET US COUNT: " & $i) Sleep("2000") Next GUICtrlSetData($StartStop, "Start") GUICtrlSetState($StartStop, $GUI_ENABLE) GUICtrlSetState($Rounds, $GUI_ENABLE) EndFunc
Set Checked / un-checked value according to Registry value
Hi all, first post here ever, I'm working on a project, Helpdesk type tool. I'm trying to set the State (Checked, Unchecked) of check boxes, and Or button, (a Toggle). this would be set by determining the Value of Certain Reg keys, here is my phone below. $PC_select_data is the Computer Name so you could replace it with "@Computer".
I looked and looked and couldn't find whats wrong.
I'm new to Autoit somewhat.
I may be complicating things by assigning Arrays for my controls, but I think this will work.
the first part is fine, I get a Computer from a list (that I got from AD with Water's Awesome UDF)
please not I'm using onevent also, well. the UDF OnEventA that allows upto 4 ByVal or Ref's
I get the Value $PC_selected_data
return the value to the Function
I send a test Key with Regread, if I can't read it I launch sc.exe to run Remote Reg.
Then I read 5 values from the Remote Reg. I assigned a Array of those Values and Also Assigned a Array of my CheckBoxes also.
Now my logic, if the Value of the REG key is "" (blank) then UnCheck all the check boxes, else, Check them. Now, to make this more efficient, I put the Controls in an Array, of the Same Lenth. now here is the think, I run my script, it runs fine, finds the value, and Un-checks all of the check boxes, now if I go change one of the REG values, it does not Check them. because of the Logic for the For Loop. I would have figured that If the first value of the Array $Run_as_MSIscheck = somevalue that it would see that as a "ELSE" and Check the box. Since the For loop contains the If - then- Else, but I Understand that it only runs the first Block, IF the condition is True. So I guess Am I totally off track?
Func Check_PC_status($PC_select_Data) local $pingPC local $regtemp = "" local $x = "" local $Run_as_MSIcheck,$Run_as_CMDcheck,$Run_as_BATCheck,$Run_as_REGcheck local $RUNas_chks = [$MSI_runAs_chk,$CMD_runAs_chk,$BAT_runAs_chk,$REG_runAs_chk] local $runAS_function_check = [$Run_as_MSIcheck,$Run_as_CMDcheck,$Run_as_BATCheck,$Run_as_REGcheck] ;~ @error: ;~ 1 = Host is offline ;~ 2 = Host is unreachable ;~ 3 = Bad destination ;~ 4 = Other errors ;Sends Ping to pc to see if its live or not. $pingPC = ping($PC_select_Data,2000) ;if Ping has returned a good value, NOT 0. check current status of the following lines in registry. checkes for RunAS for CMD/MSI/BAT and Remote REG keys. checks for SMS prompt control. if $pingPC Then ;tries to read a key from the registry, and returns its value, if its blank, $regtemp = RegRead("\\" & $PC_select_Data & "\HKLM\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control", "Permission Required") ConsoleWrite("Sending test Key, is set to: " & $regtemp & @CRLF) ;~error: 3 = Bad destination if @error = 3 or $regtemp = "" Then ConsoleWrite("Unable to determine status of remote registry!!!" & @CRLF & "Trying to start Remote Registry.... via Service Control Manager" & @CRLF ) RunWait(@SystemDir & '\sc.exe \\' & $PC_select_Data & ' start RemoteRegistry',"","") if Not @error then ConsoleWrite("Remote Registry loaded" & @CRLF & @CRLF) EndIf EndIf TCPStartup() $IPadd = TCPNameToIP ($PC_select_Data) ConsoleWrite($IPadd & @CRLF) TCPShutdown() ConsoleWrite("ping Success: " & $pingPC & "ms" & @CRLF) $Sccm_PROMPTcheck = RegRead("\\" & $PC_select_Data & "\HKLM\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control", "Permission Required") $Run_as_MSIcheck = RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\Msi.Package\shell\runas\command", "") ; MSI access Check $Run_as_CMDcheck = RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\cmdfile\shell\runas\command", "") ; CMS access Check $Run_as_BATCheck = RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\batfile\shell\runas\command", "") ; BAT access Check $Run_as_REGcheck = RegRead("\\" & $PC_select_Data & "\HKEY_CLASSES_ROOT\regfile\shell\runas\command", "") ; REG access Check ConsoleWrite("SMS Client status: " & $Sccm_Promptcheck & @CRLF & "MSI RunAS Status: " & $Run_as_MSIcheck & @CRLF & "CMD RunAs Status: " & $Run_as_CMDcheck & @CRLF & "BAT RunAs Status: " & $Run_as_BATCheck & @CRLF & "REG RunAs Status: " & $Run_as_REGcheck & @CRLF & @CRLF) for $x = 0 to UBound($runAS_function_check) -1 ConsoleWrite("Count: " & $x & @CRLF) if $runAS_function_check[$x] = "" Then $test1 = guictrlread($RUNas_chks[$x]) ConsoleWrite("B4 " & $test1 & @CRLF) GUICtrlSetState($RUNas_chks[$x],$GUI_UNCHECKED) $test2 = guictrlread($RUNas_chks[$x]) ConsoleWrite("After " & $test2 & @CRLF) Else GUICtrlSetState($RUNas_chks[$x],$GUI_CHECKED) EndIf Next Else ConsoleWrite($PC_select_Data & " is Not reachable" & @CRLF & @CRLF) EndIf Endfunc any help is appreciated.