Page 2 of 2

Re: Is is possible to use auto copy/paste?

Posted: 22 Jul 2018, 17:50
by Divvy
I also use Win10 Win64
And same AutoHotkey version

I have restarted my computer but got same errors again when I run the script.

Please don't give up yet, I know you can do it :)

Re: Is is possible to use auto copy/paste?

Posted: 22 Jul 2018, 18:14
by GEV
I only get this (and it is no error) if I add

Code: Select all

ListLines  ; displays the script lines most recently executed
before the first return in the code.

Re: Is is possible to use auto copy/paste?

Posted: 22 Jul 2018, 18:20
by Divvy
That's weird working for you and not for me, we both are using the same software versions.
What could be? No idea?

Maybe an alternative for the letters/numbers selection?

Can someone help us, please? :)

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 01:49
by GEV
Try adding this

Code: Select all

ListLines off
WinHide %A_ScriptFullPath% - AutoHotkey v%A_AhkVersion%
before the first return.
It's not the perfect solution, but at least you don't get disturbed each time you start the script.

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 02:26
by Divvy
Like this?

Code: Select all

#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%

WinTitle := "Edit Model ‹ Agency — WordPress - Google Chrome:"

Keys := ["#","1","2","3","4","5","6","7","8","9","0"]
for each, key in Keys
	Hotkey, !+%key%, Create_LV_Key, On

Loop, 26
	Hotkey, % "!+" Chr(A_Index + 64), Create_LV_Key, On
ListLines off
WinHide %A_ScriptFullPath% - AutoHotkey v%A_AhkVersion%
return

Create_LV_Key:
key := SubStr(A_ThisHotkey, 0)
Gui, destroy
Index := ""
text := ""
Loop, Read, linkslist.txt
{
	If ((StrLen(A_LoopReadLine) = 1) && (A_LoopReadLine == key))
	{
		Index := A_Index
			break
	}
}
Loop, Read, linkslist.txt
{
	If (A_Index <= Index)
		continue
	If (A_LoopReadLine = "")
		continue
	If (StrLen(A_LoopReadLine) = 1) && (A_Index > Index)
		break
	text .= A_LoopReadLine "`r`n"
}

Gui, Add, ListView, r10 w400 gMyListView, domain|URL|notes

Loop, parse, text, `r`n
{
	If (A_LoopField = "")
		continue
	If !InStr(A_LoopField, "://")
		continue
	If (SubStr(A_LoopField, 1, 2) = "- ")
	{
		domain := "- " . StrSplit(A_LoopField," ").2
		URL := StrSplit(A_LoopField," ").3
	}
	else
	{
		domain := StrSplit(A_LoopField," ").1
		URL := StrSplit(A_LoopField," ").2
	}
	If InStr(A_LoopField, "(")
	{
		note := "(" . StrSplit(A_LoopField,"(").2
		LV_Add("", domain, URL, note)
	}
	else
		LV_Add("", domain, URL)
}
LV_ModifyCol()  ; auto-size each column to fit its contents.
Gui, Add, Button, Default, Send
Gui, Show,, Send domain+URL  %key%
return

MyListView:
	If (A_GuiEvent = "DoubleClick")
	{
		LV_GetText(domain, A_EventInfo, 1)
		If SubStr(domain, 1, 2) = "- "
			domain := SubStr(domain, 3)
		else
			domain := domain
		LV_GetText(URL, A_EventInfo, 2)
		; MsgBox, domain = "%domain%"`nURL = "%URL%"
		WinActivate, %WinTitle%
		WinWaitActive, %WinTitle%
		SendInput, %domain%%A_Tab%%URL%
	}
return

; https://autohotkey.com/docs/commands/ListView.htm#LV_GetNext
ButtonSend:
	RowNumber  = 0
	Loop
	{
		RowNumber  := LV_GetNext(RowNumber)  
		If (!RowNumber )
			Break
		LV_GetText(domain, RowNumber, 1)
		If SubStr(domain, 1, 2) = "- "
			domain := SubStr(domain, 3)
		else
			domain := domain
		LV_GetText(URL, RowNumber, 2)
		; MsgBox, domain = "%domain%"`nURL = "%URL%"
		WinActivate, %WinTitle%
		WinWaitActive, %WinTitle%
		SendInput, %domain%%A_Tab%%URL%
	}
Return

Esc::
GuiClose:
ExitApp
Nothing happens... I still get the same lines when I run the script.

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 02:37
by GEV
What happens if you close this window manually?
Does the script work if you press Alt+Shift+letter afterwards?

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 02:48
by Divvy
If I close the window manually, the same window appears. I can't even see the GUI window.

