Jump to content
Sign in to follow this  
EdyYusof

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

Recommended Posts

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

 

 

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

Share this post


Link to post
Share on other sites
EdyYusof
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

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
Sign in to follow this  

  • Similar Content

    • BogdanNicolescu
      By BogdanNicolescu
      While 1 / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / WEnd OR:

       
      HotKeySet("{ESC}", "Terminate") While 1 MouseClick("Right",674,422) MouseClick("Left",673,447) Sleep(2000) / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / MouseClick("Left",675,339) SLeep(3000) WEnd Func Terminate()     Exit 0 EndFunc  
      Sorry if i should't let this here to be found by newbies like me -.-'
    • nacerbaaziz
      By nacerbaaziz
      Hello all
      I found this function in the Internet
      It is to play audio files from  the compiled script
      I did not understand just one thing on this function
      func play($name, $wait = 0) local Const $SND_RESOURCE = 0x00040004 local Const $SND_ASYNC = 1 ; Play the file - the script will pause as it sounds if $wait = 0 then DllCall("winmm.dll", "int", "PlaySound", "str", $name, "hwnd", 0, "int", BitOR($SND_RESOURCE, $SND_ASYNC)) else DllCall("winmm.dll", "int", "PlaySound", "str", $name, "hwnd", 0, "int", $SND_RESOURCE) endIf return 1 endFunc What I did not understand was this variable
      local Const $SND_RESOURCE = 0x00040004 I know that this variable is contains the resource name
      But what if I want to change the name of the resource what i'll do?
      can i do that?
      Thanks in advance
       
    • krasnoshtan
      By krasnoshtan
      Hello forum users!
      At some point I had a need to restart my script. Is it possible to do this with autoit or do I need to connect additional scripts like .cmd or .bat?
      For example: i have only script.au3 and it's running. Wich code shoud i use to exit from the script and start it again?
    • tintin92
      By tintin92
      Hello,

      How can I automatically download a list of zip files, like the ones in the quote, using a AutoIt script?
      Is it possible with AutoIt script?
       
    • Eggsplorer
      By Eggsplorer
      Hi,
      Ich hab ein Script für Windows Updates, dass nach dem OOBE aufgerufen werden soll. Run/RunOnce ist daher nicht möglich.
      Stattdessen möchte ich das Script in den Autostart schreiben lasse. Wenn die OOBE beendet wird und der Administrator angemeldet wird, soll das Update-Script einmalig aufgerufen werden und sich anschl. selbst löschen.
      Lang rede, kurzer Sinn:
      Wie kann ich folgendes Script in den Autostart schreiben?
      RunWait(@ComSpec & " /c " & "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File C:\UA\Scripts\win-updates.ps1 -MaxUpdatesPerCycle 100 -RestartRequired 1", "") Ich würde ungern eine BAT oder EXE reinkopieren, da ich es unsauber finde. Die müsste ja auch zusätzlich irgendwo liegen.
      Danke
      Eggsplorer
×