1. Tải bản cài đặt AutoIT mới nhất

    Chào Khách. Nếu bạn mới tham gia và chưa cài đặt AutoIT.
    Vui lòng vào topic trên để tải bản AutoIT mới nhất nhé
    Dismiss Notice
  2. Quy định và nội quy

    Chào Khách. Vui lòng đọc kỹ nội quy và quy định của diễn đàn
    Để tránh bị ban một cách đáng tiếc nhé!
    Dismiss Notice
  3. Hướng dẫn chèn mã AutoIT trong diễn đàn

    Chào Khách. Vui lòng xem qua bài viết này
    Để biết cách chèn mã AutoIT trong diễn đàn bạn nhé :)
    Dismiss Notice

AutoHotKey Chia sẻ một số library, công cụ và code hữu ích

Thảo luận trong 'AutoHotkey' bắt đầu bởi Milli Master, 26/8/18.

  1. Milli Master

    Milli Master ??
    • 93/113

    Tham gia ngày:
    9/7/16
    Bài viết:
    106
    Đã được thích:
    2,303
    Nơi ở:
    Thủ Đức, TP Hồ Chí Minh
    Dưới đây là một số library, công cụ và code hữa ích mà mình sưu tập được và thường sử dụng. Bạn nào có cái nào hay hay thì cũng đăng ở dưới nha.

    Class/Function
    [Function] CBAutoComplete

    Chức năng: tự động điền vào combobox nội dung đã có.
    [​IMG]

    [Class] GuiControlTips
    Chức năng: tạo tool tip cho control.
    [​IMG]

    [Class] CtlColor
    Có chức năng thay đổi màu sắc cho các gui control.
    [​IMG]

    [Class] Class_ImageButton
    Có chức năng tạo button với đủ thể loại, kiểu dáng.
    [​IMG]
    Code: https://autohotkey.com/boards/viewtopic.php?f=6&t=1103

    Ví dụ:
    Mã (Autohotkey):

    ; GLOBAL SETTINGS ===============================================================================================================

    #NoEnv
    #SingleInstance Force
    SetBatchLines -1

    global version := 0.03

    global IBAnimation := True                                                     ; enable / disable (hover-fade) animation
    global IBNames     := ["Startpage", "Menu 1", "Menu 2", "Menu 3", "Menu 4"]
    global IBClrStyles := [ [0, 0x80FFFFFF, , 0xD3000000, 0, , 0x80FFFFFF, 1]      ; normal
                          , [0, 0x80E6E6E6, , 0xD3000000, 0, , 0x80E6E6E6, 1]      ; hover
                          , [0, 0x80CCCCCC, , 0xD3000000, 0, , 0x80CCCCCC, 1]      ; pressed
                          , [0, 0x80F3F3F3, , 0x000078D7, 0, , 0x80F3F3F3, 1] ]    ; disabled (defaulted)

    ; GUI ===========================================================================================================================

    Gui, Margin, 0, 0
    Gui, Color, FFFFFF
    Gui, Font, s12, Segoe UI

    Gui, Add, Button, xm ym  w150 h30 0x100 hWndhBTN01 gMN_SELECT vMN_TAB_1, % "  " IBNames[1]
    ImageButton.Create(hBTN01, IBClrStyles*)

    Gui, Add, Button, xm y+0 w150 h30 0x100 hWndhBTN02 gMN_SELECT vMN_TAB_2, % "  " IBNames[2]
    ImageButton.Create(hBTN02, IBClrStyles*)

    Gui, Add, Button, xm y+0 w150 h30 0x100 hWndhBTN03 gMN_SELECT vMN_TAB_3, % "  " IBNames[3]
    ImageButton.Create(hBTN03, IBClrStyles*)

    Gui, Add, Button, xm y+0 w150 h30 0x100 hWndhBTN04 gMN_SELECT vMN_TAB_4, % "  " IBNames[4]
    ImageButton.Create(hBTN04, IBClrStyles*)

    Gui, Add, Button, xm y+0 w150 h30 0x100 hWndhBTN05 gMN_SELECT vMN_TAB_5, % "  " IBNames[5]
    ImageButton.Create(hBTN05, IBClrStyles*)

    Gui, Add, Tab2, xm ym w0 h0 -Wrap Choose1 AltSubmit vMyMenuTab, % "1|2|3|4|5"

    Gui, Tab, 1
    Gui, Font, s14 c474747, Segoe UI
    Gui, Add, Text, xm+150 ym w250 h250, % "  " IBNames[1]

    Gui, Tab, 2
    Gui, Font, s14 c474747, Segoe UI
    Gui, Add, Text, xm+150 ym w250 30, % "  " IBNames[2]
    Gui, Add, Button, xm+150 y+5 w80 h30, % "Test"

    Gui, Tab, 3
    Gui, Font, s14 c474747, Segoe UI
    Gui, Add, Text, xm+150 ym w250 h250, % "  " IBNames[3]

    Gui, Tab, 4
    Gui, Font, s14 c474747, Segoe UI
    Gui, Add, Text, xm+150 ym w250 h250, % "  " IBNames[4]

    Gui, Tab, 5
    Gui, Font, s14 c474747, Segoe UI
    Gui, Add, Text, xm+150 ym w250 h250, % "  " IBNames[5]

    SystemParametersInfo(IBAnimation)
    Gui, Show, AutoSize, % "AHK-Concept: Win10 Settings"
    return

    ; SCRIPT ========================================================================================================================

    MN_SELECT:
       GuiControl, Choose, MyMenuTab, % k := SubStr(A_GuiControl, 8)

        loop % IBNames.MaxIndex() {
            if (k = A_Index)
                GuiControl, Disable, MN_TAB_%A_Index%
            else
                GuiControl, Enable, MN_TAB_%A_Index%
        }
    return

    ; FUNCTIONS =====================================================================================================================

    CtlColorBtns()                                    ; https://github.com/jNizM/AHK_Scripts/blob/master/src/gui/GUI_CtlColorBtns.ahk
    {
        static init := OnMessage(0x0135, "CtlColorBtns")
        return DllCall("gdi32\CreateSolidBrush", "uint", 0xFFFFFF, "uptr")
    }

    SystemParametersInfo(toggle := 0)                               ; https://msdn.microsoft.com/en-us/library/ms724947(v=vs.85).aspx
    {
        static SPI_SETCLIENTAREAANIMATION := 0x1043
        if !(DllCall("user32\SystemParametersInfo", "uint", SPI_SETCLIENTAREAANIMATION, "uint", 0, "int", toggle, "uint", 0))
            throw Exception("SystemParametersInfo failed: " A_LastError, -1)
        return true
    }

    ; INCLUDES ======================================================================================================================
    #Include Class_ImageButton.ahk                                  ; https://github.com/AHK-just-me/Class_ImageButton

    ; EXIT ==========================================================================================================================

    GuiClose:
    GuiEscape:
    ExitApp

    ; ===============================================================================================================================
       

    [Function] TaskBar_SetAttr
    Làm mờ, trong suốt và thay đổi màu sắc cho thanh taskbar
    [​IMG]
    [​IMG]
    [​IMG]
    Code: https://github.com/jNizM/AHK_TaskBar_SetAttr
    Ví dụ:
    Mã (AutoIt):

    #NoEnv
    #Persistent
    #SingleInstance Force
    SetBatchLines -1

    SetTimer, UPDATE_TASKBAR, 200
    return

    UPDATE_TASKBAR:
        TaskBar_SetAttr(3)
    return

    #Include TaskBar_SetAttr.ahk

    [Function] Gdip_ImageSearch

    Chức năng: Tìm kiếm hình ảnh trên cửa sổ bị che khuất.
    Code: https://github.com/MasterFocus/Auto...nctions/Gdip_ImageSearch/Gdip_ImageSearch.ahk

    Ví dụ:
    Mã (Autohotkey):

    #NoEnv
    SetBatchLines, -1
    Process, Priority,, High
    settitlematchmode 2

    OnExit, EXIT_LABEL

    If !pToken := Gdip_Startup()
    {
       MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
       ExitApp
    }

    ; imagefile that you  want to find
    needle=%a_scriptdir%\needle.png  ;you need testimage needle.png

    ; title of window you want to search into
    WinTitle:="PSPad"  ;just example
    hwnd:=WinExist(WinTitle) ; get the handle to the window
    ; msgbox %hwnd%  ;for debugging to see if there is a handle
    return




    f4::
    bmpHaystack := Gdip_BitmapFromHWND(hwnd)  ;you need the handle of the window to search in
    ;Gdip_SaveBitmapToFile(bmpHaystack,"test.png") ; you can test to see what has been captured for debugging
    bmpNeedle := Gdip_CreateBitmapFromFile(needle)
    RET := Gdip_ImageSearch(bmpHaystack,bmpNeedle,LIST)
    Gdip_DisposeImage(bmpHaystack)
    Gdip_DisposeImage(bmpNeedle)
    Gdip_Shutdown(pToken)


    pos:=strsplit(list,",")
    xp:=pos.1+5 ,yp:=pos.2+5
    tooltip  % xp "   "  yp
    ControlClick, x%xp% y%yp% , ahk_id %hwnd%,,,, Pos
    return


    found:
    msgbox clicked on image
    return

    esc::
    EXIT_LABEL:
    Gdip_Shutdown(pToken)
    EXITAPP

    #Include Gdip_ImageSearch.ahk ;https://github.com/MasterFocus/AutoHotkey/blob/master/Functions/Gdip_ImageSearch/Gdip_ImageSearch.ahk
    #Include Gdip.ahk ;https://github.com/tariqporter/Gdip/blob/master/Gdip.ahk

     

    [Function] FindText
    Đây là một chức năng bá đạo cho mấy bạn auto game bằng cách tìm hình ảnh. Nó cũng giống như ImageSearch nhưng hay hơn, có thể tìm được hình cho dù nó bị đổi màu, v.v..
    [Function] CPULoad + [Function] XGraph
    Chức năng: đọc tỉ lệ phần trăm sử dụng của CPU và khi kết hợp với function XGraph sẽ như hình bên dưới.

    [​IMG]

    Thành viên đóng góp:
    [Function]
    WinHttpRequest
    ------------------------------------------------------------------------------------------------------------
    Mẫu thiết kế GUI

    [GUI] Microsoft Office 2016 Inspired GUI Interface

    [​IMG]
    [​IMG]

    Code:
    Mã (Autohotkey):

    ; Globals ======================================================================
    #SingleInstance, Force ; Allow only one running instance of the script
    #Persistent ; Keep the script permanently running until terminated
    #NoEnv ; Avoid checking empty variables for environment variables
    #Warn ; Enable warnings to assist with detecting common errors
    ;#NoTrayIcon ; Disable the tray icon of the script
    SendMode, Input ; Method for sending keystrokes and mouse clicks
    SetWorkingDir, %A_ScriptDir% ; Set the working directory of the script
    SetBatchLines, -1 ; Run the script at maximum speed
    SetWinDelay, -1 ; The delay to occur after modifying a window
    SetControlDelay, -1 ; The delay to occur after modifying a control

    Application := {} ; Create Application Object
    Application.Name := "New AutoHotkey Script"
    Application.Version := "0.1"

    Window := {} ; Create Window Object
    Window.Width := 600
    Window.Height := 400
    Window.Title := Application.Name
    ; ==============================================================================

    ; Script =======================================================================
    Menu, FileMenu, Add, File (Item 1), MenuHandler
    Menu, FileMenu, Add, File (Item 2), MenuHandler
    Menu, FileMenu, Add, File (Item 3), MenuHandler
    Menu, FileMenu, Add ; Separator
    Menu, FileMenu, Add, Exit, ExitSub
    Menu, EditMenu, Add, Edit (Item 1), MenuHandler
    Menu, EditMenu, Add, Edit (Item 2), MenuHandler
    Menu, EditMenu, Add, Edit (Item 3), MenuHandler
    Menu, ViewMenu, Add, View (Item 1), MenuHandler
    Menu, ViewMenu, Add, View (Item 2), MenuHandler
    Menu, ViewMenu, Add, View (Item 3), MenuHandler
    Menu, ToolsMenu, Add, Tools (Item 1), MenuHandler
    Menu, ToolsMenu, Add, Tools (Item 2), MenuHandler
    Menu, ToolsMenu, Add, Tools (Item 3), MenuHandler
    Menu, HelpMenu, Add, Help (Item 1), MenuHandler
    Menu, HelpMenu, Add, Help (Item 2), MenuHandler
    Menu, HelpMenu, Add, Help (Item 3), MenuHandler

    Gui, +LastFound -Resize -Caption -Border +HWNDhGui1
    Gui, Color, FFFFFF
    Gui, Margin, 10, 10

    ; Window Border
    Gui, Add, Text, % " x" 0 " y" 0 " w" 1 " h" Window.Height " +0x4E +HWNDhBorderLeft"
    Gui, Add, Text, % " x" Window.Width-1 " y" 0 " w" 1 " h" Window.Height " +0x4E +HWNDhBorderRight"
    Gui, Add, Text, % "x" 1 " y" Window.Height-1 " w" Window.Width-2 " h" 1 " +0x4E +HWNDhBorderBottom"
    DllCall("SendMessage", "Ptr", hBorderLeft, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0072C6", 1, 1))
    DllCall("SendMessage", "Ptr", hBorderRight, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0072C6", 1, 1))
    DllCall("SendMessage", "Ptr", hBorderBottom, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0072C6", 1, 1))

    ; Window Header
    Gui, Add, Text, % "x" 1 " y" 0 " w" Window.Width-2 " h" 67 " +0x4E +HWNDhTitleHeader"
    DllCall("SendMessage", "Ptr", hTitleHeader, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0173C7", 1, 1))

    ; Window Title
    Gui, Font, s9 cFFFFFF, Segoe UI ; Set font options
    Gui, Add, Text, % " x" 140 " y" 12 " w" Window.Width-280 " +BackgroundTrans +0x101 +HWNDhTitle", % Window.Title
    Gui, Font ; Reset font options

    ; Window StatusBar
    Gui, Add, Picture, % " x" 1 " y" Window.Height-23 " w" Window.Width-2 " h" 22 " +0x4E +HWNDhStatusBar"
    StatusBar := "#@@@@@@@@@@@@@@@@@@@@@"
    StringReplace, StatusBar, StatusBar, #, BFBFBF|, All
    StringReplace, StatusBar, StatusBar, @, F1F1F1|, All
    StringTrimRight, StatusBar, StatusBar, 1
    DllCall("SendMessage", "Ptr", hStatusBar, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(StatusBar, 1, 22))
    Gui, Font, s8 c515050, Segoe UI ; Set font options
    Gui, Add, Text, % " x" 8 " y" Window.Height-19 " w" Window.Width-16 " +HWNDhStatusBarText +BackgroundTrans", % "Sample Text"
    Gui, Font ; Reset font options

    ; Window Minimize Button
    Gui, Add, Picture, % " x" Window.Width-139 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonMinimizeN Hidden0"
    Gui, Add, Picture, % " x" Window.Width-139 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonMinimizeH Hidden1"
    Gui, Add, Picture, % " x" Window.Width-139 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonMinimizeP Hidden1"

    ButtonMinimize := "####################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################@@@@@@@@@@####################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################"

    StringReplace, ButtonMinimizeN, ButtonMinimize, #, 0173C7|, All
    StringReplace, ButtonMinimizeN, ButtonMinimizeN, @, FFFFFF|, All
    StringTrimRight, ButtonMinimizeN, ButtonMinimizeN, 1

    StringReplace, ButtonMinimizeH, ButtonMinimize, #, 2A8AD4|, All
    StringReplace, ButtonMinimizeH, ButtonMinimizeH, @, FFFFFF|, All
    StringTrimRight, ButtonMinimizeH, ButtonMinimizeH, 1

    StringReplace, ButtonMinimizeP, ButtonMinimize, #, 015C9F|, All
    StringReplace, ButtonMinimizeP, ButtonMinimizeP, @, FFFFFF|, All
    StringTrimRight, ButtonMinimizeP, ButtonMinimizeP, 1

    DllCall("SendMessage", "Ptr", hButtonMinimizeN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonMinimizeN, 46, 31))
    DllCall("SendMessage", "Ptr", hButtonMinimizeH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonMinimizeH, 46, 31))
    DllCall("SendMessage", "Ptr", hButtonMinimizeP, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonMinimizeP, 46, 31))

    ; Window Maximize Button
    Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonMaximizeN Hidden0"
    Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonMaximizeH Hidden1"
    Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonMaximizeP Hidden1"

    ButtonMaximize := "##############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################@@@@@@@@@@####################################@########@####################################@########@####################################@########@####################################@########@####################################@########@####################################@########@####################################@########@####################################@########@####################################@@@@@@@@@@############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################"

    StringReplace, ButtonMaximizeN, ButtonMaximize, #, 0173C7|, All
    StringReplace, ButtonMaximizeN, ButtonMaximizeN, @, FFFFFF|, All
    StringTrimRight, ButtonMaximizeN, ButtonMaximizeN, 1

    StringReplace, ButtonMaximizeH, ButtonMaximize, #, 2A8AD4|, All
    StringReplace, ButtonMaximizeH, ButtonMaximizeH, @, FFFFFF|, All
    StringTrimRight, ButtonMaximizeH, ButtonMaximizeH, 1

    StringReplace, ButtonMaximizeP, ButtonMaximize, #, 015C9F|, All
    StringReplace, ButtonMaximizeP, ButtonMaximizeP, @, FFFFFF|, All
    StringTrimRight, ButtonMaximizeP, ButtonMaximizeP, 1

    DllCall("SendMessage", "Ptr", hButtonMaximizeN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonMaximizeN, 46, 31))
    DllCall("SendMessage", "Ptr", hButtonMaximizeH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonMaximizeH, 46, 31))
    DllCall("SendMessage", "Ptr", hButtonMaximizeP, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonMaximizeP, 46, 31))

    ; Window Restore Button
    Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonRestoreN Hidden1"
    Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonRestoreH Hidden1"
    Gui, Add, Picture, % " x" Window.Width-93 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonRestoreP Hidden1"

    ButtonRestore := "################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################@@@@@@@@######################################@######@####################################@@@@@@@@#@####################################@######@#@####################################@######@#@####################################@######@#@####################################@######@#@####################################@######@@@####################################@######@######################################@@@@@@@@##############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################"

    StringReplace, ButtonRestoreN, ButtonRestore, #, 0173C7|, All
    StringReplace, ButtonRestoreN, ButtonRestoreN, @, FFFFFF|, All
    StringTrimRight, ButtonRestoreN, ButtonRestoreN, 1

    StringReplace, ButtonRestoreH, ButtonRestore, #, 2A8AD4|, All
    StringReplace, ButtonRestoreH, ButtonRestoreH, @, FFFFFF|, All
    StringTrimRight, ButtonRestoreH, ButtonRestoreH, 1

    StringReplace, ButtonRestoreP, ButtonRestore, #, 015C9F|, All
    StringReplace, ButtonRestoreP, ButtonRestoreP, @, FFFFFF|, All
    StringTrimRight, ButtonRestoreP, ButtonRestoreP, 1

    DllCall("SendMessage", "Ptr", hButtonRestoreN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonRestoreN, 46, 31))
    DllCall("SendMessage", "Ptr", hButtonRestoreH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonRestoreH, 46, 31))
    DllCall("SendMessage", "Ptr", hButtonRestoreP, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonRestoreP, 46, 31))

    ; Window Close Button
    Gui, Add, Picture, % " x" Window.Width-47 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonCloseN Hidden0"
    Gui, Add, Picture, % " x" Window.Width-47 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonCloseH Hidden1"
    Gui, Add, Picture, % " x" Window.Width-47 " y" 1 " w" 46 " h" 31 " +0x4E +HWNDhButtonCloseP Hidden1"

    ButtonClose := "##############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################-$######$-####################################$-$####$-$#####################################$-$##$-$#######################################$-$$-$#########################################$--$##########################################$--$#########################################$-$$-$#######################################$-$##$-$#####################################$-$####$-$####################################-$######$-############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################"

    StringReplace, ButtonCloseN, ButtonClose, #, 0173C7|, All
    StringReplace, ButtonCloseN, ButtonCloseN, $, 4096D5|, All
    StringReplace, ButtonCloseN, ButtonCloseN, -, FFFFFF|, All
    StringTrimRight, ButtonCloseN, ButtonCloseN, 1

    StringReplace, ButtonCloseH, ButtonClose, #, E81123|, All
    StringReplace, ButtonCloseH, ButtonCloseH, $, EE4C59|, All
    StringReplace, ButtonCloseH, ButtonCloseH, -, FFFFFF|, All
    StringTrimRight, ButtonCloseH, ButtonCloseH, 1

    StringReplace, ButtonCloseP, ButtonClose, #, F1707A|, All
    StringReplace, ButtonCloseP, ButtonCloseP, $, F4939B|, All
    StringReplace, ButtonCloseP, ButtonCloseP, -, FFFFFF|, All
    StringTrimRight, ButtonCloseP, ButtonCloseP, 1

    DllCall("SendMessage", "Ptr", hButtonCloseN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonCloseN, 46, 31))
    DllCall("SendMessage", "Ptr", hButtonCloseH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonCloseH, 46, 31))
    DllCall("SendMessage", "Ptr", hButtonCloseP, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB(ButtonCloseP, 46, 31))

    ; Window Menu Button
    Gui, Font, s9 cFFFFFF, Segoe UI ; Set font options
    Gui, Add, Picture, % " x" 2 " y" 36 " w" 60 " h" 24 " +0x4E +HWNDhButtonMenuFileN Hidden0"
    Gui, Add, Picture, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +0x4E +HWNDhButtonMenuFileH Hidden1"
    Gui, Add, Text, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +HWNDhButtonMenuFileText +BackgroundTrans +0x201", % "File"
    DllCall("SendMessage", "Ptr", hButtonMenuFileN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0173C7", 1, 1))
    DllCall("SendMessage", "Ptr", hButtonMenuFileH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("2A8AD4", 1, 1))

    Gui, Add, Picture, % " x+" 2 " yp" 0 " w" 60 " h" 24 " +0x4E +HWNDhButtonMenuEditN Hidden0"
    Gui, Add, Picture, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +0x4E +HWNDhButtonMenuEditH Hidden1"
    Gui, Add, Text, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +HWNDhButtonMenuEditText +BackgroundTrans +0x201", % "Edit"
    DllCall("SendMessage", "Ptr", hButtonMenuEditN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0173C7", 1, 1))
    DllCall("SendMessage", "Ptr", hButtonMenuEditH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("2A8AD4", 1, 1))

    Gui, Add, Picture, % " x+" 2 " yp" 0 " w" 60 " h" 24 " +0x4E +HWNDhButtonMenuViewN Hidden0"
    Gui, Add, Picture, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +0x4E +HWNDhButtonMenuViewH Hidden1"
    Gui, Add, Text, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +HWNDhButtonMenuViewText +BackgroundTrans +0x201", % "View"
    DllCall("SendMessage", "Ptr", hButtonMenuViewN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0173C7", 1, 1))
    DllCall("SendMessage", "Ptr", hButtonMenuViewH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("2A8AD4", 1, 1))

    Gui, Add, Picture, % " x+" 2 " yp" 0 " w" 60 " h" 24 " +0x4E +HWNDhButtonMenuToolsN Hidden0"
    Gui, Add, Picture, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +0x4E +HWNDhButtonMenuToolsH Hidden1"
    Gui, Add, Text, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +HWNDhButtonMenuToolsText +BackgroundTrans +0x201", % "Tools"
    DllCall("SendMessage", "Ptr", hButtonMenuToolsN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0173C7", 1, 1))
    DllCall("SendMessage", "Ptr", hButtonMenuToolsH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("2A8AD4", 1, 1))

    Gui, Add, Picture, % " x+" 2 " yp" 0 " w" 60 " h" 24 " +0x4E +HWNDhButtonMenuHelpN Hidden0"
    Gui, Add, Picture, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +0x4E +HWNDhButtonMenuHelpH Hidden1"
    Gui, Add, Text, % " xp" 0 " yp" 0 " wp" 0 " hp" 0 " +HWNDhButtonMenuHelpText +BackgroundTrans +0x201", % "Help"
    DllCall("SendMessage", "Ptr", hButtonMenuHelpN, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("0173C7", 1, 1))
    DllCall("SendMessage", "Ptr", hButtonMenuHelpH, "UInt", 0x172, "Ptr", 0, "Ptr", CreateDIB("2A8AD4", 1, 1))
    Gui, Font ; Reset font options

    Gui, Show, % " w" Window.Width " h" Window.Height, % Window.Title

    OnMessage(0x200, "WM_MOUSEMOVE")
    OnMessage(0x201, "WM_LBUTTONDOWN")
    OnMessage(0x202, "WM_LBUTTONUP")
    OnMessage(0x2A3, "WM_MOUSELEAVE")

    VarSetCapacity(TME, 16, 0), NumPut(16, TME, 0), NumPut(2, TME, 4), NumPut(hGui1, TME, 8)
    return ; End automatic execution
    ; ==============================================================================

    ; Labels =======================================================================
    GuiSize:
        If (ErrorLevel = 1) {
            return ; The window has been minimized.  No action needed.
        }

        GuiControl, MoveDraw, % hTitleHeader, % " w" A_GuiWidth-2
        GuiControl, MoveDraw, % hBorderLeft, % " h" A_GuiHeight
        GuiControl, MoveDraw, % hBorderRight, % " x"  A_GuiWidth-1 " h" A_GuiHeight
        GuiControl, MoveDraw, % hBorderBottom, % " y" A_GuiHeight-1 " w" A_GuiWidth-2
        GuiControl, MoveDraw, % hTitle, % " w" A_GuiWidth-280
        GuiControl, MoveDraw, % hStatusBar, % " w" A_GuiWidth-2 " y" A_GuiHeight-23
        GuiControl, MoveDraw, % hStatusBarText, % " w" A_GuiWidth-16 " y" A_GuiHeight-19
        GuiControl, MoveDraw, % hButtonMinimizeN, % " x" A_GuiWidth-139
        GuiControl, MoveDraw, % hButtonMinimizeH, % " x" A_GuiWidth-139
        GuiControl, MoveDraw, % hButtonMinimizeP, % " x" A_GuiWidth-139
        GuiControl, MoveDraw, % hButtonMaximizeN, % " x" A_GuiWidth-93
        GuiControl, MoveDraw, % hButtonMaximizeH, % " x" A_GuiWidth-93
        GuiControl, MoveDraw, % hButtonMaximizeP, % " x" A_GuiWidth-93
        GuiControl, MoveDraw, % hButtonRestoreN, % " x" A_GuiWidth-93
        GuiControl, MoveDraw, % hButtonRestoreH, % " x" A_GuiWidth-93
        GuiControl, MoveDraw, % hButtonRestoreP, % " x" A_GuiWidth-93
        GuiControl, MoveDraw, % hButtonCloseN, % " x" A_GuiWidth-47
        GuiControl, MoveDraw, % hButtonCloseH, % " x" A_GuiWidth-47
        GuiControl, MoveDraw, % hButtonCloseP, % " x" A_GuiWidth-47
    return

    MenuHandler:
       MsgBox,, MenuHandler, % "Menu Item: " A_ThisMenuItem "`nMenu: " A_ThisMenu
    return

    GuiEscape:
    GuiClose:
    ExitSub:
       ExitApp ; Terminate the script unconditionally
    return
    ; ==============================================================================

    ; Functions ====================================================================
    WM_MOUSEMOVE(wParam, lParam, Msg, Hwnd) {
        Global

        DllCall("TrackMouseEvent", "UInt", &TME)

        MouseGetPos,,,, MouseCtrl, 2

        GuiControl, % (MouseCtrl = hButtonMinimizeN || MouseCtrl = hButtonMinimizeH) ? "Show" : "Hide", % hButtonMinimizeH
        GuiControl, % (MouseCtrl = hButtonMaximizeN || MouseCtrl = hButtonMaximizeH) ? "Show" : "Hide", % hButtonMaximizeH
        GuiControl, % (MouseCtrl = hButtonRestoreN || MouseCtrl = hButtonRestoreH) ? "Show" : "Hide", % hButtonRestoreH
        GuiControl, % (MouseCtrl = hButtonCloseN || MouseCtrl = hButtonCloseH) ? "Show" : "Hide", % hButtonCloseH

        GuiControl, % (MouseCtrl = hButtonMenuFileText) ? "Show" : "Hide", % hButtonMenuFileH
        GuiControl, % (MouseCtrl = hButtonMenuEditText) ? "Show" : "Hide", % hButtonMenuEditH
        GuiControl, % (MouseCtrl = hButtonMenuViewText) ? "Show" : "Hide", % hButtonMenuViewH
        GuiControl, % (MouseCtrl = hButtonMenuToolsText) ? "Show" : "Hide", % hButtonMenuToolsH
        GuiControl, % (MouseCtrl = hButtonMenuHelpText) ? "Show" : "Hide", % hButtonMenuHelpH
    }

    WM_LBUTTONDOWN(wParam, lParam, Msg, Hwnd) {
        Global

        If (MouseCtrl = hTitleHeader || MouseCtrl = hTitle) {
            PostMessage, 0xA1, 2
        }

        GuiControl, % (MouseCtrl = hButtonMinimizeH) ? "Show" : "Hide", % hButtonMinimizeP
        GuiControl, % (MouseCtrl = hButtonMaximizeH) ? "Show" : "Hide", % hButtonMaximizeP
        GuiControl, % (MouseCtrl = hButtonRestoreH) ? "Show" : "Hide", % hButtonRestoreP
        GuiControl, % (MouseCtrl = hButtonCloseH) ? "Show" : "Hide", % hButtonCloseP
    }

    WM_LBUTTONUP(wParam, lParam, Msg, Hwnd) {
        Global

        If (MouseCtrl = hButtonMinimizeP) {
            WinMinimize
        } Else If (MouseCtrl = hButtonMaximizeP || MouseCtrl = hButtonRestoreP) {
            WinGet, MinMaxStatus, MinMax

            If (MinMaxStatus = 1) {
                WinRestore
                GuiControl, Hide, % hButtonRestoreN
            } Else {
                WinMaximize
                GuiControl, Show, % hButtonRestoreN
            }
        } Else If (MouseCtrl = hButtonCloseP) {
            ExitApp
        } Else If (MouseCtrl = hButtonMenuFileText) {
            ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuFileText%
            Menu, FileMenu, Show, %ctlX%, % ctlY + ctlH
        } Else If (MouseCtrl = hButtonMenuEditText) {
            ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuEditText%
            Menu, EditMenu, Show, %ctlX%, % ctlY + ctlH
        } Else If (MouseCtrl = hButtonMenuViewText) {
            ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuViewText%
            Menu, ViewMenu, Show, %ctlX%, % ctlY + ctlH
        } Else If (MouseCtrl = hButtonMenuToolsText) {
            ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuToolsText%
            Menu, ToolsMenu, Show, %ctlX%, % ctlY + ctlH
        } Else If (MouseCtrl = hButtonMenuHelpText) {
            ControlGetPos, ctlX, ctlY, ctlW, ctlH, , ahk_id %hButtonMenuHelpText%
            Menu, HelpMenu, Show, %ctlX%, % ctlY + ctlH
        }

        GuiControl, Hide, % hButtonMinimizeP
        GuiControl, Hide, % hButtonMaximizeP
        GuiControl, Hide, % hButtonRestoreP
        GuiControl, Hide, % hButtonCloseP
        GuiControl, Hide, % hButtonMenuFileH
        GuiControl, Hide, % hButtonMenuEditH
        GuiControl, Hide, % hButtonMenuViewH
        GuiControl, Hide, % hButtonMenuToolsH
        GuiControl, Hide, % hButtonMenuHelpH
    }

    WM_MOUSELEAVE(wParam, lParam, Msg, Hwnd) {
        Global

        GuiControl, Hide, % hButtonMinimizeH
        GuiControl, Hide, % hButtonMaximizeH
        GuiControl, Hide, % hButtonRestoreH
        GuiControl, Hide, % hButtonCloseH
        GuiControl, Hide, % hButtonMinimizeP
        GuiControl, Hide, % hButtonMaximizeP
        GuiControl, Hide, % hButtonRestoreP
        GuiControl, Hide, % hButtonCloseP
        GuiControl, Hide, % hButtonMenuFileH
        GuiControl, Hide, % hButtonMenuEditH
        GuiControl, Hide, % hButtonMenuViewH
        GuiControl, Hide, % hButtonMenuToolsH
        GuiControl, Hide, % hButtonMenuHelpH
    }

    CreateDIB(Input, W, H, ResizeW := 0, ResizeH := 0, Gradient := 1 ) {
        WB := Ceil((W * 3) / 2) * 2, VarSetCapacity(BMBITS, (WB * H) + 1, 0), P := &BMBITS

        Loop, Parse, Input, |
        {
            P := Numput("0x" . A_LoopField, P + 0, 0, "UInt") - (W & 1 && Mod(A_Index * 3, W * 3) = 0 ? 0 : 1)
        }

        hBM := DllCall("CreateBitmap", "Int", W, "Int", H, "UInt", 1, "UInt", 24, "Ptr", 0, "Ptr")
        hBM := DllCall("CopyImage", "Ptr", hBM, "UInt", 0, "Int", 0, "Int", 0, "UInt", 0x2008, "Ptr")
        DllCall("SetBitmapBits", "Ptr", hBM, "UInt", WB * H, "Ptr", &BMBITS)

        If (Gradient != 1) {
            hBM := DllCall("CopyImage", "Ptr", hBM, "UInt", 0, "Int", 0, "Int", 0, "UInt", 0x0008, "Ptr")
        }

        return DllCall("CopyImage", "Ptr", hBM, "Int", 0, "Int", ResizeW, "Int", ResizeH, "Int", 0x200C, "UPtr")
    }
    ; ==============================================================================
     

    [GUI] AutoHotkey Ribbon

    [​IMG]
    [​IMG]

    [​IMG]

    Bạn chạy script bằng 32-bit nhá
    Code: https://autohotkey.com/boards/download/file.php?id=1206

    [GUI] Menu Interface

    [​IMG]

    [​IMG]

    Code:
    Mã (Autohotkey):

    ; Globals ======================================================================
    #SingleInstance, Force ; Replace with new instance if script is running
    #Persistent ; Keep script permanently running until terminated
    #NoEnv ; Prevent identifying empty variables as potential environment variables
    #Warn ; Enable warnings to assist with detecting errors
    ;#NoTrayIcon ; Disable the tray icon of the script
    SendMode, Input ; Method for sending keystrokes and mouse clicks
    SetWorkingDir, %A_ScriptDir% ; The current working directory of the script

    Application := {Name: "Menu Interface", Version: "0.1"}
    Window := {Width: 600, Height: 400, Title: Application.Name}
    Navigation := {Label: ["General", "Advanced", "Language", "Theme", "---", "Help", "About"]}
    ; ==============================================================================

    ; Auto-Execute =================================================================
    Menu, Tray, Icon, Shell32.dll, 174
    Menu, Tray, Tip, % Application.Name
    Menu, Tray, NoStandard
    Menu, Tray, Add, Exit, ExitSub

    Gui, +LastFound -Resize +HwndhGui1
    Gui, Color, FFFFFF

    Gui, Add, Tab2, % " x" 0 " y" 0 " w" 0 " h" 0 " -Wrap +Theme vTabControl", % ""

    Gui, Tab ; Exclude future controls from any tab control

    Gui, Add, Picture, % "x" -999999 " y" -999999 " w" 4 " h" 32 " vpMenuHover +0x4E +HWNDhMenuHover",
    Gui, Add, Picture, % "x" 0 " y" 18 " w" 4 " h" 32 " vpMenuSelect +0x4E +HWNDhMenuSelect",

    Gui, Font, s9 c808080, Segoe UI ; Set Font Options
    Loop, % Navigation.Label.Length() {
        GuiControl,, TabControl, % Navigation.Label[A_Index] "|"
        If (Navigation.Label[A_Index] = "---") {
            Continue
        }
        Gui, Add, Text, % "x" 18 " y" (32*A_Index)-14 " h" 32 " +0x200 gMenuClick vMenuItem" . A_Index, % Navigation.Label[A_Index]
    }
    Gui, Font ; Reset font options

    Gui, Font, s11 c000000, Segoe UI ; Set Font Options
    Gui, Add, Text, % "x" 192 " y" 18 " w" (Window.Width-192)-14 " h" 32 " +0x200 vPageTitle", % ""
    Gui, Font ; Reset font options

    Gui, Add, Picture, % "x" 192 " y" 50 " w" (Window.Width-192)-14 " h" 1 " +0x4E +HWNDhDividerLine",

    Gui, Add, Button, % "x" (Window.Width-170)-10 " y" (Window.Height-24)-10 " w" 80 " h" 24 " vButtonOK", % "OK"
    Gui, Add, Button, % "x" (Window.Width-80)-10 " y" (Window.Height-24)-10 " w" 80 " h" 24 " vButtonCancel", % "Cancel"

    Gui, Tab, 1 ; Future controls are owned by the specified tab
    Gui, Add, Checkbox, % "x" 192 " y" 66 " w" (Window.Width-192)-14, % "Checkbox Example"

    Gui, Tab, 2 ; Future controls are owned by the specified tab
    Gui, Add, ListView, % "x" 192 " y" 66 " w" (Window.Width-192)-14, % "Col1|Col2"
    LV_Add("", "ListView", "Example")
    LV_ModifyCol()

    Gui, Tab, 3 ; Future controls are owned by the specified tab
    Gui, Add, MonthCal, % "x" 192 " y" 66

    Gui, Tab, 4 ; Future controls are owned by the specified tab
    Gui, Add, DateTime, % "x" 192 " y" 66, LongDate

    Gui, Tab, 5 ; Future controls are owned by the specified tab
    ; Skipped

    Gui, Tab, 6 ; Future controls are owned by the specified tab
    Gui, Add, GroupBox, % "x" 192 " y" 66 " w" (Window.Width-192)-14, % "GroupBox"

    Gui, Tab, 7 ; Future controls are owned by the specified tab
    Gui, Add, DateTime, % "x" 192 " y" 66, LongDate

    Gui, Show, % " w" Window.Width " h" Window.Height, % Window.Title

    GoSub, OnLoad
    return ; End automatic execution
    ; ==============================================================================

    ; Labels =======================================================================
    OnLoad:
       SetPixelColor("CCEEFF", hMenuHover)
        SetPixelColor("3399FF", hMenuSelect)
        SetPixelColor("D8D8D8", hDividerLine)
        SelectMenu("MenuItem1")
        OnMessage(0x200, "WM_MOUSEMOVE")
    return

    MenuClick:
       SelectMenu(A_GuiControl)
    return

    GuiEscape:
    GuiClose:
    ButtonOK:
    ButtonCancel:
    ExitSub:
       ExitApp ; Terminate the script unconditionally
    return
    ; ==============================================================================

    ; Functions ====================================================================
    SelectMenu(Control) {
        Global

        CurrentMenu := Control

        Loop, % Navigation.Label.Length() {
            SetControlColor("808080", Navigation.Label[A_Index])
        }

        SetControlColor("000000", Control)
        GuiControl, Move, pMenuSelect, % "x" 0 " y" (32*SubStr(Control, 9, 2))-14 " w" 4 " h" 32
        GuiControl, Choose, TabControl, % SubStr(Control, 9, 2)
        GuiControl,, PageTitle, % Navigation.Label[SubStr(Control, 9, 2)]
    }

    WM_MOUSEMOVE(wParam, lParam, Msg, Hwnd) {
        Global

        If (InStr(A_GuiControl, "MenuItem") = true && A_GuiControl != CurrentMenu) {
            GuiControl, Move, pMenuHover, % "x" 0 " y" (32*SubStr(A_GuiControl, 9, 2))-14 " w" 4 " h" 32
        } Else If (InStr(A_GuiControl, "MenuItem") = false || A_GuiControl = CurrentMenu) {
            GuiControl, Move, pMenuHover, % "x" -999999 " y" -999999 " w" 4 " h" 32
        }
    }

    SetControlColor(Color, Control) {
        Global

        GuiControl, % "+c" Color, % Control

        ; Required due to redrawing issue with Tab2 control
        GuiControlGet, ControlText,, % Control
        GuiControlGet, ControlHandle, Hwnd, % Control
        DllCall("SetWindowText", "Ptr", ControlHandle, "Str", ControlText)
    }

    SetPixelColor(Color, Handle) {
        VarSetCapacity(BMBITS, 4, 0), Numput("0x" . Color, &BMBITS, 0, "UInt")
        hBM := DllCall("Gdi32.dll\CreateBitmap", Int, 1, Int, 1, UInt, 1, UInt, 24, Ptr, 0)
        hBM := DllCall("User32.dll\CopyImage", Ptr, hBM, UInt, 0, Int, 0, Int, 0, UInt, 0x2008)
        DllCall("Gdi32.dll\SetBitmapBits", Ptr, hBM, UInt, 3, Ptr, &BMBITS)
        return DllCall("User32.dll\SendMessage", Ptr, Handle, UInt, 0x172, Ptr, 0, Ptr, hBM)
    }
    ; ==============================================================================
     

    [GUI Skin] USkin

    [​IMG]

    Xem chi tiết tại đây: https://autohotkey.com/boards/viewtopic.php?f=6&t=5841
     
    Chỉnh sửa cuối: 1/5/19
  2. DuyMinh

    DuyMinh Thành viên năng động
    • 28/34

    Tham gia ngày:
    14/3/17
    Bài viết:
    177
    Đã được thích:
    92
    [WINHTTPREQUEST]
    Code: https://pastebin.com/vTJJ5R3P
    Cách sử dụng:
    WinHttpRequest( URL, ByRef In_POST__Out_Data="", ByRef In_Out_HEADERS="", Options="" )
    URL: Ai cũng biết là cái gì rồi...
    In_POST__Out_Data: nói đơn giản thì nạp vào 1 biến chứa data2send, sau khi request biến đó sẽ chứa source trả về. Nếu data rỗng thì method là GET => đương nhiên là thế rồi.
    In_Out_HEADERS: tương tự, nhưng là với header
    Options: có trong phần đầu code, timeout, method, save binary, no redirect bla bla bla...
     
    ahk idol and Huân Hoàng like this.
  3. Only AHK

    Only AHK Team AutoHotkey
    • 3/6

    Tham gia ngày:
    13/6/18
    Bài viết:
    24
    Đã được thích:
    15
    Wow, mấy cái gui đẹp quá bác ơi <3<3
     
  4. Thanh Hưng bmT

    Thanh Hưng bmT Thành viên mới
    • 1/6

    Tham gia ngày:
    20/4/19
    Bài viết:
    3
    Đã được thích:
    0
    bá đạo
     
  5. Nguyễn Tiến Vũ

    Nguyễn Tiến Vũ Thành viên mới
    • 3/6

    Tham gia ngày:
    18/3/20
    Bài viết:
    8
    Đã được thích:
    1
    hay quá bạn ơi!!!!
     
  6. CaubeToMo

    CaubeToMo Thành viên mới
    • 1/6

    Tham gia ngày:
    25/4/20
    Bài viết:
    3
    Đã được thích:
    0
    Bác cho em hỏi có library nào cho phép search text bên trong ảnh thay vì màn hình k ạ!
     
  7. ledachai

    ledachai Thành viên
    • 18/23

    Tham gia ngày:
    17/5/20
    Bài viết:
    41
    Đã được thích:
    27
    - Cái FindText
    Mình copy code và dán vào New Autohotkey Script chạy thì nó báo lỗi này
    Mã (Text):
    Error at line xxx
    Line Text: local
    Error: This line does not contain a recognized action.
    The program will exit.
    Nó báo lỗi dòng nào thì mình đi theo xoá hết dòng đó :D . Và điều kỳ lạ là code hoạt động!!! Mình k0 hiểu lý do là gì?
    - Gdip_ImageSearch, Mình chạy thử mã của Milli. Nó chỉ tìm đc hình trong cửa sổ bị che khuất, chứ không tìm đc cửa sổ minize dưới taskabar. Và khi nó cotrolclick thì lại active cửa sổ đó lên trên. Cho mình hỏi muốn cửa sổ vẫn inactive bên dưới thì làm thế nào?
    Edit: À mình khắc phục được rồi, đọc cái controlclick xong thay option cuối Pos thành NA, vậy là không active cửa sổ lên nữa
     
    Chỉnh sửa cuối: 24/5/20
    huynhvantam123 thích bài này.

Chia sẻ trang này

Đang tải...