Screenshot: http://take.ms/uLtwm

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 03:02
by GEV
Try adding
ListLines off
at the very top

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 03:07
by Divvy
If I put in the first line:

Code: Select all

ListLines off
#NoEnv
(...)
I get this:
Script lines most recently executed (oldest first). Press [F5] to refresh. The seconds elapsed between a line and the one after it is in parentheses to the right (if not 0). The bottommost line's elapsed time is the number of seconds since it executed.


Press [F5] to refresh.

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 03:30
by GEV
I can only suppose that your keyboard driver doesn't support such a thing.

Try replacing the whole auto-execute section with

Code: Select all

#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%
ListLines off

WinTitle := "Edit Model ‹ Agency — WordPress - Google Chrome:"

Keys := ["a","b","c","d"] ; ...
for each, key in Keys
	Hotkey, !+%key%, Create_LV_Key, On
return
and if it doesn't work with

Code: Select all

#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%
ListLines off

WinTitle := "Edit Model ‹ Agency — WordPress - Google Chrome:"

!+a::
!+b::
!+c::
!+d:: 
; ...
GoSub, Create_LV_Key
return

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 03:45
by Divvy
1st option:
Script lines most recently executed (oldest first). Press [F5] to refresh. The seconds elapsed between a line and the one after it is in parentheses to the right (if not 0). The bottommost line's elapsed time is the number of seconds since it executed.

---- C:\Users\bestl\Desktop\test.ahk
003: SetWorkingDir,%A_ScriptDir% (1.89)

Press [F5] to refresh.
2nd option:
Script lines most recently executed (oldest first). Press [F5] to refresh. The seconds elapsed between a line and the one after it is in parentheses to the right (if not 0). The bottommost line's elapsed time is the number of seconds since it executed.

---- C:\Users\bestl\Desktop\test.ahk
003: SetWorkingDir,%A_ScriptDir% (1.31)

Press [F5] to refresh.
I'm without luck :(

The previous code was working fine (without the letter selection).
Isn't there any other solution? The drop-down is not possible in GUI?

Btw, thank you for your time by trying to help me, bud!

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 04:10
by GEV
This thread is too long for other users to read.
I would open a new thread and ask if someone could test or improve the code.

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 04:20
by Divvy
Done.

Thank you for everything, GEV! :)

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 08:09
by GEV
Divvy wrote: Isn't there any other solution? The drop-down is not possible in GUI?
Try

Code: Select all

#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%

WinTitle := "Edit Model ‹ Agency — WordPress - Google Chrome:"

Keys := ["#","1","2","3","4","5","6","7","8","9","0"]
for each, key in Keys
	DDL_key .= key "|"
	
Loop, 26
	DDL_key .= Chr(A_Index + 64) "|"
	
DDL_key := SubStr(DDL_key, 1, -1)

Gui, 1:  +ToolWindow +AlwaysOnTop
Gui, 1:  Add, DropDownList, gCreate_LV_Key vkey Choose1,%DDL_key%
Gui, 1:  Show, x0 y0, domains
return

Create_LV_Key:
Gui, 1:  Submit, NoHide
GuiControlGet, key
Gui, 2: destroy
Index := ""
text := ""
Loop, Read, linkslist.txt
{
	If ((StrLen(A_LoopReadLine) = 1) && (A_LoopReadLine == key))
	{
		Index := A_Index
		break
	}
}
Loop, Read, linkslist.txt
{
	If (A_Index <= Index)
		continue
	If (A_LoopReadLine = "")
		continue
	If (StrLen(A_LoopReadLine) = 1) && (A_Index > Index)
		break
	text .= A_LoopReadLine "`r`n"
}
Gui, 2: Add, ListView, vLV r10 w400 gMyListView, domain|URL|notes
Gui, 2: default 
Loop, parse, text, `r`n
{
	If (A_LoopField = "")
		continue
	If !InStr(A_LoopField, "://")
		continue
	If (SubStr(A_LoopField, 1, 2) = "- ")
	{
		domain := "- " . StrSplit(A_LoopField," ").2
		URL := StrSplit(A_LoopField," ").3
	}
	else
	{
		domain := StrSplit(A_LoopField," ").1
		URL := StrSplit(A_LoopField," ").2
	}
	If InStr(A_LoopField, "(")
	{
		note := "(" . StrSplit(A_LoopField,"(").2
		Gui, 2: ListView
		LV_Add("", domain, URL, note)
	}
	else
	{
		Gui, 2: ListView
		LV_Add("", domain, URL)
	}
}
LV_ModifyCol()  ; auto-size each column to fit its contents.
Gui, 2: Add, Button, Default, Send
Gui, 2: Show,, Send domain+URL  %key%
return

