autoit AHK and what have you

Discussion & Support for xplorer² professional

Moderators: fgagnon, nikos, Site Mods

User avatar
nikos
Site Admin
Site Admin
Posts: 14628
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

autoit AHK and what have you

Post by nikos » 2018 Feb 05, 13:05

anyone using external macros like AHK to manage xplorer2 I would love to hear from you what are you doing with such scripts and how do you feel about the new macro engine in v4 beta?

User avatar
FrizzleFry
Platinum Member
Platinum Member
Posts: 1162
Joined: 2005 Oct 16, 19:09

Re: autoit AHK and what have you

Post by FrizzleFry » 2018 Feb 06, 20:44

How can I do new tab in opposite pane (Alt+Ctrl Insert) with a macro?

I have tried the SENDKEY command, for example:

SENDKEY alt+ctrl+insert

and other keys but I always get an error 2, last argument (empty)

Well I got it to work with SENDKEY but I had to add a command before the SENDKEY for the macro to work

SENDKEY alt+ctrl+insert

always generates an error 2

GETFOCUS
SENDKEY alt+ctrl+insert

works. Is GETFOCUS required for SENDKEY to work?

User avatar
FrizzleFry
Platinum Member
Platinum Member
Posts: 1162
Joined: 2005 Oct 16, 19:09

Re: autoit AHK and what have you

Post by FrizzleFry » 2018 Feb 06, 21:46

Is there a way to get the path from the active tab with macros?

User avatar
nikos
Site Admin
Site Admin
Posts: 14628
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: autoit AHK and what have you

Post by nikos » 2018 Feb 07, 05:29

keep in mind that most commands require a window to act upon, that's why sendkey on itself doesn't work, but does so preceded by getfocus

as for the tabs, I think instead of going there for the current folder, just jump to the addressbar:
FINDWND address
FINDCLASS combobox
GETTEXT $1 # current full path in variable 1

User avatar
nikos
Site Admin
Site Admin
Posts: 14628
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: autoit AHK and what have you

Post by nikos » 2018 Feb 07, 05:59

ps to find controls on the main window a tool like spy++ is required to see the window layers. This pic should explain why we searched for "address" then "combobox":

click to see the flippin image
(I can't manage to put it in here straight!?)

User avatar
nikos
Site Admin
Site Admin
Posts: 14628
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: autoit AHK and what have you

Post by nikos » 2018 Feb 07, 07:20

here is another way to get the active path, just demonstrating the possibilities!

Code: Select all

getfocus
sendkey back # up folder
COMMAND "copy names" 
input 0 # import clipboard!
Message $0
getfocus
sendkey enter # go back in the original folder

User avatar
FrizzleFry
Platinum Member
Platinum Member
Posts: 1162
Joined: 2005 Oct 16, 19:09

Re: autoit AHK and what have you

Post by FrizzleFry » 2018 Feb 07, 20:02

How about getting just the name of the folder in the active tab. Not the full path name just the name (like the $N token).

Also can you get the content of any column in a pane?

User avatar
nikos
Site Admin
Site Admin
Posts: 14628
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: autoit AHK and what have you

Post by nikos » 2018 Feb 08, 06:15

you are stretching the system, no? :)
basically you have to use your imagination and the available commands in xplorer2. Here's what I came up with

folder name
1a. If the folder doesn't have spaces, jump to the addressbar, sendkey END, sendkey ctrl+shift+back, sendkey ctrl+c, input $0

1b. if the folder name has spaces, select 1 item, then simulate a TOOLS > COMMAND SCRIPT command, set the template to $C, click preview button, then copy out the first line from the preview window (send the keys HOME, SHIFT+END, Ctrl+c), then ESC to dismiss the dialog

to copy out a particular column
click on the header to sort by it, then sendkey ctrl+alt+p, then input 0 to import clipboard

unfortunately the header control doesn't respond to CLICKDEF instruction on its columns as it should, I don't know why, so you cannot select a desired column with a macro, unless it is one of those appearing in the arrangeby menu

perhaps in the future I will add commands that manipulate strings to make operations like this easier

User avatar
nikos
Site Admin
Site Admin
Posts: 14628
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: autoit AHK and what have you

Post by nikos » 2018 Feb 08, 07:27

I added the command CHOPSTR that breaks up a string in parts using a separating character like \ or \t (tab), and then lets you pick the n-th string of the array

