Auto ban moi nhat

Source code:



#InstallKeybdHook
#UseHook On
CoordMode, Mouse, Relative
global Var_From := 0
global Var_To := 0
global MyRadioGroup := 1
global numberChar := 3
global isDauNhay := 0
global Var_From := 0
global Var_To := 0
global soDongCanGop := 2
global soCotCanGop := 15
global viTriCotBatDauGop := 1
global main_trang_thai = "Bật"
global main_button = 1
global winID := []
global winClickID := 0
init_aray()
initialize()
initGuiInputNumRow()
initGuiRowHeightUp()
khoi_tao_bang_dieu_khien()
hien_thi_bang_dieu_khien()
; bien su dung cho gop hang
global number_Row_Join := 1
global number_Column_Loop_Join := 3
global flag_hot_key := 1
temp1 := 0
class_send_001 := 0

`::LButton

^0::
SendMessage, 0x112, 0xF170, 2,, Program Manager
Return
temp := winID[1]
^1::Winset, Alwaysontop, , A

Return
;
^2:: Set_Copy()
;^2:: dua_top_go_phim()
^!2:: showGuiInputNumRow()
;^!2:: showGuiThayDoiChieuCao()
;^+2:: Set_Copy_AOO()
^+2:: setMerge()

^3:: Set_Paste()
^+3:: setUnMerge()
; Ctrl + Shift + 2


^5::
    Cao_2_3 := Ceil((A_ScreenHeight/3)*2)
    Rong_full := A_ScreenWidth
    WinMove, A, , 0, 0, %Rong_full%, %Cao_2_3%,
Return
^6::
    Cao_2_3 := Ceil((A_ScreenHeight/3)*2)
    Cao_1_3 := Ceil((A_ScreenHeight/3)*1) - 45 ;tinh ca taskbar
    Rong_full := A_ScreenWidth
    WinMove, A, , 0, %Cao_2_3%, %Rong_full%, %Cao_1_3%,
Return

!5::
    Cao_1_2 := Ceil(A_ScreenHeight/2)
    Rong_full := A_ScreenWidth
    WinMove, A, , 0, 0, %Rong_full%, %Cao_1_2%,
Return
!6::
    Cao_2_3 := Ceil(A_ScreenHeight/2)
    Cao_1_3 := Ceil(A_ScreenHeight/2) - 45 ;tinh ca taskbar
    Rong_full := A_ScreenWidth
    WinMove, A, , 0, %Cao_2_3%, %Rong_full%, %Cao_1_3%,
Return
^8::
    Write_Index()
Return
Write_Index(){
    Var_From := 0
    Var_To := 0
    Gui, InputPrefix:Show
    return
}
!NumpadEnd::Save_And_Move_Window(1)
!NumpadDown::Save_And_Move_Window(2)
!NumpadPgDn::Save_And_Move_Window(3)
!NumpadLeft::Save_And_Move_Window(4)
!NumpadClear::Save_And_Move_Window(5)
!NumpadRight::Save_And_Move_Window(6)
!NumpadHome::Save_And_Move_Window(7)
!NumpadUp::Save_And_Move_Window(8)
!NumpadPgUp::Save_And_Move_Window(9)
^!NumpadIns::Reset_All_View()
^+NumpadIns::Maximum_All_View()
Move_End(){
    SendInput ^{End}
}
Move_Begin(){
    SendInput ^{Home}
}
Set_Select(){
    SendInput {Esc}
    SendInput {F2}
    Move_End()
    SendInput {Shift down}
    Move_Begin()
    SendInput {Shift up}
}
Set_Copy(){
    Set_Select()
    SendInput ^c
    SendInput {Esc}
}
Set_Paste(){
    Set_Select()
    SendInput ^v
    SendInput {Enter}
}
Set_Delete(){
    Set_Select()
    SendInput {Delete}
    SendInput {Enter}
}

initialize(){
    ; thay doi icon
    pathIcon := A_ScriptDir . "\Pikachu.ico"
    handerIcon := LoadPicture(pathIcon,"w16 h16",IMAGE_ICON)
    Menu Tray, Icon, HICON:*%handerIcon%
    ;Menu Tray, Icon, %pathIcon%
    MyRadioGroup := a
    Gui, InputPrefix: New
    global hIcon32 := DllCall("LoadImage", uint, 0
    , str, "Pikachu.ico"  ; Icon filename (this file may contain multiple icons).
    , uint, 1  ; Type of image: IMAGE_ICON
    , int, 32, int, 32    ; Desired width and height of image (helps LoadImage decide which icon is best).
    , uint, 0x10)  ; Flags: LR_LOADFROMFILE

    Gui, InputPrefix: Add, Text , X25 Y25 section , Nhập số bắt đầu
    Gui, InputPrefix: Add, Text , , Nhập số kết thúc
    Gui, InputPrefix: Add, Text , , Cấu hình prefix
    Gui, InputPrefix: Add, Text, , Số lượng ký tự:
    Gui, InputPrefix: Add, Text, , Dấu nháy ?:
    ; Nhập số bắt đầu
    Gui, InputPrefix: Add, Edit, w50 ys vVar_From Number Limit3 , 0
    ;Nhập số kết thúc
    Gui, InputPrefix: Add, Edit, w50 vVar_To Number Limit3 , 0
    ;Cấu hình prefix
    Gui, InputPrefix: Add, Radio, Group Checked vMyRadioGroup, không dùng
    Gui, InputPrefix: Add, Radio, ,có dùng
    ; Số lượng ký tự
    Gui, InputPrefix: Add, Edit, vnumberChar Number Limit2 ReadOnly, % numberChar
    Gui, InputPrefix: Add, UpDown, Range3-10,
    ;Dấu nháy ?:
    Gui, InputPrefix: Add, Checkbox, visDauNhay, Có sử dụng dấu '
    Gui, InputPrefix: Add, Button, Default gSetPrefix, OK (3 con sâu)
    ;
    Gui, InputPrefix: +Resize +AlwaysOnTop
}
setPrefix(){
    Gui, InputPrefix: Submit
    if (Var_To > Var_From) {
        i := 1
    } else {
        i := -1
    }
    While Var_From != Var_To
    {
        string001 := Var_From
        string001 := genStringOutput(Var_From)
        SendInput % string001 . "{Enter}"
        Var_From := Var_From + i
    }
    string001 := genStringOutput(Var_From)
    SendInput % string001 . "{Enter}"
}
genStringOutput(number001){
    stringOut := number001
    if (MyRadioGroup == 2) {
        stringOut := Format("{:0+" . numberChar . "s}", stringOut)
    }
    if (isDauNhay != 0) {
        stringOut := "'" . stringOut
    }
    return stringOut
}
setMerge(){
    SendInput {Alt}hmm
}
setUnMerge(){
    SendInput {Alt}hmu
}
setMergeLine(){
    SendInput {Alt}hmm
}

; oopy in apache openoffline -> copy 1 line
Set_Copy_AOO(){
    SendInput ^a
        SendInput ^c
    SendInput {Esc}
}
;///////////////////Nhap
; function get char
dua_top_go_phim(){
    Loop, parse, clipboard, %A_Space%,
    {
        SendInput  %A_LoopField%{Space}
        Sleep, 200
    }
}
;
go_To_Begin_Line(){
    SendInput {Esc}{Home}
}
initGuiInputNumRow(){
    Gui, InputRow: New
    Gui, InputRow: Add, Text, X25 Y25 section, Nhập số dòng cần gộp:
    Gui, InputRow: Add, Text, , Nhập số cột cần gộp:
    Gui, InputRow: Add, Text, , Nhập vị trí cột cần gộp:
    Gui, InputRow: Add, Button, gcancel, Cancel
    Gui, InputRow: Add, Edit, vsoDongCanGop Number Limit2  ys, %soDongCanGop%
    Gui, InputRow: Add, UpDown, Range2-50,    %soDongCanGop%
    Gui, InputRow: Add, Edit, vsoCotCanGop Number Limit2 , %soCotCanGop%
    Gui, InputRow: Add, UpDown, Range1-50,    %soCotCanGop%
    Gui, InputRow: Add, Edit, vviTriCotBatDauGop Number Limit2, %viTriCotBatDauGop%
    Gui, InputRow: Add, UpDown, Range1-50,    %viTriCotBatDauGop%
    Gui, InputRow: Add, Button, Default gbat_dau_merge, OK
}
bat_dau_merge(){
    Gui, InputRow: Submit ,
    soDongXoa := soDongCanGop - 2
    soDongGop := soDongCanGop -1
    soCotXoa := soCotCanGop - 1
    soCotDich := viTriCotBatDauGop -1
    SendInput {Home}{Left}{Right %soCotDich%}{Down}
    SendInput {Shift Down}{Down %soDongXoa%}
    SendInput {Right %soCotXoa%}
    SendInput {Shift Up}
    SendInput {Delete}
    SendInput {Up}
    Loop, %soCotCanGop% {
        SendInput {Shift Down}
        SendInput {Down %soDongGop%}
        SendInput {F8}
        SendInput {Shift Up}
        SendInput {Right}
    }
    setMerge()
}
cancel(){
    Gui, InputRow: Submit ,
}
showGuiInputNumRow(){
    Gui, InputRow: Show
    GuiControl, , soCotCanGop , %soCotCanGop%
}
initGuiRowHeightUp() {
    Gui, RowHeight: New
    Gui, RowHeight: Add, Text, X25 Y25 section, Nhập số dòng cần làm tăng chiều cao tương ứng:
    Gui, RowHeight: Add, Button, gcancel2, Cancel
    Gui, RowHeight: Add, Edit, vsoDongCanGop Number Limit2    ys, %soDongCanGop%
    Gui, RowHeight: Add, UpDown, Range2-50,     %soDongCanGop%
    Gui, RowHeight: Add, Button, Default gbat_dau_thay_doi_chieu_cao, OK
}
cancel2(){
    Gui, RowHeight: Submit ,
}
bat_dau_thay_doi_chieu_cao(){
    Gui, RowHeight: Submit ,
    chieuCao := Round(soDongCanGop * 16.5,2)
    SendInput {Alt}hoh
    Sleep, 100
    SendInput %chieuCao%
    Sleep, 100
    SendInput {Enter}
}
showGuiThayDoiChieuCao(){
    Gui, RowHeight: Show
    GuiControl, , soCotCanGop , %soCotCanGop%
}

khoi_tao_bang_dieu_khien(){
    Gui, Main01: New, +AlwaysOnTop -Border    -Caption +Owner, Cấu hình
    Gui, Main01: Color, EEAA99
    Gui, Main01: +LastFound
    WinSet, TransColor, EEAA99
    Gui, Main01: Add, Text, section,Trạng thái:
    Gui, Main01: Add, Text, vmain_trang_thai ys, Bật
    Gui, Main01: Add, Button, vmain_button gmain_click_thay_doi ys, Tắt
    moveImage := A_ScriptDir . "\move.png"
    handerMoveImage := LoadPicture(moveImage, "w24 h24", IMAGE_BITMAP)
    ;Menu Tray, Icon, HBITMAP:*%handerMoveImage%
    Gui, Main01: Add, Picture, gmove_main ys, HBITMAP:%handerMoveImage%
}
main_click_thay_doi(){
    if (flag_hot_key == 1) {
        flag_hot_key := 0
        GuiControl, Main01:Text, main_trang_thai, Tắt
        GuiControl, Main01:Text, main_button, Bật
        disable_hotkey()
    }
    else {
        flag_hot_key := 1
        GuiControl, Main01:Text, main_trang_thai, Bật
        GuiControl, Main01:Text, main_button, Tắt
        enable_hotkey()
    }
}

hien_thi_bang_dieu_khien(){
    Gui, Main01: Show, NA
}
;////////////////////////
^NumpadEnd:: save_window_id(1)
^NumpadDown:: save_window_id(2)
^NumpadPgDn:: save_window_id(3)
^NumpadLeft:: save_window_id(4)
^NumpadClear:: save_window_id(5)
^NumpadRight:: save_window_id(6)
^NumpadHome:: save_window_id(7)
^NumpadUp:: save_window_id(8)
^NumpadPgUp:: save_window_id(9)
^NumpadDel:: save_window_id(10)
^NumpadIns:: save_window_id(11)
;////////////////////////
NumpadEnd:: active_windows(1)
NumpadDown:: active_windows(2)
NumpadPgDn:: active_windows(3)
NumpadLeft:: active_windows(4)
NumpadClear:: active_windows(5)
NumpadRight:: active_windows(6)
NumpadHome:: active_windows(7)
NumpadUp:: active_windows(8)
NumpadPgUp:: active_windows(9)
NumpadDel:: active_windows(10)
NumpadIns:: active_windows(11)
active_windows(index1){
    if (winID[index1] != 0) {
        WinGet, temp, ID, A
        if(temp != winID[index1]){
            temp := winID[index1]
            WinActivate, ahk_id %temp%
        }
    }
}
save_window_id(index1){
    temp := 0
    WinGet, temp, ID, A
    index_exists := check_exists_win_id(temp)
    if(index_exists != 0) {
        winID[index_exists] := 0
    }
    ;hoan vi neu da ton tai cua so
    ; neu khong thi gan no vao 1 vi tri nao do
    if(winID[index1] != 0) and WinExist("ahk_id " . winID[index1]) {
        if(index_exists!=0) {
            winID[index_exists] := winID[index1]
        } else {
            len := winID.Length()
            Loop, %len% {
                if(winID[A_Index] = 0) or not (WinExist("ahk_id " . winID[A_Index])) {
                    winID[A_Index] :=winID[index1]
                    break
                }
            }
        }
    }
    winID[index1] := temp
}
check_exists_win_id(ahk_id_value){
    len := winID.Length()
    Loop, %len% {
        if (winID[A_Index] = ahk_id_value) {
            return A_Index
        }
    }
    return 0
}
init_aray(){
winID[1] := 0
winID[2] := 0
winID[3] := 0
winID[4] := 0
winID[5] := 0
winID[6] := 0
winID[7] := 0
winID[8] := 0
winID[9] := 0
winID[10] := 0
winID[11] := 0
}
move_main(){
    Gosub, Label1
}
;////////////////////////
Label1:
CoordMode, Mouse  ; Switch to screen/absolute coordinates.
MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin%
WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin%
if EWD_WinState = 0     ; Only if the window isn't maximized
    SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it.
return

EWD_WatchMouse:
GetKeyState, EWD_LButtonState, LButton, P
if EWD_LButtonState = U     ; Button has been released, so drag is complete.
{
    SetTimer, EWD_WatchMouse, off
    return
}
GetKeyState, EWD_EscapeState, Escape, P
if EWD_EscapeState = D    ; Escape has been pressed, so drag is cancelled.
{
    SetTimer, EWD_WatchMouse, off
    WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY%
    return
}
; Otherwise, reposition the window to match the change in mouse coordinates
; caused by the user having dragged the mouse:
CoordMode, Mouse
MouseGetPos, EWD_MouseX, EWD_MouseY
WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin%
SetWinDelay, -1      ; Makes the below move faster/smoother.
WinMove, ahk_id %EWD_MouseWin%,, EWD_WinX + EWD_MouseX - EWD_MouseStartX, EWD_WinY + EWD_MouseY - EWD_MouseStartY
EWD_MouseStartX := EWD_MouseX  ; Update for the next timer-call to this subroutine.
EWD_MouseStartY := EWD_MouseY
return
;////////////////////////
enable_hotkey(){
    Hotkey, NumpadEnd, On
    Hotkey, NumpadDown, On
    Hotkey, NumpadPgDn, On
    Hotkey, NumpadLeft, On
    Hotkey, NumpadClear, On
    Hotkey, NumpadRight, On
    Hotkey, NumpadHome, On
    Hotkey, NumpadUp, On
    Hotkey, NumpadPgUp, On
    Hotkey, NumpadDel, On
    Hotkey, NumpadIns, On
    Hotkey, ^NumpadEnd, On
    Hotkey, ^NumpadDown, On
    Hotkey, ^NumpadPgDn, On
    Hotkey, ^NumpadLeft, On
    Hotkey, ^NumpadClear, On
    Hotkey, ^NumpadRight, On
    Hotkey, ^NumpadHome, On
    Hotkey, ^NumpadUp, On
    Hotkey, ^NumpadPgUp, On
    Hotkey, ^NumpadDel, On
    Hotkey, ^NumpadIns, On
    Hotkey, !NumpadEnd, On
    Hotkey, !NumpadDown, On
    Hotkey, !NumpadPgDn, On
    Hotkey, !NumpadLeft, On
    Hotkey, !NumpadClear, On
    Hotkey, !NumpadRight, On
    Hotkey, !NumpadHome, On
    Hotkey, !NumpadUp, On
    Hotkey, !NumpadPgUp, On
    Hotkey, ^!NumpadIns, On
    Hotkey, ^+NumpadIns, On
    Hotkey, *``, On
    Hotkey, *`` up, On
    Hotkey, ^1, On
    Hotkey, ^2, On
    Hotkey, ^3, On
    Hotkey, ^8, On
    Hotkey, ^!2, On
    Hotkey, ^+2, On
}
disable_hotkey(){
    Hotkey, NumpadEnd, Off
    Hotkey, NumpadDown, Off
    Hotkey, NumpadPgDn, Off
    Hotkey, NumpadLeft, Off
    Hotkey, NumpadClear, Off
    Hotkey, NumpadRight, Off
    Hotkey, NumpadHome, Off
    Hotkey, NumpadUp, Off
    Hotkey, NumpadPgUp, Off
    Hotkey, NumpadDel, Off
    Hotkey, NumpadIns, Off
    Hotkey, ^NumpadEnd, Off
    Hotkey, ^NumpadDown, Off
    Hotkey, ^NumpadPgDn, Off
    Hotkey, ^NumpadLeft, Off
    Hotkey, ^NumpadClear, Off
    Hotkey, ^NumpadRight, Off
    Hotkey, ^NumpadHome, Off
    Hotkey, ^NumpadUp, Off
    Hotkey, ^NumpadPgUp, Off
    Hotkey, ^NumpadDel, Off
    Hotkey, ^NumpadIns, Off
    Hotkey, !NumpadEnd, Off
    Hotkey, !NumpadDown, Off
    Hotkey, !NumpadPgDn, Off
    Hotkey, !NumpadLeft, Off
    Hotkey, !NumpadClear, Off
    Hotkey, !NumpadRight, Off
    Hotkey, !NumpadHome, Off
    Hotkey, !NumpadUp, Off
    Hotkey, !NumpadPgUp, Off
    Hotkey, ^!NumpadIns, Off
    Hotkey, ^+NumpadIns, Off
    Hotkey, *``, Off
    Hotkey, *`` up, Off
    Hotkey, ^1, Off
    Hotkey, ^2, Off
    Hotkey, ^3, Off
    Hotkey, ^8, Off
    Hotkey, ^!2, Off
    Hotkey, ^+2, Off
}
copyV(){
    Send {RCtrl down}
    Send c
    Send {RCtrl up}
}
pasteV(){
    Send {RCtrl down}
    Send v
    Send {RCtrl up}
}
SelectV(){
    Send {F2}
    Send {Home}
    Send {Shift down}
    Send {End}
    Send {Shift up}
}
Save_And_Move_Window(n){
    save_window_id(n)
    Move_Window(n)
}
Move_Window(n){
    if (n == 1){
        x := 1
        y := 3
    }
    if (n == 2){
        x := 2
        y := 3
    }
    if (n == 3){
        x := 3
        y := 3
    }
    if (n == 4){
        x := 1
        y := 2
    }
    if (n == 5){
        x := 2
        y := 2
    }
    if (n == 6){
        x := 3
        y := 2
    }
    if (n == 7){
        x := 1
        y := 1
    }
    if (n == 8){
        x := 2
        y := 1
    }
    if (n == 9){
        x := 3
        y := 1
    }
    Rong := A_ScreenWidth / 2
    Cao := (A_ScreenHeight - 45) / 2 ;tinh ca taskbar
    Chia_Ngang := A_ScreenWidth / 4
    Chia_Doc := (A_ScreenHeight - 45) / 4 ;tinh ca taskbar
    viTriX := (x - 1) * Chia_Ngang
    viTriY := (y - 1) * Chia_Doc
    temp := winID[n]
    WinRestore, ahk_id %temp%
    WinMove, ahk_id %temp%, , %viTriX%, %viTriY%, %Rong%, %Cao%,
}
Reset_All_View(){
    VongLap := [7,8,9,4,5,6,1,2,3]
    for i,j in VongLap
    {
        if (winID[j] != 0){
            Move_Window(j)
        }
    }
    hien_thi_bang_dieu_khien()
}
Maximum_All_View(){
    Rong := A_ScreenWidth
    Cao := A_ScreenHeight - 43 ;tinh ca taskbar
    Loop, 9
    {
        if (winID[A_Index] != 0){
            temp := winID[A_Index]
            WinRestore, ahk_id %temp%
            WinMove, ahk_id %temp%, , 0, 0, %Rong%, %Cao%,
        }
    }
    hien_thi_bang_dieu_khien()
}

don_dong(){
len := 9
j := 1
Loop, %len% {
if (winID[A_Index] != 0) and WinExist("ahk_id " . winID[A_Index]) {
if (A_Index <> j) {
winID[j] := winID[A_Index]
winID[A_Index] := 0
}
j := j+1
}
}
}

Không có nhận xét nào:

Đăng nhận xét