본문 바로가기
이미지맥스 그리고 루아(lua)/[응용] GUI

[이미지맥스] LD앱플레이어 제어용 GUI 및 lua함수 스크립트

by 위치결정 2022. 4. 24.
반응형

LD_GUI.7z
0.00MB

이미지맥스를 이용하여 LD앱플레이어 같은 앱플레이어를 활용하는 경우가 많을것 같습니다.

LD앱플레이어에서 제공하는 콘솔명령어를 활용하여 이미지맥스에서 앱플레이어를 제어할수 있는 기능을 공유합니다.

 

LD앱플레이어 콘솔 명령어 : https://kr.ldplayer.net/blog/an-introduction-to-ldplayer-command-line-interface.html

 

 

< 기능 >

- 이미지맥스의 GUI를 이용하여 LD앱플레이어의 실행, 종료 그리고 재시작을 컨트롤 할수있습니다.

- 이미지맥스를 실행하면 앱플레이어 및 지정앱을 자동실행 할수 있도록 옵션을 제공합니다.

 

< 설정 >

1. 앱플레이어 경로 설정

본인의 PC에 설치된 LD 앱플레이어의 설치 경로를 앱플레이어 경로에 작성합니다.

설치 된 LD 앱플레이어의 바로가기의 속성을 열어보면 설치경로를 알 수 있습니다. 이를 복사하여 앱플레이어 경로에 붙여 넣으신수 \ 를 \\ 로 수정하거나 / 로 수정해줍니다.

※ 루아에서 역슬래시에 해당하는 '\'를 이용하여 제어문자를 입력합니다. 따라서 \를 문자열로 입력하기 위해서는 \\ 로 입력하여야 합니다.

그리고 LD의 콘솔 dnconsole.exe 를 경로에 덧붙여줍니다.

2. 실행할 앱 지정하기

LD콘솔을 이용하여 지정앱을 실행하기 위해서는 앱의 패키지명을 알아야합니다.

그러면 앱의 패키지명은 어떻게 알수있는가?

이를 위해 우선 앱플레이어의 탐색기로 들어가 Android > Data 폴더로 이동을 합니다.

Data 폴더안에 앰플레이어에 설치되어 있는 앱들의 패키지명으로 생성되어있는것을 알수있습니다.

이중 실행할 앱을 찾아 똑같이 타이핑해줍니다.

 

3. 실행할 앱플레이어 번호 지정

실행할 앱플레이어의 번호를 지정합니다.

 

여기까지 다 하셨다면 설정 끝!

 

< 내장되어있는 함수 >

본 스크립트에 내장되어있는 lua로 활용할수 있는 함수들입니다.

 

- runApp(_string_path) : 윈도우 실행창을 통해 실행명령을 할수있습니다.

ex) runApp('calc') -- 윈도우 계산기앱 실행

 

- ld_launch() : 앱플레이어 실행 함수

- ld_quit() : 앱플레이어 종료 함수

- ld_reboot() : 앱플레이어 재시작 함수

- ld_launchex() : 앱플레이어를 실행 후, 지정앱 실행 함수

- ld_runapp() : 지정앱 실행 함수

- ld_killapp() : 지정앱 종료 함수

 

 

1. 앱플레이어의 실행 및 종료, 재시작

2. 지정 앱 실행 및 종료, 앱플레이어의 시작과 지정앱을 자동 실행

3. 이미지맥스를 실행시 앱플레이어 자동실행

4. 이미지맥스를 실행시 앱플레이어 자동 실행 및 지정앱 자동 실행

 

< LD 앱플레이어 제어용 GUI 사전스크립트 코드 >

-- print('========================================')
-- print('LD앱플레이어 제어 프로그램 ver.220605')
-- print('========================================')

-- 윈도우 앱 실행
function runApp(_string_path)
    os.execute('start "" '.._string_path)
    print('실행: '..tostring(_string_path))
end


-- ## LD 앱플레이어 GUI
ldplayer_gui = 'LD앱플레이어'
GUIAddTab(ldplayer_gui)
GUISetCurTab(ldplayer_gui)


-- # 앱플레이어 경로 그룹
x, y, w, h = 5, 10, 350, 25
GUIAddGroup(x, y, w, h, '앱플레이어 경로')
ld_path_edit_id = GUIAddEdit(x + 0, y + 8, 340, -1, '경로를 기입해주세요.', nil, 'ld_path_edit')


