Masum

Exit / Stop Script

12 posts in this topic

Hi all,

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?

Thanks

Share this post


Link to post
Share on other sites



Thanks but that too didn't work, only worked while AutoIt was the active screen.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

What didn't  work exactly as I have no idea what you mean with AutoIt being the active screen?

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

As in when the script is automating other apps, like Excel and a remote application, exiting the script via CTRL+Break or via a HotKeySet does not work. Could this be due to the fact the script is always doing something, hence doesn't give it the chance to read any keyboard entry via a manual method, and hence why CTRL+Break or HotKeySet are not read to be actioned?

Share this post


Link to post
Share on other sites

Also, does this forum support email notification for post responses? I don't get any, hence the late replies...

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Call me slow, but I am still puzzled what you mean here. Show me a demo script that has something blocking an hotkey set by HotKeySet().

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi, it's a fairly short script, hence I've copied all of it below. Two issues with it, 1. HotKey does not respond while the script is running, 2. the If conditions do not work, I've created a post for the second issue here

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

;Ensure this script is saved in the same directory as the DCW.
;Ensure InboxConfigTool.exe is open and Maximised.
;Ensure the screen resolution is set to 1366 x 768 and no additional screens are connected.

HotKeySet('e', 'EndProgram')

SelectManagePoolsTab()

;Create Excel application object
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

;Open DCW
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\CHB Data Collection Workbook - Message Centre.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Error", "Error opening workbook '" & @ScriptDir & "CHB Data Collection Workbook - Message Centre.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

$oExcel.Sheets("CHFT Pools & RTE Rules").Select ;Select the CHFT Pools & RTE Rules tab of the DCW

Local $Row = 13 ;Used to store data from cells of the current row, here the starting row is defined, 13 being the first row
Local $Finish = 'Finish' ;Used as an anchor to stop the script passed the last row of the DCW

Do
    Local $Status = _Excel_RangeRead($oWorkbook, 'CHFT Pools & RTE Rules', 'I' & $Row) ;Stores current data from the 'Built?' column
    MsgBox(0, "Status", "Status of cell I" & $Row & " is " & $Status)

    If $Status = '' Then
        Local $PoolName = _Excel_RangeRead($oWorkbook, 'CHFT Pools & RTE Rules', 'E' & $Row)
        Local $PoolDescription = _Excel_RangeRead($oWorkbook, 'CHFT Pools & RTE Rules', 'F' & $Row)
        Local $RTERuleName = _Excel_RangeRead($oWorkbook, 'CHFT Pools & RTE Rules', 'G' & $Row)
        Local $FirstName = _Excel_RangeRead($oWorkbook, 'CHFT Pools & RTE Rules', 'B' & $Row)
        Local $LastName = _Excel_RangeRead($oWorkbook, 'CHFT Pools & RTE Rules', 'A' & $Row)
        Local $Notes = _Excel_RangeRead($oWorkbook, 'CHFT Pools & RTE Rules', 'J' & $Row)
        Sleep(100)
        ActivateInboxConfigTool()
        AddPool()
        DragScrollBarUp()
        EnterPoolName()
        EnterPoolDescription()
        SearchForMember()
        AddMember()
        MakeTeamLead()
        SetMemberOptions()
        DragScrollBarDown()
        SetOrganisations()
        AddRTERule()
    EndIf

    $Row = $Row + 1
Until $Status = $Finish

Sleep(500)
MsgBox(64, 'Update', 'The script has finished building the pools from the chosen DCW, please review what needs to be redone or failed.')
Exit

Func ActivateInboxConfigTool()
    Do
        WinActivate("Inbox Config Tool")
        Sleep(100)
    Until WinActive("Inbox Config Tool")
EndFunc   ;==>ActivateInboxConfigTool

Func SelectManagePoolsTab()
    ActivateInboxConfigTool()
    Sleep(100)
    MouseClick('primary', 230, 118, 1) ;Click on Manage Pools tab
    Sleep(200)
