[PA] 업무자동화/[AH]Autohotkey

AH 승인요청 - 승인 app

Weneedu 2022. 5. 28. 01:57

20220609 1742 

z문서승인 요청 승인결과 알림 앱 20220603 1435.docx
0.07MB
z문서승인 요청 승인결과 알림 앱 20220603 1435.pdf
1.10MB

 

20220609 1742 

REF

 

 

기능/기술

drag & drop

특정 위치에 drag & drop해야 반응하기

네트워크 통신 - 네트워크 파일 갱신 모니터링

배열과 loop을 이용한 Gui 만들기

 

Approval Request & Monitoring App.pdf
0.38MB

 

코드

1. Approval Request

;#################################################################
; Approval Request Module
; 20220526 1447 
; PARAMETERS
zflag:=1
zFiles:=[]
zDests:=["\Daily Cash mgt report\"
               ,"\Fund Transafer\"
			   ,"\Fund Transafer\"
			   ,"\Fund Transafer\"
			   ,"\Market Information\"]
zDescription:=["cash file"
                         ,"FT a"
						 ,"FT GA"
						 ,"FT PR"
						 ,"Deal"]
zNmb :=zDests.length()
;#################################################################

File=\zMessenger\data.txt ;Change this to what ever directory is being shared with the other computer.
Name:=A_ComputerName ;Comment this if you want to choose your own name in the chat. This is just to make things more simple.

FileDelete, %File%
FileAppend,, %File%

Gui, Dropper: New

loop, %zNmb% {
	Gui, Color, 00FF00
	zDscr:=zDescription[A_Index] 
    ztmp:= "vzTxt"A_Index
	ztmp1:= "HwndHTB"A_Index
	ztmp2 := "HwndHTable"A_Index
	Gui, Font, cRed
	;Gui, Add, text, cBlue %ztmp2% HwndHTable1,%zDscr%  ▶  Click_to_open_work_folder	
	Gui, Add, text, cBlue gzLink %ztmp2%,%zDscr%(▶ Click_Here_to_open_folder)
	Gui, Font, cBlack
	Gui, Add, Edit, ReadOnly -BackgroundTrans +Border  %ztmp% h50 w250 %ztmp1% ,  Drop file here
}
;Gui, Show,w300 h200, Dropper
Gui, Add, Button, gSend , Send
Gui, Add, Button, gCanc x+40 yp , Cancel
Gui, Show,, Approval Requester
WinGet Gui_ID, ID, A
Return

zLink:
loop, %zNmb% {
	MouseGetPos,,,, Hclick,2
	ztmp:="HTable"A_Index
	;MsgBox,% Hclick
	if (Hclick = %ztmp%) {
		zTar:=zDests[A_Index]
		run, %zTar%
	}
}
return

Canc:
ExitApp

DropperGuiDropFiles:
DroppedFile:=A_GuiEvent
SplitPath, DroppedFile , zName
MouseGetPos,,,, Hdrop,2
loop, %zNmb% {
	ztmp:="HTB"A_Index
	ztmp1:="zTxt"A_Index
	zFiles.push("")
	if (Hdrop = %ztmp%)  { 
	GuiControl,,%ztmp1%,%zName% 
	zFiles[A_Index]  := DroppedFile
	ztmp:=zFiles[A_index]
	} 
}

Gui, Show,, Approval Requester
return


Send:
$Enter::
Gui, Submit, Nohide
IfWinNotActive, Approval Requester
{ 
	Send, {Enter} 
	Return
}

zTimestamp :=  A_year A_Mon A_DD " " A_Hour A_Min A_Sec
FileAppend, %name%`n`n, %File%
FileAppend, %zTimestamp%`n`n, %File%

loop, %zNmb% {
	ztmp:=zFiles[A_Index]
	ztmp_dest:=zDests[A_Index]
	if StrLen(ztmp)>0 {
	ztmp1:="zTxt"A_Index
	ztmp1:=%ztmp1%
	FileAppend, %ztmp_dest% %ztmp1%`n`n, %File%
	FileCopy, %ztmp% ,  %ztmp_dest% ; source, dest, flag 1= overriete
	}
}

Gui, destroy
ztmp :=""
ztmp1 :=""
ztmp2 :=""
zcount :=0
loop, %zNmb% {
	ztmp2:="zTxt"A_Index
    ztmp1:=%ztmp2%
	if (ztmp1 !="Drop file here") {
	ztmp:= ztmp ztmp1 "`n"
	zcount:=zcount + 1
	}
}

SetTimer, ParseData, 500
FileRead, Data, %File%
LastData=%Data%
zstr := ztmp "`n" zcount  " file(s) sent..waiting approval or`n click cancel"

Gui, Add, text, ,%zstr% 
Gui, Add, Button, gXwait, minimize window and wait
Gui, Add, Button, gXcancel, Cancel
Gui, Show,, win_wait
return

Xwait:
WinMinimize, win_wait
return

Xcancel:
FileDelete, %File%
FileAppend,, %File%
ExitApp

; if cancel then delete all

ParseData:
FileRead, Data, %File%
If (Data <> LastData) {
	;WinClose, wait_window 
	MsgBox, %ztmp% `n`n %zcount% File(s) Approved. Thank you.
	ExitApp
}
LastData=%Data%
Return

ExitApp

GuiClose:
ExitApp

 

2. monitoring & approval

File=\\10.156.1.86\group\Treasury\RESTR\zMessenger\data.txt ;Change this to what ever directory is being shared with the other computer.
Name:=A_ComputerName ;Comment this if you want to choose your own name in the chat. This is just to make things more simple.

Gui, Color, FF8040
FileRead, Data, %File%

Gui, Add, Edit, ReadOnly -BackgroundTrans +Border vTextData w250 h200, %Data%
Gui, Add, Edit, vTextInput  x10 y215 w200 h50,
Gui, Add, Button, gSend x215 y215 w50 h50, Send
Gui, Show,, Request Monitor
WinGet Gui_ID, ID, A

SetTimer, ParseData, 500
Return

Send:
$Enter::
Gui, Submit, Nohide
IfWinNotActive, Request Monitor
{
	Send, {Enter}	
	Return
}
If (TextInput = "/del log")
{
	FileDelete, %File%
	FileAppend,, %File%
	GuiControl,, TextInput, 
	Return
}
FileAppend, %name%:`n%TextInput%`n`n, %File%
GuiControl,, TextInput, 
Return

ParseData:
FileRead, Data, %File%
If (Data <> LastData)
{	
	MsgBox, 48, Popup Window, Approval Requested
	IfMsgBox OK
	{
		WinRestore, Request Monitor
		WinActivate, Request Monitor
	}

    GuiControl,, TextData, %Data%
	GuiControl Focus, TextData
	ControlGetFocus ClassLog, ahk_id %Gui_ID%
	ControlSend %ClassLog%, ^{End}, ahk_id %Gui_ID%
	GuiControl Focus, TextInput
        TrayTip, New message!
        Sleep 500
        TrayTip

}
LastData=%Data%
Return

GuiClose:
ExitApp