-- # 앱플레이어 기본 설정 그룹
x, y, w, h = 5, 60, 350, 25
GUIAddGroup(x, y, w, h, '앱플레이어 설정')
ld_index_text_id = GUIAddText(x + 0, y + 8, -1, -1, '번호')
ld_index_combo_table = {
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    '10', '11', '12', '13', '14', '15', '16', '17', '18', '19',
    '20', '21', '22', '23', '24', '25', '26', '27', '28', '29',
    '30', '31'
    }
ld_index_combo_id = GUIAddCombo(x + 35, y + 8, -1, -1, ld_index_combo_table, nil, 'ld_index_combo')

ld_app_text_id = GUIAddText(x + 110, y + 8, -1, -1, '앱패키지')
ld_app_edit_id = GUIAddEdit(x + 165, y + 8, 180, -1, '앱패키지이름', nil, 'ld_app_edit')


-- # 앱플레이어 제어 기능 그룹
-- 앱플레이어 실행 함수
function ld_launch()
    runApp(string.format('%s launch --index %s', ld_path_edit, ld_index_combo))
end

-- 앱플레이어 종료 함수
function ld_quit()
    runApp(string.format('%s quit --index %s', ld_path_edit, ld_index_combo))
end

-- 앱플레이어 재실행 함수
function ld_reboot()
    runApp(string.format('%s reboot --index %s', ld_path_edit, ld_index_combo))
end

-- 앱플레이어 실행+앱실행 함수
function ld_launchex()
    runApp(string.format('%s launchex --index %s --packagename %s', ld_path_edit, ld_index_combo, ld_app_edit))
end

-- 앱플레이어 앱실행 함수
function ld_runapp()
    runApp(string.format('%s runapp --index %s --packagename %s', ld_path_edit, ld_index_combo, ld_app_edit))
end

-- 앱플레이어 앱종료 함수
function ld_killapp()
    runApp(string.format('%s killapp --index %s --packagename %s', ld_path_edit, ld_index_combo, ld_app_edit))
end

x, y, w, h = 5, 110, 350, 55
GUIAddGroup(x, y, w, h, '앱플레이어 제어 테스트')
ld_launch_btn_id = GUIAddButton(x - 5, y + 8, 90, -1, 'LD 시작', 'ld_launch')
ld_quit_btn_id = GUIAddButton(x + 85, y + 8, 90, -1, 'LD 종료', 'ld_quit')
ld_reboot_btn_id = GUIAddButton(x + 175, y + 8, 90, -1, 'LD 재시작', 'ld_reboot')
ld_launchex_btn_id = GUIAddButton(x + 265, y + 8, 90, -1, '시작+앱실행', 'ld_launchex')
ld_runapp_btn_id = GUIAddButton(x - 5, y + 34, 90, -1, '앱실행', 'ld_runapp')
ld_killapp_btn_id = GUIAddButton(x + 85, y + 34, 90, -1, '앱종료', 'ld_killapp')


-- # 앱플레이어 자동실행 옵션 그룹
function ld_toggle_autorun()
    if ld_autorun_check == 0 then
        GUIItemEnable(ld_autoapp_check_id, false)
    elseif ld_autorun_check == 1 then
        GUIItemEnable(ld_autoapp_check_id, true)
    end
end

x, y, w, h = 5, 190, 150, 45
GUIAddGroup(x, y, w, h, '앱플레이어 자동실행 옵션')
ld_autorun_check_id = GUIAddCheck(x + 0, y + 8, -1, -1, '앱플레이어 자동실행', 'ld_toggle_autorun', 'ld_autorun_check')
ld_autoapp_check_id = GUIAddCheck(x + 0, y + 30, -1, -1, '지정 앱 자동실행', nil, 'ld_autoapp_check')


-- GUI 생성
GUIShow()
GUISetCurTab(ldplayer_gui)


-- 앱플레이어 자동 실행 옵션 실행
if ld_autorun_check == 1 then
    if ld_autoapp_check == 1 then
        ld_launchex()
    else
        ld_launch()
    end
else
    GUIItemEnable(ld_autoapp_check_id, false)
end

 

 

반응형

댓글