click a button, open a folder, place and size

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
sbrady19
Posts: 348
Joined: 12 Apr 2018, 05:22
Location: Central Florida
Contact:

click a button, open a folder, place and size

Post by sbrady19 » 09 Dec 2023, 12:35

I am converting my old v1 scripts to v2
I need to click a button, have it open a folder, then place and size it
here is how I did it in v1
can you help me conform this to v2

Code: Select all

buttonnewswin:

;focus folder
run, "\\folder.xxx.local\Focus Packages"
sleep 1000
WinMove, \\folder.xxx.local\Focus Packages, , 69,  185, 700,  396, , 
sleep 1000

User avatar
boiler
Posts: 17710
Joined: 21 Dec 2014, 02:44

Re: click a button, open a folder, place and size

Post by boiler » 09 Dec 2023, 13:20

Here's a translation of what you showed. It's not a complete script since you didn't show what directs the code to the label in your script.

Code: Select all

buttonnewswin() {
	Run '\\folder.xxx.local\Focus Packages'
	Sleep 1000
	WinMove 69, 185, 700, 396, '\\folder.xxx.local\Focus Packages'
	Sleep 1000
}

sbrady19
Posts: 348
Joined: 12 Apr 2018, 05:22
Location: Central Florida
Contact:

Re: click a button, open a folder, place and size

Post by sbrady19 » 09 Dec 2023, 15:55

my original code is from AHK v1 which works, I dont understand the syntax in the v2 documentation

error says left most character (in the WinMove line) is illegal in an expression

User avatar
boiler
Posts: 17710
Joined: 21 Dec 2014, 02:44

Re: click a button, open a folder, place and size

Post by boiler » 09 Dec 2023, 16:31

sbrady19 wrote: my original code is from AHK v1 which works, I dont understand the syntax in the v2 documentation
No, as I said, what you posted does not work as you described. It does not respond to a button press, which is what you said it did. It executes immediately up running the script. So if you want this to do the same, then run the following version:

Code: Select all

#Requires AutoHotkey v2.0

buttonnewswin() 

buttonnewswin() {
	Run '\\folder.xxx.local\Focus Packages'
	Sleep 1000
	WinMove 69, 185, 700, 396, '\\folder.xxx.local\Focus Packages'
	Sleep 1000
}
If you want it to respond to a button press, then you need to have it do that. If your original script did that, I would have added it to this script. I can add that if you describe it which button you mean. A button in a GUI that you didn't show? A mouse button hotkey that you didn't show? Some other kind of button?

sbrady19 wrote: error says left most character (in the WinMove line) is illegal in an expression
It says that because you ran it with v1, not v2. The #Requires line like in the version above will prevent it from trying to run it with v1.

sbrady19
Posts: 348
Joined: 12 Apr 2018, 05:22
Location: Central Florida
Contact:

Re: click a button, open a folder, place and size

Post by sbrady19 » 09 Dec 2023, 18:31

The original script is for v1.........v2 now is so different, I need help
the button is called "news win", I click that button and it opens a folder as shown above, and places and sizes the window.

User avatar
boiler
Posts: 17710
Joined: 21 Dec 2014, 02:44

Re: click a button, open a folder, place and size

Post by boiler » 09 Dec 2023, 20:26

What do you mean the button is called that? What button? A button on a GUI? If you have another part of the v1 script that creates a GUI, you can’t just leave that the way it was in the v1 version. Why are you only showing this one part of the script since it would all have to be translated to v2?

sbrady19
Posts: 348
Joined: 12 Apr 2018, 05:22
Location: Central Florida
Contact:

Re: click a button, open a folder, place and size

Post by sbrady19 » 10 Dec 2023, 06:18

Im not a coder, I do audio for television. I would like to convert my old scripts to the new v2. Clicking a button on a Gui is different in v2 than how things were done in v1. I watched a video, its very different. My code above is from v1. So I thought I need help writing new code that works in v2. here is my GUI, click a button and it opens a certain folder and places and sizes it........so easy in v1.

https://www.dropbox.com/scl/fi/v3ag5gihc7zo9ht1fs8r0/GUIv2.png?rlkey=k6ryhgcdbtas9ysgf7z743q13&dl=0


here is a YouTube on AHKv2
https://youtu.be/QW7RgCHfA4Q?si=a7SiQ8JMWsEJdVUK

User avatar
boiler
Posts: 17710
Joined: 21 Dec 2014, 02:44

Re: click a button, open a folder, place and size

Post by boiler » 10 Dec 2023, 06:40

Have you already converted all of the GUI definition to v2? I would hope the video would have showed you how to make a click event for a button execute a particular function, like this:

Code: Select all

#Requires AutoHotkey v2.0

MyGui := Gui()
MyGui.Add('Button', 'w140', 'News Win').OnEvent('Click', buttonnewswin)
MyGui.Show

buttonnewswin(*) {
	MsgBox 'This is News Win!'
}

Post Reply

Return to “Ask for Help (v2)”