EndFunc   ;==>SelectManagePoolsTab

Func AddPool()
    MouseClick("left", 554, 675, 1) ;Click Add
    Sleep(100)
EndFunc   ;==>AddPool

Func DragScrollBarUp()
    MouseClickDrag('Primary', 1345, 574, 1345, 401)
    Sleep(100)
EndFunc   ;==>DragScrollBarUp

Func EnterPoolName()
    MouseClick('Primary', 100, 409, 1) ;Click in Name field
    Sleep(100)
    Send($PoolName)
    Sleep(100)
EndFunc   ;==>EnterPoolName

Func EnterPoolDescription()
    MouseClick('Primary', 100, 458, 1) ;Click in Description field
    Sleep(100)
    Send($PoolDescription)
    Sleep(100)
EndFunc   ;==>EnterPoolDescription

Func SearchForMember()
    MouseClick('Primary', 100, 507, 1) ;Click in Search for Member field
    Sleep(100)
    Send('System,System')
    Sleep(100)
    Send('{TAB}') ;Tab over to the Magnifying glass button
    Send('{SPACE}') ;Press Magnifying glass
    Send('{Enter}') ;Press OK on the Clinical Staff Selection window
    Sleep(100)
EndFunc   ;==>SearchForMember

Func AddMember()
    MouseClick('Primary', 100, 612, 1) ;Select available member
    Sleep(100)
    MouseClick('Primary', 339, 619, 1) ;Click Add
    Sleep(100)
EndFunc   ;==>AddMember

Func MakeTeamLead()
    MouseClick('Primary', 411, 612, 1) ;Select active member
    Sleep(100)
    MouseClick('Primary', 499, 553, 1) ;Click Make Team Lead
    Sleep(100)
EndFunc   ;==>MakeTeamLead

Func SetMemberOptions()
    MouseClick('Primary', 689, 441, 1) ;Tick Allow users to opt-in or opt-out of membership
    Sleep(100)
    MouseClick('Primary', 689, 466, 1) ;Tick Allow users without org association to view the pool
    Sleep(100)
    MouseClick('Primary', 689, 492, 1) ;Tick Allow users without org association to forward to the pool
    Sleep(100)
EndFunc   ;==>SetMemberOptions

Func DragScrollBarDown()
    MouseClickDrag('Primary', 1345, 401, 1345, 574)
    Sleep(100)
EndFunc   ;==>DragScrollBarDown

Func SetOrganisations()
    Send('{CTRLDOWN}')
    MouseClick('Primary', 703, 576, 1) ;Select Bradford Royal Infirmary
    Sleep(100)
    MouseClick('Primary', 703, 619, 1) ;Selct Calderdale Royal Hospital
    Sleep(100)
    MouseClickDrag('Primary', 931, 582, 931, 592)
    Sleep(100)
    MouseClick('Primary', 703, 576, 1) ;Select Huddersfield Royal Infirmary
    Sleep(100)
    MouseClickDrag('Primary', 931, 592, 931, 596)
    Sleep(100)
    MouseClick('Primary', 703, 592, 1) ;Select St. Lukes Hospital
    Sleep(100)
    Send('{CTRLUP}')
    MouseClick('Primary', 979, 564, 1) ;Click Add
    Sleep(100)
EndFunc   ;==>SetOrganisations

