Jump to content

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


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 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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Sachs
      I have a few questions:
      BACKGROUND
      I am using Oracle Application Testing Suite's OpenScript 13 (Eclipse IDE), Oracle Java 6, and AutoIt.
      My goal is to access a given Internet Explorer browser window (`$ieTitle`), send the keystroke of "shift-control-s" for "Save As" functionality to be invoked, so that I can download a (PDF) file to a given location ($fileName).
      The code within the script `DownloadPdfFile.au3` is
      $ieTitle = $CmdLine[1] $ieControl = "AVL_AVView31" $fileName = $CmdLine[2] ControlFocus($ieTitle, "", $ieControl) ControlSend($ieTitle, "", $ieControl, "+^s") ; Save as dialog $winTitle = "Save As" ; wait for Save As window WinWait($winTitle) ; activate Save As window If Not WinActive($winTitle) Then WinActivate($winTitle) ControlFocus($winTitle,"","Edit1") ControlSetText($winTitle,"","Edit1",$fileName) Sleep(2000) ControlClick($winTitle,"","Button3") Exit 0 So I compiled it with SciTE-Lite (32-bit Version 4.4.6 , creating `DownloadPdfFile.exe`, and so within my Java code, I have
      String command = autoItExePath + " " + scriptPath + " \"" + winTitle + "\" " + directoryPath.toFile().toString() + "\\Form9Report" + sdf_ddmmmyyyy.format(new Date()) + ".pdf"; try { Process process = Runtime.getRuntime().exec(command); process.waitFor(); } catch (Exception e) { logger.error("Exception " + e.getMessage(), e); } The output would be like `C:\Program Files (x86)\AutoIt3\AutoIt3.exe C:\...\AutoItScripts\DownloadPdfFile.au3 "https://****.com/****.exe?temp_id=**** - Internet Explorer" C:\...\Report05Apr2022.pdf"` which does run without the $cmdLine successfully. 
      When executed by Java, I see in the taskbar an icon, which I right-click has "[Check] Script Paused" and "Exit".
      Questions:
      (1) How do I unpause the script?
      (2) How do I avoid having the script paused?
      Any help is appreciated.
    • By asiawatcher
      hi below i got one script i made which runs audacity starts a recording and ends it at specific times
       
      when i run the script even if it isn't the time to start audacity and sits idle on taskbar the pc fan gets very loud, when i close the script it comes back to normal 
       
      why this happens ? anything wrong with my code ?? cheers
      #include <INet.au3> #include <Array.au3> #include <WinAPIFiles.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <string.au3> #include <FTPEx.au3> #include <ClipBoard.au3> #include <date.au3> #include <ProgressConstants.au3> #include <IE.au3> #Include <Constants.au3> #Include <INET.au3> #include <SendMessage.au3> #include <File.au3> #include <String.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <Misc.au3> #include <FileConstants.au3> #include <WinAPI.au3> while 1 if @HOUR = '11' And @MIN = '00' Then  Run("C:\Program Files (x86)\Audacity\audacity.exe", "", @SW_MAXIMIZE) SLEEP(2000) if ProcessExists("audacity.exe") Then winactivate("Audacity") EndIf      Send("r") ;;KREVATI Sleep(1000 * 60) endif if @HOUR = '23' And @MIN = '00' Then  if ProcessExists("audacity.exe") Then winactivate("Audacity") EndIf Send("s") Sleep(1000 * 60) EndIf wend  
    • By v120
      Original posted by CoePSX
       
       
       
       
      Drawing_Script.au3
    • By ademon
      Hi. I can open the editor with out problems but I can not compile because it is placed on another partition diferent from C.
      Can you provide an update of this bug?


    • By lenclstr746
      Hi guys,
      Some functions of my script are running slowly. Very slow. What is the reason?
      My Code:
      <snip>
×
×
  • Create New...