This is the gui phrase I used in v1, but I want to change it to the v2 version.

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
note_korean
Posts: 2
Joined: 09 May 2024, 03:08

This is the gui phrase I used in v1, but I want to change it to the v2 version.

09 May 2024, 03:13

Code: Select all

buttonfindexcel:
{
	Gui, Submit, nohide
	FileSelectFile, filename,3,%A_ScriptDir% , Open a input Excel file, Excel files(*.xlsx)
	if filename =
		MsgBox, You didn't select a file
	else
		GuiControl, ,a5, %filename%
	return
}
buttonexcelsetting:
{
	coordmode, mouse,screen
	coordmode, pixel,screen
	Gui, Submit, nohide
	aexcel1:= ComObjCreate("Excel.Application")
	where = %a5%
	sleep 50
	aexcel1.Workbooks.open(where)
	sleep 50
	aexcel1.visible:=true
	sleep 50
	return
}
I'm a very newbie.
User avatar
boiler
Posts: 17188
Joined: 21 Dec 2014, 02:44

Re: This is the gui phrase I used in v1, but I want to change it to the v2 version.

09 May 2024, 04:59

You need to show the code where the GUI is created, which apparently you’ve already translated to v2 since you didn’t include that. We don’t even know the name of the GUI object.
note_korean
Posts: 2
Joined: 09 May 2024, 03:08

Re: This is the gui phrase I used in v1, but I want to change it to the v2 version.

13 May 2024, 00:20

I'll think about it a little more and post the exact question.
Thank you for your answer.
User avatar
Seven0528
Posts: 393
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

Re: This is the gui phrase I used in v1, but I want to change it to the v2 version.

13 May 2024, 01:02

 @note_korean
Next time, please provide executable code in your questions.
Answering questions with incomplete code snippets requires a lot of inference, which may not be appropriate. Thank you.
다음부터는 실행 가능한 코드로 질문 글을 작성해 주세요.
코드가 불완전하면 여러모로 유추해야 할 것이 많아 답변드리기에 적절치 않습니다. 감사합니다.

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance Force
myGui := gui()
editPath := myGui.add("Edit", "w400 ReadOnly")
btnFindExcel := myGui.add("Button", "w400", "Find Excel")
btnFindExcel.onEvent("Click", btnFindExcel_Click)
btnExcelSetting := myGui.add("Button", "w400", "Excel Setting")
btnExcelSetting.onEvent("Click", btnExcelSetting_Click)
myGui.show()

btnFindExcel_Click(guiCtrlObj, info)    {
    global editPath
    filename := fileSelect(1|2, A_ScriptDir, "Open a input Excel file, Excel files(*.xlsx)")
    if (filename = "")
        msgBox "You didn't select a file"
    else
        editPath.Text := filename
}

btnExcelSetting_Click(guiCtrlObj, info)    {
    where := editPath.Text
    if (where = "")
        return
    aexcel1 := comObject("Excel.Application")
    sleep 50
    aexcel1.Workbooks.open(where)
    sleep 50
    aexcel1.Visible := true
    sleep 50
}

Code: Select all

#Requires AutoHotkey v1.1
#SingleInstance Force
gui Add, Edit, w400 ReadOnly veditPath
gui Add, Button, w400 ggButtonFindExcel, Find Excel
gui Add, Button, w400 ggButtonExcelSetting, Excel Setting
gui Show
return

gButtonFindExcel:
    fileSelectFile filename, % 1|2, %A_ScriptDir% , Open a input Excel file, Excel files(*.xlsx)
    if (filename = "")
        msgBox You didn't select a file
    else
        guiControl,, editPath, %filename%
    return

gButtonExcelSetting:
    gui Submit, Nohide
    where := editPath
    if (where = "")
        return
    aexcel1 := comObjCreate("Excel.Application")
    sleep 50
    aexcel1.Workbooks.open(where)
    sleep 50
    aexcel1.Visible := true
    sleep 50
    return
Last edited by Seven0528 on 13 May 2024, 01:30, edited 5 times in total.
  • English is not my native language. Please forgive any awkward expressions.
  • 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.
User avatar
Seven0528
Posts: 393
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

Re: This is the gui phrase I used in v1, but I want to change it to the v2 version.

13 May 2024, 01:14

 Gui creation code can be written succinctly as follows.

Code: Select all

btnFindExcel := myGui.add("Button", "w400", "Find Excel")
btnFindExcel.onEvent("Click", btnFindExcel_Click)
btnExcelsetting := myGui.add("Button", "w400", "Excel Setting")
btnExcelsetting.onEvent("Click", btnExcelSetting_Click)

Code: Select all

myGui.add("Button", "w400", "Find Excel").onEvent("Click", btnFindExcel_Click)
myGui.add("Button", "w400", "Excel Setting").onEvent("Click", btnExcelSetting_Click)
  • English is not my native language. Please forgive any awkward expressions.
  • 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: emp00, erann, Noitalommi_2 and 29 guests