MyListView:
	If (A_GuiEvent = "DoubleClick")
	{
		LV_GetText(domain, A_EventInfo, 1)
		If SubStr(domain, 1, 2) = "- "
		domain := SubStr(domain, 3)
		else
		domain := domain
		LV_GetText(URL, A_EventInfo, 2)
		; MsgBox, domain = "%domain%"`nURL = "%URL%"
		WinActivate, %WinTitle%
		WinWaitActive, %WinTitle%
		SendInput, %domain%%A_Tab%%URL%
	}
return

; https://autohotkey.com/docs/commands/ListView.htm#LV_GetNext
ButtonSend:
	RowNumber  = 0
	Loop
	{
		RowNumber  := LV_GetNext(RowNumber)  
		If (!RowNumber )
		Break
		LV_GetText(domain, RowNumber, 1)
		If SubStr(domain, 1, 2) = "- "
		domain := SubStr(domain, 3)
		else
		domain := domain
		LV_GetText(URL, RowNumber, 2)
		MsgBox, domain = "%domain%"`nURL = "%URL%"
		WinActivate, %WinTitle%
		WinWaitActive, %WinTitle%
		SendInput, %domain%%A_Tab%%URL%
	}
Return

Esc::
GuiClose:
ExitApp

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 08:48
by wolf_II
May there be a mistaken ListLines for error?
I made also an attempt in the new thread.

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 13:22
by Divvy
GEV, you're the man !!!

Thank you so much, that option with drop-down menu is much better :)

I only changed this line:

Code: Select all

Keys := ["#","1","2","3","4","5","6","7","8","9","0"]
with this:

Code: Select all

Keys := ["#"]
Because when I select #, is showing the domains starting with numbers too. Is that ok?

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 13:23
by Divvy
wolf_II wrote:May there be a mistaken ListLines for error?
I made also an attempt in the new thread.
Thank you for your time and for trying to help me, mate!

But it seems that everything is fine now :)

Thanks!

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 15:35
by GEV
Divvy wrote:that option with drop-down menu is much better :)
Glad you like it, but unfortunately it doesn't quite work perfectly. You can't send the selected item by clicking on the default button Send or by pressing Enter. :problem:
Maybe someone can fix it.
Divvy wrote:when I select #, is showing the domains starting with numbers too. Is that ok?
If you list the numbers like the other letters (A,B...) in linkslist.txt, they are not shown in the #-domain.

If you ask me, I like the shortcuts solution much better. Using a shortcut is much faster than manually mousing over a menu and clicking an item after searching for it and your attention isn't attracted away from the main window or task.

Re: Is is possible to use auto copy/paste?

Posted: 23 Jul 2018, 16:29
by Divvy
GEV wrote:Glad you like it, but unfortunately it doesn't quite work perfectly. You can't send the selected item by clicking on the default button Send or by pressing Enter. :problem:
Maybe someone can fix it.
Is not a problem for me, double-click is working fine and is faster this way.
GEV wrote:when I select #, is showing the domains starting with numbers too. Is that ok?
If you list the numbers like the other letters (A,B...) in linkslist.txt, they are not shown in the #-domain.
No, I use # for numbers (0-9). So is working fine for me.
GEV wrote:If you ask me, I like the shortcuts solution much better. Using a shortcut is much faster than manually mousing over a menu and clicking an item after searching for it and your attention isn't attracted away from the main window or task.
You're probably right, but unfortunately, that solution didn't work for me because I couldn't open the GUI.

Anyway, I'm happy with your alternative :thumbup:

Re: Is is possible to use auto copy/paste?

Posted: 03 Aug 2018, 13:26
by Divvy
Hello GEV :)

Maybe you can help me again. I'm looking for a little upgrade in the script that you wrote.

1) Regarding the issue of the default button "Send" not working. Do you already know how to solve it? I want to prevent GUI window to disappear when I use double-click.
Or as an alternative, is it possible to GUI window not disappear when I use double-click?

2) Is it possible to increase the size of text for main domains?
If you don't remember my list, here's an example:

maindomain.com
- subdomain.com
- subdomain2.com
- subdomain3.com

maindomain2.com
- subdomainhjgj.com
- subdomainjyt5r7.com
- subdomaingrydry6.com

Thank you!