by Noitalommi_2 » 01 Apr 2024, 11:14
@Helmut2
Hmm, mit der Fehlermeldung "Error: Failed" von MouseGetPos kann nicht so richtig etwas anfangen.
Habe MouseGetPos mal eine Etage tiefer gepackt, so das es nur aktiv ist wenn auch das Scribble Papers Fenster aktiv ist, vielleicht hilft es ja.
Code: Select all
#Requires AutoHotkey 2.0
#SingleInstance
;F1::ListLines
F4::ExitApp
SetTimer(ScribblePapers, 50)
Hotkey("LButton", (*)=> false, "off") ; erstellt Hotkey LButton
ScribblePapers() {
static WinTitle := "ahk_exe ScPapers.exe"
, Control := "TRxRichEdit1"
, Browser := { Edge:"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe",
Chrome:"C:\Program Files\Google\Chrome\Application\chrome.exe",
FireFox1:"D:\Programme\Firefox_Ebay\Firefox\firefox.exe", ; Pfad des Browsers FireFox1
FireFox2:"",
FireFox3:"",
FireFox4:""}
, Loader := { FireFox1:"D:\Programme\Firefox_Ebay\Firefox_Ebay.exe", ; Pfad des Loaders für Browser FireFox1
FireFox2:"",
FireFox3:"",
FireFox4:""}
, Wait := 250 ; Sleep-Dauer nach SendInput in ms
, LineMin := 20, LineMax := 500 ; erlaubte Zeilenlänge, min 20 Zeichen max 500 Zeichen
, LButton := false
, wParam := Buffer(4), lParam := Buffer(4)
if WinActive(WinTitle) { ; Wenn ScribblePapers-Fenster aktiv
MouseGetPos &OutputVarX, &OutputVarY, &OutputVarWin, &OutputVarControl
if OutputVarControl = Control && A_Cursor = "Unknown" && !LButton { ; Wenn Cursor über RichEdit-Fenster, Cursor-Art nicht Standard und Hotkey LButton nicht aktiv.
Hotkey("LButton", "on"), LButton := true ; deaktiviert linke Maustaste
try
ControlGetPos &OutX, &OutY, &OutWidth, &OutHeight, Control, WinTitle ; Verucht X-Posisiton des RichEdit-Fensters zu ermitteln
catch TargetError
{
Hotkey("LButton", "off"), LButton := false
Sleep 250
return ; bei Fehler Abbruch
}
if ClickWait() { ; ruft ClickWait-Funktion auf
MouseGetPos &OutputVarX, &OutputVarY
MouseClick ,OutX+10, OutputVarY ; Klickt auf die leere Spalte vor der Zeile, um die komplette Zeile zu markieren.
MouseMove OutputVarX, OutputVarY ; Cursor zurück zur ursprünglichen Position.
Sleep 100
SendMessage(0xB0, wParam, lParam, Control, WinTitle) ; EM_GETSEL - Fragt die Anfangs- und Endposition der Auswahl ab.
; Wenn etwas makiert ist, dass größer als LineMin und kleiner als LineMax ist. LineMin sollte min 1 sein.
if (l := NumGet(lParam, "UInt") - w := NumGet(wParam, "UInt")) > LineMin && l-w < LineMax {
Text := EditGetLine(EditGetCurrentLine(Control, WinTitle), Control, WinTitle)
ControlSend("{Home}", Control, WinTitle)
if InStr(Text, "http") = 1 && Pos2 := InStr(Text, "||",,, 2) { ; Wenn Zeile mit "http" beginnt und 2x2 Senkrechtstriche als Separatoren enthält.
Text := SubStr(Text, 1, Pos2-1) ; Ermittelt Link und Browsername.
Pos1 := InStr(Text, "||")
Link := SubStr(Text, 1, Pos1-1)
Name := SubStr(Text, Pos1+2, Pos1-1)
if !Browser.HasOwnProp(Name) ; Wenn Browsername nicht bekannt
Hotkey("LButton", "off"), MsgBox("Browser `"" Name " `"unbekannt.",, 262160), ExitApp()
if !FileExist(Browser.%Name%) ; Wenn Browserpfad nicht existiert.
Hotkey("LButton", "off"), MsgBox("Browserpfad existiert nicht. `n`n" "`"" Browser.%Name% "`"",, 262160), ExitApp()
ClipSaved := ClipboardAll() ; Sichert Inhalt des Clipboards
A_Clipboard := "", A_Clipboard := Link, ClipWait(2)
Run(Loader.HasOwnProp(Name) ? Loader.%Name% : Browser.%Name%)
WinWait("ahk_exe" Browser.%Name%)
WinWaitActive("ahk_exe" Browser.%Name%)
Sleep(Wait)
SendInput("^l"), Sleep(Wait) ; Fokus auf Adressleiste
SendInput("^v"), Sleep(Wait) ; paste
SendInput("{Enter}")
A_Clipboard := "", A_Clipboard := ClipSaved, ClipWait(2), ClipSaved := "" ; Clipboard wiederherstellen
WinActivate(WinTitle) ; Gibt den Fokus zurück zu Scribble Papers.
WinWaitActive(WinTitle)
}
else { ; Wenn Zeile nicht mit "http" beginnt und nicht 2x2 Senkrechtstriche als Separatoren enthält.
Click() ; Klickt Hyperlink
WinWaitActive("A")
WinActivate(WinTitle)
WinWaitActive(WinTitle)
}
}
}
}
else if LButton
Hotkey("LButton", "off"), LButton := false
}
ClickWait() { ; Wartet darauf, dass die linke Maustaste physisch gedrückt wird.
while A_Cursor = "Unknown" && OutputVarControl = Control { ; Cursor-Art nicht Standard und Cursor über RichEdit-Fenster.
Sleep 50
MouseGetPos &OutputVarX, &OutputVarY, &OutputVarWin, &OutputVarControl
if GetKeyState("LButton", "P") {
return 1
}
}
return 0
}
}
[mention]Helmut2[/mention]
Hmm, mit der Fehlermeldung "Error: Failed" von MouseGetPos kann nicht so richtig etwas anfangen. :think:
Habe MouseGetPos mal eine Etage tiefer gepackt, so das es nur aktiv ist wenn auch das Scribble Papers Fenster aktiv ist, vielleicht hilft es ja.
[code]
#Requires AutoHotkey 2.0
#SingleInstance
;F1::ListLines
F4::ExitApp
SetTimer(ScribblePapers, 50)
Hotkey("LButton", (*)=> false, "off") ; erstellt Hotkey LButton
ScribblePapers() {
static WinTitle := "ahk_exe ScPapers.exe"
, Control := "TRxRichEdit1"
, Browser := { Edge:"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe",
Chrome:"C:\Program Files\Google\Chrome\Application\chrome.exe",
FireFox1:"D:\Programme\Firefox_Ebay\Firefox\firefox.exe", ; Pfad des Browsers FireFox1
FireFox2:"",
FireFox3:"",
FireFox4:""}
, Loader := { FireFox1:"D:\Programme\Firefox_Ebay\Firefox_Ebay.exe", ; Pfad des Loaders für Browser FireFox1
FireFox2:"",
FireFox3:"",
FireFox4:""}
, Wait := 250 ; Sleep-Dauer nach SendInput in ms
, LineMin := 20, LineMax := 500 ; erlaubte Zeilenlänge, min 20 Zeichen max 500 Zeichen
, LButton := false
, wParam := Buffer(4), lParam := Buffer(4)
if WinActive(WinTitle) { ; Wenn ScribblePapers-Fenster aktiv
MouseGetPos &OutputVarX, &OutputVarY, &OutputVarWin, &OutputVarControl
if OutputVarControl = Control && A_Cursor = "Unknown" && !LButton { ; Wenn Cursor über RichEdit-Fenster, Cursor-Art nicht Standard und Hotkey LButton nicht aktiv.
Hotkey("LButton", "on"), LButton := true ; deaktiviert linke Maustaste
try
ControlGetPos &OutX, &OutY, &OutWidth, &OutHeight, Control, WinTitle ; Verucht X-Posisiton des RichEdit-Fensters zu ermitteln
catch TargetError
{
Hotkey("LButton", "off"), LButton := false
Sleep 250
return ; bei Fehler Abbruch
}
if ClickWait() { ; ruft ClickWait-Funktion auf
MouseGetPos &OutputVarX, &OutputVarY
MouseClick ,OutX+10, OutputVarY ; Klickt auf die leere Spalte vor der Zeile, um die komplette Zeile zu markieren.
MouseMove OutputVarX, OutputVarY ; Cursor zurück zur ursprünglichen Position.
Sleep 100
SendMessage(0xB0, wParam, lParam, Control, WinTitle) ; EM_GETSEL - Fragt die Anfangs- und Endposition der Auswahl ab.
; Wenn etwas makiert ist, dass größer als LineMin und kleiner als LineMax ist. LineMin sollte min 1 sein.
if (l := NumGet(lParam, "UInt") - w := NumGet(wParam, "UInt")) > LineMin && l-w < LineMax {
Text := EditGetLine(EditGetCurrentLine(Control, WinTitle), Control, WinTitle)
ControlSend("{Home}", Control, WinTitle)
if InStr(Text, "http") = 1 && Pos2 := InStr(Text, "||",,, 2) { ; Wenn Zeile mit "http" beginnt und 2x2 Senkrechtstriche als Separatoren enthält.
Text := SubStr(Text, 1, Pos2-1) ; Ermittelt Link und Browsername.
Pos1 := InStr(Text, "||")
Link := SubStr(Text, 1, Pos1-1)
Name := SubStr(Text, Pos1+2, Pos1-1)
if !Browser.HasOwnProp(Name) ; Wenn Browsername nicht bekannt
Hotkey("LButton", "off"), MsgBox("Browser `"" Name " `"unbekannt.",, 262160), ExitApp()
if !FileExist(Browser.%Name%) ; Wenn Browserpfad nicht existiert.
Hotkey("LButton", "off"), MsgBox("Browserpfad existiert nicht. `n`n" "`"" Browser.%Name% "`"",, 262160), ExitApp()
ClipSaved := ClipboardAll() ; Sichert Inhalt des Clipboards
A_Clipboard := "", A_Clipboard := Link, ClipWait(2)
Run(Loader.HasOwnProp(Name) ? Loader.%Name% : Browser.%Name%)
WinWait("ahk_exe" Browser.%Name%)
WinWaitActive("ahk_exe" Browser.%Name%)
Sleep(Wait)
SendInput("^l"), Sleep(Wait) ; Fokus auf Adressleiste
SendInput("^v"), Sleep(Wait) ; paste
SendInput("{Enter}")
A_Clipboard := "", A_Clipboard := ClipSaved, ClipWait(2), ClipSaved := "" ; Clipboard wiederherstellen
WinActivate(WinTitle) ; Gibt den Fokus zurück zu Scribble Papers.
WinWaitActive(WinTitle)
}
else { ; Wenn Zeile nicht mit "http" beginnt und nicht 2x2 Senkrechtstriche als Separatoren enthält.
Click() ; Klickt Hyperlink
WinWaitActive("A")
WinActivate(WinTitle)
WinWaitActive(WinTitle)
}
}
}
}
else if LButton
Hotkey("LButton", "off"), LButton := false
}
ClickWait() { ; Wartet darauf, dass die linke Maustaste physisch gedrückt wird.
while A_Cursor = "Unknown" && OutputVarControl = Control { ; Cursor-Art nicht Standard und Cursor über RichEdit-Fenster.
Sleep 50
MouseGetPos &OutputVarX, &OutputVarY, &OutputVarWin, &OutputVarControl
if GetKeyState("LButton", "P") {
return 1
}
}
return 0
}
}
[/code]