Sign in to follow this  
Followers 0
EdyYusof

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

3 posts in this topic

#1 ·  Posted (edited)

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



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  
Followers 0

  • Similar Content

    • 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
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning everyone
      I worked a bit on a little project of mine, and I managed to do what I was trying to do, or, automate a quiz in AutoIt.
      Now, everything works fine but, in order to achieve what I'm trying to achive, I'd like to make this script run faster.
      I'll attach a portion of the code in order to let you understand what my script does.
      $objIE_h1 = _IETagNameGetCollection($objIE, "h1") ; Take the text of the answer If @error Then ConsoleWrite("Errore durante la lettura degli h1 nella pagina. - Errore: " & @error & @CRLF) Else For $objElement In $objIE_h1 $strInnerText = $objElement.innerText Next Select Case StringInStr($strInnerText, "QUESTION") ; Here is the question ; PS4 PRO $objSpans = _IETagNameGetCollection($objIE, "span") ; Answers are stored here For $objElement In $objSpans If $i >= 4 Then $strAnswer = $objElement.innerText ; Take the text of the answer n° 0, 1, 2, 3 If StringInStr($strAnswer, "CORRECT ANSWER") Then ; If I match the correct answer, then, I have to click on the input with answer id = answer_i $j = $i - 4 $objInput = _IEGetObjById($objIE, "answer_" & $j) If @error Then ConsoleWrite("Errore durante la lettura della risposta #" & $i & " - Errore: " & @error & @CRLF) Else _IEAction($objInput, "click") If @error Then ConsoleWrite("Errore durante il click sull'elemento. - Errore: " & @error) Else ConsoleWrite($j & ") Risposta: " & $strAnswer & @CRLF) ExitLoop EndIf EndIf EndIf $i+=1 Else $i+=1 EndIf Next $i = 0 $j = 0 This is what my script does.
      Questions are 20, in which I have 15 multiple choice question, 2 images ( on which I use _IEImgClick() ), and 3 text inputs ( a simple send with the text I have to enter ).
      How can I make all of these, faster?
      If I reach this goal, I've probably done one of my best goals in life, and I'd like to share my happiness with you, giving a huge donation to this fantastic community!
      Thanks for your help
    • au3leecher
      By au3leecher
      Hellow everybody,
      I tryed to manipulate a game called "Assault Cube" which is a easy beginning in coding. I run the code but the wished value doesn't change, i don't understand why.
      The Pointers are fine, I checked that the pointers don't change every time while restart the game.
      My Code:
      <snip>
      _____________________________________________________________________________________________________________________________________________________________________________________________
      Checklist:
      The Offsets are 18C & 4
      In Cheat Engine: ("ac_client.exe"+0010F418) <- Pointer
      4 Bytes = 'dword'
       
    • nacerbaaziz
      By nacerbaaziz
      Hello
      How are you
      I have a question, please.
      I've created a window and i need
      when i run the script if it detect an other copy from the same script was runing
       the script close the first copy Automatically and run a new copy
      I want an example to understand it
    • Nareshm
      By Nareshm
      Please Somebody Help me i am trying to create new script but, i don't know how to create it.

      I am Creating script like this :
      ; My script here [First Script]
      Check the internet connection, if internet connected then
      ; My Script here [Second Script]
      If internet not connected, wait for connect, after connected run my second script
      If Control id/windows/title matched do nothing and end/exit autoit script
      If Control id/windows/title not matched repeat my first and second script again until control id/windows/tittle not matched

      match with :
      >>>> Window <<<<
      Title:    PS :: Version - 2.8.0.0  - [PS Bill]
      Class:    WindowsForm734a
      Position:    -8, -8
      Size:    1382, 744
      Style:    0x17CD0000
      ExStyle:    0x00050100
      Handle:    0x0000000000130572
      >>>> Control <<<<
      Class:    WindowsForm734a
      Instance:    15
      ClassnameNN:    WindowsForm34a15
      Name:    BillPrint
      Advanced (Class):    [NAME:BillPrint]
      ID:    7875
      Text:    
      Position:    39, 310
      Size:    1221, 306
      ControlClick Coords:    745, 20
      Style:    0x56010000
      ExStyle:    0x00000000
      Handle:    0x00000000000C0468