e.g. to get the last part of the path (folder name) you would do

Code: Select all

CHOPSTR \-1
(-1 means last)

to get the second column of the selected item you would do

Code: Select all

getfocus
getsel $1
getitemtext $1
chopstr \t2

User avatar
FrizzleFry
Platinum Member
Platinum Member
Posts: 1162
Joined: 2005 Oct 16, 19:09

Re: autoit AHK and what have you

Post by FrizzleFry » 2018 Feb 08, 18:08

Good. String manipulation will be very useful.

RE: stretching the system

Well, you did ask if we could use macros to handle some of what we use scripts to do :)

The AHK script I am trying to replace brings up the add folder groups dialog and inserts the current folder name plus top or bottom depending on which pane is active. Getting the name of the current folder is the only thing I'm missing but CHOPSTR will take care of that.

I do like your suggestion of using the command script dialog to extract token info but it would be nicer to have those tokens directly available from macros.

Another suggestion is to make the macro properties dialog larger. The current dialog is fine for very small macros but you only get three lines. I have been writing macros in a text editor and then copy&pasting to the properties dialog.

It seems the vars ($1-$9) are initialized to 0 (zero). Is that a valid assumption? I do not see a way to set a var to 0.

I really do not like that you have to run the macro to save it. Saving and assigning a name to it should save it!

User avatar
nikos
Site Admin
Site Admin
Posts: 14628
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: autoit AHK and what have you

Post by nikos » 2018 Feb 09, 05:44

don't get me wrong, I like you stretching the system.

for editing the macro, your best bet is to run it first, then it becomes available as the "last macro" and you will find the code in NEW MACRO command. For minor edits the 3 lines in ORGANIZE dialog should be bearable

As for saving without running, I recommend clicking on DEBUG then cancelling at the first instruction

User avatar
FrizzleFry
Platinum Member
Platinum Member
Posts: 1162
Joined: 2005 Oct 16, 19:09

Re: autoit AHK and what have you

Post by FrizzleFry » 2018 Feb 09, 12:06

I am trying chopstr with the latest beta but it is not working

# get path of active folder
findwnd address
findclass combobox
gettext $2
pop $2
chopstr /-1
store $2
message $2

it keeps failing with an error 1

did you change what findwnd 0 returns?

User avatar
nikos
Site Admin
Site Admin
Posts: 14628
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: autoit AHK and what have you

Post by nikos » 2018 Feb 09, 12:50

the path separator character is \ so you need chopstr \-1

User avatar
FrizzleFry
Platinum Member
Platinum Member
Posts: 1162
Joined: 2005 Oct 16, 19:09

Re: autoit AHK and what have you

Post by FrizzleFry » 2018 Feb 09, 16:20

yeah, it was the wrong slash.

I am doing this to determine which pane is active:

# get active dialog
#findwnd 0
getfocus
store $1

# determine if active pane is left/top or right/bottom
findwnd "left pane"
equal $1
jumpok leftpane
findwnd "right pane"
equal $1
jumpok rightpane

In the previous beta, either findwnd 0 or getfocus worked but findwnd 0 does not seem to work in this beta (10). It looks like findwnd 0 is returning info for the x2 window rather the active dialog.

findwnd 0
hw4F081A class=ATL:ExplorerFrame, ID=-2135783104 [xplorer² [main] - macros @ D:\ # [test @ D:\]]

findwnd "left pane"
hw340900 class=ATL:BrowserListView, ID=59648 [Left pane settings]

findwnd "right pane"
hw1307DE class=ATL:BrowserListView, ID=59649 [Right pane settings]

Well I installed the previous two betas and findwnd 0 returned the same as in the current beta. So I do not know why findwnd 0 seemed to work at some time. getfocus does work so I'll use that.

User avatar
nikos
Site Admin
Site Admin
Posts: 14628
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: autoit AHK and what have you

Post by nikos » 2018 Feb 09, 18:00

findwnd 0 returns the "outer" (frame) window, which is either a dialog or the main xplorer2 window, whereas getfocus most likely will return the view, where you last clicked anyway. Here's another way for testing which pane is active

Code: Select all

pop "left"
store $2
getfocus
gettext $1
pop $1
chopstr " 1"
equal $2
jumperr right
message "left active"
exit

label right
message "right active"

Post Reply