Func AddRTERule()
    MouseClick('Primary', 69, 657, 1) ;Click Rules...
    Sleep(100)
    MouseClick('Primary', 363, 228, 1) ;Click Type
    Sleep(100)
    MouseClick('Primary', 363, 266, 1) ;Click RTE
    Sleep(100)
    MouseClick('Primary', 363, 545, 1) ;Click New Rule
    Sleep(100)
    Send($RTERuleName) ;Enter Mnemonic
    Sleep(100)
    Send('{TAB}') ;Enter Description
    Send('{TAB}{TAB}{RIGHT}') ;Navigate to Rule tab
    Send('{SHIFTDOWN}{TAB}{TAB}{TAB}{SHIFTUP}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}') ;Select the Operand 'Order Physician'
    Send('{SHIFTDOWN}{TAB}{SHIFTUP}{DOWN}{DOWN}{ENTER}') ;Select the Operator '='
    Send('{TAB}{TAB}{TAB}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}') ;Open the 'Order Physician' Datasource value dialog
    Send($LastName & ',' & $FirstName) ;Enter resource name
    Send('{ENTER}') ;Search resource
    Sleep(500)

    If PixelGetColor(697, 446, 0xF0F0F0) Then ;If resource is not found, cancel out
        Sleep(200)
        MsgBox(64, 'Error', 'Resource is not found, therefore this pool will not be saved and will cancel out. Click OK to continue.')
        _Excel_RangeWrite($oWorkbook, 'CHFT Pools & RTE Rules', 'Fail', 'I' & $Row)
        _Excel_RangeWrite($oWorkbook, 'CHFT Pools & RTE Rules', 'Resource not found. ' & $Notes, 'J' & $Row)
        Sleep(500)
        WinActivate('Scheduling Help')
        Sleep(500)
        Send('{ENTER}') ;Click OK
        Sleep(500)
        Send('{SHIFTDOWN}{TAB}{SHIFTUP}{ENTER}') ;Click Cancel
        Sleep(500)
        Send('{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{ENTER}') ;Click Close
        Sleep(500)
        WinActivate('Scheduling: DB Flex Rule Tool - Inbox Pool Routing')
        Sleep(500)
        Send('{TAB}{ENTER}') ;Click Yes
        Sleep(500)
        WinActivate('Rules for Pool')
        Sleep(500)
        Send('{TAB}{TAB}{TAB}{ENTER}') ;Click Cancel
        Sleep(500)
        MouseClick('Primary', 1259, 653, 1) ;Click Cancel
        Sleep(500)
    Else
        Send('{TAB}{TAB}{DOWN}') ;Find resource
        Sleep(200)
        If PixelGetColor(725, 383, 0x3399FF) Then ;If there are multiple resources, cancel out
            Sleep(200)
            MsgBox(64, 'Error', 'There are multiple resources, therefore this pool will not be saved and will cancel out. Click OK to continue.')
            _Excel_RangeWrite($oWorkbook, 'CHFT Pools & RTE Rules', 'Redo', 'I' & $Row)
            _Excel_RangeWrite($oWorkbook, 'CHFT Pools & RTE Rules', 'Multiple resources. ' & $Notes, 'J' & $Row)
            Sleep(500)
            WinActivate('Scheduling Help')
            Sleep(500)
            Send('{TAB}{TAB}{ENTER}') ;Click Cancel
            Sleep(500)
            Send('{SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}{ENTER}') ;Click Close
            Sleep(500)
            WinActivate('Scheduling: DB Flex Rule Tool - Inbox Pool Routing')
            Sleep(500)
            Send('{TAB}{ENTER}') ;Click Yes
            Sleep(500)
            WinActivate('Rules for Pool')
            Sleep(500)
            Send('{TAB}{TAB}{TAB}{ENTER}') ;Click Cancel
            Sleep(500)
            MouseClick('Primary', 1259, 653, 1) ;Click Cancel
            Sleep(500)
        Else ;Select the resource
            Sleep(200)
            Send('{ENTER}') ;Select Order Physician
            ;MsgBox(0, '', 'save button clicks now')
            Send('{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}') ;Click Save
            Sleep(500)
            ;If rule already exists, cancel out
            ;If PixelGetColor(802, 433, 0xF0F0F0) Then ;Grey
            If PixelGetColor(554, 383, 0x1D40B7) Then ;Blue
                Sleep(500)
                MsgBox(64, 'Error', 'Rule already exists, therefore this pool will not be saved and will cancel out. Click OK to continue.')
                _Excel_RangeWrite($oWorkbook, 'CHFT Pools & RTE Rules', 'Redo', 'I' & $Row)
                _Excel_RangeWrite($oWorkbook, 'CHFT Pools & RTE Rules', 'Rule already exists. ' & $Notes, 'J' & $Row)
                Sleep(1000)
                WinActivate('Scheduling: DB Flex Rule Tool - Inbox Pool Routing')
                Sleep(500)
                Send('{ENTER}') ;Click OK
                Sleep(500)
                Send('{TAB}{TAB}{ENTER}') ;Click Close
                Sleep(500)
                Send('{TAB}{ENTER}') ;Click Yes
                Sleep(500)
                Send('{TAB}{TAB}{TAB}{ENTER}') ;Click Cancel
                Sleep(500)
                MouseClick('Primary', 1259, 653, 1) ;Click Cancel
            ElseIf PixelGetColor(572, 382, 0xAD0909) Then ;Red
                MsgBox(0, '', 'Syntax error.')
            Else
                MsgBox(0, '', 'Rule can be saved.')
                _Excel_RangeWrite($oWorkbook, 'CHFT Pools & RTE Rules', 'Complete', 'I' & $Row)
                _Excel_RangeWrite($oWorkbook, 'CHFT Pools & RTE Rules', 'Success. ' & $Notes, 'J' & $Row)
                Send('{SHIFTDOWN}{TAB}{SHIFTUP}{ENTER}') ;Click Close
                Sleep(500)
                Send('{SHIFTDOWN}{TAB}{TAB}{SHIFTUP}') ;Navigate to Name field
                Sleep(100)
                Send($RTERuleName) ;Enter RTE Rule Name just created
                Sleep(100)
                Send('{TAB}{ENTER}') ;Click Search
                Sleep(100)
                Send('{TAB}{TAB}{TAB}{TAB}{DOWN}{DOWN}') ;Select RTE Rule just created
                Sleep(100)
                Send('{SHIFTDOWN}{TAB}{TAB}{TAB}{SHIFTUP}{ENTER}') ;Click Add >
                Sleep(500)
                MouseClick('Primary', 1148, 654, 1) ;Click Apply
                Sleep(500)
                MouseClick('Primary', 45, 91, 1) ;Click Commit
                Sleep(500)
                Send('{ENTER}') ;Click OK
                Sleep(1000)
            EndIf
        EndIf
    EndIf
