Jump to content

Learning Tools.au3, Open AutoIt.chm Url By Seleted Keyword From Text editor


EdyYusof
 Share

Recommended Posts

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

 

 

file.php?id=9726

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

Edited by EdyYusof
miss info
Link to comment
Share on other sites

13 minutes ago, JohnOne said:

Are you aware that if you click on function in scite4autoit and press F1, the help file is opened at that function.

Thanks for info,

i not fimiliar yet with scite4autoit, in learning,  temporary i using editplus

Link to comment
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
 Share

×
×
  • Create New...