EndFunc   ;==>AddRTERule

Func EndProgram()
    Exit
EndFunc   ;==>EndProgram

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

you want to to stop the script using hotkeys

right?

I ran your script and hotkeyset worked fine while auto it window is minimized.. please could you be more specific???

HotKeySet('e', 'EndProgram')
Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Share this post


Link to post
Share on other sites

Yes that's correct. Forgive me for asking what may be a stupid question, but this specific hotkey to be actioned upon only requires the letter e to be entered on the keyboard with no other key needing to be entered right?

If so, this did not work for me while I ran the entire script copied in previously. It also did not work for the simple script below.

MsgBox(65, "Update", "Hello!")

HotKeySet('e', 'EndProgram')

Func EndProgram()
    Exit
EndFunc   ;==>EndProgram

 

Share this post


Link to post
Share on other sites

This script ends right after the MsgBox is closed so am unsure what you are trying to say here.

In case you mean that the letter e doesn't close the MsgBox then:

  1. MsgBox() is a blocking function and indeed can't be interupted by a HotKeySet(). Workaround is to build your own MsgBox() func with a GUI.
  2. In your case it would have never worked anyways since the HotKey isn't set yet when the MsgBox() is displayed. 

Jos

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks for confirming, I assume there are other blocking functions going in my original script hence the hotkeysets do not work. I've updated my script to ask for my input after each cycle of the automation is completed, from whereby I can abort it as an option. Good enough for now. I'll have a try with a GUI workaround though for future projects, thanks again.

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

  • Similar Content

    • fopetesl
      By fopetesl
      For some reason my personal notes were omitted when posting.
      Still a Newb it seems! So have attached my slightly modified example.
      If I comment out Exit button references script will not Exit even with windows 'X' button icon.
      If I'm losing GUI/Tab focus I cannot see where is the difference with(out) definition.
      GUI_No_Exit.au3
    • dumbledown
      By dumbledown
      Hi,
      I'm new to AutoIt but it looks great.
      I want to get the text from Internet Explorer when hovering the mouse over an image, the statusbargettext function appears to be the way to go.
      When running via a hotkey I return a blank, but the msgbox works. Do you know what I'm doing wrong?
      Thanks
      HotKeySet("!x", "RecordURL") ;wait for ALT-a keystroke While 1 ;loop forever to wait for the keypress Sleep(100) ;no need to kill the CPU WEnd Func RecordURL() #include <MsgBoxConstants.au3> AutoItSetOption("WinTitleMatchMode", 2) Local $sText = StatusbarGetText("Internet Explorer") MsgBox($MB_SYSTEMMODAL, "", "Internet Explorer's status bar says: " & $sText) EndFunc  
       
    • barkeeper
      By barkeeper
      Hi there, not sure if this is the right place, but I'm building a script for using premade answers in chat. It works and outputs the answers (stored in an ini file based on:  answer name = answer it also works with a new line if there is a tag <enter> in the answer text in the ini file. Now the problem is, that after the answer is pasted in the chat (you bring up the interface with ctrl+1) it gives an enter, thus sending the output straight away. I would like to be able to review the answer before sending it. can anyone help me by telling what's wrong in the script, I tried replacing the @crlf in the script with other options, no luck. Thanks in advance! 
      antwoorden.au3
      antwoorden.ini
    • EdyYusof
      By EdyYusof
      Hi,
      I newbie here, my english not so good
      my first post and first script,
      I learn make sofware with autoit, and to want share with other forumer
      just simple autoit script in my first try
      (and not full follow autoit format(yet, in learning and understand))
      Screenshot  http://www.xyplorer.com/xyfc/download/file.php?id=9726
       
      #include <Array.au3> #include <IE.au3> #NoTrayIcon Global $g_sUrlList, $g_sHelpPath, $g_sNavPath, $g_sKeyword, $hWnd, $g_RegexP Global $sChmUrl_L, $g_sClipbord, $sFileN $sFileN = StringRegExpReplace(@ScriptFullPath, "(.+\\)([^\\]+)\.(au3|a3x|exe)", "$2", 1) $sSDir = StringRegExpReplace(@ScriptFullPath, "(.+\\)[^\\]+\.(au3|a3x|exe)", "$1", 1) Global Const $g_sIniPath = $sSDir & '_IncludePart\' & $sFileN & '.ini' _sClipGet() $sTitl = WinGetTitle("[ACTIVE]") $sExt = StringRegExpReplace($sTitl, "(.+\.)(\w{1,6}).*", "$2", 1) Local $sCount, $sDefault $sCext = "~" $i = 0 $pi = 1 If FileExists($g_sIniPath) = 0 Then _IniWriteSection() Sleep(1000) EndIf If FileExists($g_sIniPath) = 1 Then $j = 0 $sCount = IniRead($g_sIniPath, "MainHChmData", "TotalItems", "") Do $j += 1 $sKeyt = " " & IniRead($g_sIniPath, "HChmData" & $j, "FileExt", "") Until $j = 20 Or $sKeyt = " " $j -= 1 If $sCount <> $j Then IniWrite($g_sIniPath, "MainHChmData", "TotalItems", $j) $sCount = $j EndIf $sDefault = IniRead($g_sIniPath, "MainHChmData", "DefaultItems", "") For $i = 1 To $sCount Local $sCext = " " & IniRead($g_sIniPath, "HChmData" & $i, "FileExt", "") $Cext = StringInStr($sCext, $sExt & ";") If $Cext > 1 Then ExitLoop EndIf Next EndIf If $sCext = "~" Or $sDefault = "" Then $sDefault = 1 If $i > $sCount Then $i = $sDefault $g_sHelpPath = IniRead($g_sIniPath, "HChmData" & $i, "HChmPath", "") $hWndT = '[' & IniRead($g_sIniPath, "HChmData" & $i, "hWnd", "") & ']' $g_sNavPath = IniRead($g_sIniPath, "HChmData" & $i, "ChmUrlList", "") $sDef = IniRead($g_sIniPath, "HChmData" & $i, "DefaultPage", "") $g_RegexP = IniRead($g_sIniPath, "HChmData" & $i, "RegexMatches", "") If FileExists($g_sHelpPath) = 0 Or FileExists($g_sNavPath) = 0 Or $hWndT = "[]" Then MsgBox(0, "Missing Or Invalid Path :", "Note: Make Sure Correct Ini Data In : " & @CRLF & $g_sIniPath & @CRLF & @CRLF & "Bellow Information Data :" & @CRLF & @CRLF & "HelpFile.chm : " & @CRLF & $g_sHelpPath & @CRLF & @CRLF & "ChmUrlList : " & @CRLF & $g_sNavPath & @CRLF & @CRLF & "HelpWindowsHwnd : " & @CRLF & $hWndT & @CRLF) EndIf $sChf = "::" & $sDef If $sDef = "" Then $sChf = "" If WinExists($hWndT) = 0 Then Run('"hh.exe" "' & $g_sHelpPath & $sChf & '"') WinWaitActive($hWndT) Sleep(500) EndIf $hWnd = WinGetHandle($hWndT) If IsHWnd($hWnd) = 0 Then MsgBox(0, "Not Valid Help Windows Hwnd", 'Make Sure Correct Help Windows Hwnd' & @CRLF & @CRLF & "HelpWindowsHwnd : " & @CRLF & $hWndT & @CRLF & @CRLF & "Sample Correct Hwnd (Windows Help Title & Class)" & @CRLF & "REGEXPTITLE:AutoIt Help.+; REGEXPCLASS:HH Parent" & @CRLF & "OR" & @CRLF & "TITLE:AutoIt Help (v3.3.14.2); CLASS:HH Parent") EndIf _sGetUrl() Exit Func _IniWriteSection() If FileExists($g_sIniPath) = 0 Then DirCreate(@ScriptDir & "\_IncludePart") EndIf Local $sAutoItInstallDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & ((@OSArch = 'X64') ? "\Wow6432Node" : "") & "\AutoIt v3\AutoIt", "InstallDir") If $sAutoItInstallDir = "" Then $sAutoItInstallDir = "Replace This Note In _IncludePart\" & $sFileN & ".Ini File With Valid Path " Local $aGeneral[3][2] = [[2, ""], ["TotalItems", "1"], ["DefaultItems", "1"]] Local $aSection[7][2] = [[5, ""], ["HChmPath", $sAutoItInstallDir & "\AutoIt.chm"], ["hWnd", "REGEXPTITLE:AutoIt Help.+; REGEXPCLASS:HH Parent"], _ ["ChmUrlList", @ScriptDir & "\_IncludePart\HHChmAutoIt3.au3t"], ["FileExt", "au3;a3x;"], ["DefaultPage", "html/functions/Window Management.htm"], _ ["RegexMatches", ""]] IniWriteSection($g_sIniPath, "MainHChmData", $aGeneral) IniWriteSection($g_sIniPath, "HChmData1", $aSection) EndFunc ;==>_IniWriteSection Func _sClipGet() $ClipBord = ClipGet() ClipPut("") Sleep(10) Send("^c") $g_sClipbord = ClipGet() ClipPut($ClipBord) Local $iLength = StringLen($g_sClipbord) EndFunc ;==>_sClipGet Func _sGetUrl() Local $iLength = StringLen($g_sClipbord) $aData = StringRegExp($g_sClipbord, '[^"()$\s\n]+', $STR_REGEXPARRAYFULLMATCH) If $aData = 1 Then MsgBox(0, "Abort :", "Clipbord : " & $g_sClipbord & @CRLF & @CRLF & "Noting Selected Or Macth With Regex" & @CRLF & @CRLF) Exit EndIf $g_sKeyword = StringLower(StringFormat("%s", $aData[0])) $iLength2 = StringLen($g_sKeyword) If $iLength2 < 3 Then MsgBox(0, "Note :", "Abort : Word Letter Below 4" & @CRLF & "Seleted = " & $g_sKeyword & @CRLF & "Length = " & $iLength2) Exit Else _aFileRead($g_sNavPath) _sChmUrl() EndIf EndFunc ;==>_sGetUrl Func _sChmUrl() $Reg = '(?i)([^\n]+' & $g_sKeyword & '[^\n]*)' _StringRegex($g_sUrlList, $Reg) $aRegx = "[^\n]+/()\.htm;;[^\n]+/()\w\w?\.htm;;[^\n]+#();;[^\n]+#()\w\w?;;[^\n]+/()[^\n/]+\.htm;;[^\n]+#[^\n#/]*()[^\n]*;;[^\n]+/[^\n/]+()[^\n/]*\.htm;;[^\n]+()[^\n/]*\r" If $g_RegexP <> "" Then $aRegx = $g_RegexP & ";;" & $aRegx EndIf $aRegx = StringSplit("(" & StringReplace(StringReplace($aRegx, "()", $g_sKeyword), ";;", "\r)¦(") & "\r)", "¦", 1) _StringRegexUrl($sChmUrl_L, $aRegx) Exit EndFunc ;==>_sChmUrl Func _NavigateCHM($sFilePath, $sSection) If IsHWnd($hWnd) Then Local $oIE = _IEAttach($hWnd, 'Embedded') _IENavigate($oIE, 'mk:@MSITStore:' & $sFilePath & '::/' & $sSection) WinActivate($hWnd) ; ControlFocus($hWnd,"","[ID:201]") ; ControlClick($hWnd,"","[ID:201]","",1,625, 155) ; ControlClick($hWnd,"","[CLASS:Button; TEXT:Hide;]","") EndIf Exit EndFunc ;==>_NavigateCHM Func _StringRegexUrl($sList, $aRegx) Local $sChmUrl For $i = 1 To $aRegx[0] - 1 $sChmUrl = StringRegExp($sList, '(?i)' & $aRegx[$i], 1) If IsArray($sChmUrl) Then $sChmUrl = StringTrimRight($sChmUrl[0], 1) _NavigateCHM($g_sHelpPath, $sChmUrl) EndIf Next Exit EndFunc ;==>_StringRegexUrl Func _StringRegex($sConten, $Reg) $aGetChmUrl = StringRegExp($sConten, $Reg, 3) If $aGetChmUrl = 1 Then MsgBox(0, "Abort :", "Keyword : " & $g_sKeyword & @CRLF & @CRLF & "Noting Macth Any Chm Url By Keyword" & @CRLF & @CRLF) Exit Else $sCChm = UBound($aGetChmUrl) For $i = 0 To $sCChm - 1 $sChmUrl_L &= $aGetChmUrl[$i] & @CRLF Next EndIf Return $sChmUrl_L EndFunc ;==>_StringRegex Func _aFileRead($g_sNavPath) Local $hFileOpen = FileOpen($g_sNavPath, $FO_READ) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.") Return False EndIf $g_sUrlList = FileRead($hFileOpen) FileClose($hFileOpen) Return $g_sUrlList EndFunc ;==>_aFileRead  
       

      LearningTools.7z
      Info in ReadMe.txt
      Just to ask other forumer,
      Correct way or keyword command to autoit click Hide button in AutoIt.chm windows?
          ControlFocus($hWnd,"","[ID:201]")
          ControlClick($hWnd,"","[ID:201]","left",1)
          ControlClick($hWnd,"","[CLASS:Button; TEXT:Hide;]","left",1)
      I try using ControlClick, sendkey or mouseclick, but not work
       
       
       
      LearningTools.7z
    • fosil
      By fosil
      Hi all,

      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