Critical Error: Invalid memory read/write Topic is solved

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

KHA
Posts: 403
Joined: 21 Aug 2018, 11:11

Re: Critical Error: Invalid memory read/write

27 Sep 2020, 07:57

@just me

Ich bin ein großer Fan von deine Erklärungen und Tutorials, danke nochmal für die super Erklärung, habe eingebaut und Dateien konnte ich Problemlos kopieren.

Nachdem ich 10 verschiedene Textstellen aus verschiedene quellen (url, Dateien, Dateiname, Textpassagen aus wikipedia, Text aus Editor und Word) kopiert habe, trat der Fehler wieder auf
CriEro.png
CriEro.png (14.97 KiB) Viewed 1121 times
@haichen
werde jetzt auf 100 erhöhen
just me
Posts: 9451
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Critical Error: Invalid memory read/write  Topic is solved

28 Sep 2020, 04:41

Moin,

schade! Dann kommt jetzt mein letzter Versuch: Wir holen uns den Text über die API-Funktionen. Ich glaube zwar eher nicht, dass das hilft, aber man weiß ja nie. Der AHK-Sourcecode enthält jedenfalls einige Hinweise auf immer mal wieder aufgetretene Probleme mit dem Clipboard.

Code: Select all

ZwischenablageG(Type) {
   If !(Type = 1) Or !Clipboard_HasText()
      Return
   ClipAlt := Clipboard_GetText()
   If (ClipAlt = "")
      Return
   ...
}
; -------------------------------------------
Clipboard_HasText() {
   Static CF_NATIVETEXT := A_IsUnicode ? 13 : 1 ; CF_UNICODETEXT = 13, CF_TEXT = 1
   Return DllCall("IsClipboardFormatAvailable", "UInt", CF_NATIVETEXT, "UInt")
}
; -------------------------------------------
Clipboard_GetText() {
   Static CF_NATIVETEXT := A_IsUnicode ? 13 : 1 ; CF_UNICODETEXT = 13, CF_TEXT = 1
   ClipText := ""
   If DllCall("OpenClipboard", "Ptr", 0, "UInt") {
      If (HMEM := DllCall("GetClipboardData", "UInt", CF_NATIVETEXT, "UPtr")) {
         Chrs := DllCall("GlobalSize", "Ptr", HMEM, "Ptr") >> !!A_IsUnicode
         If (PMEM := DllCall("GlobalLock", "Ptr", HMEM, "UPtr")) {
            ClipText := StrGet(PMEM, Chrs)
            DllCall("GlobalUnlock", "Ptr", HMEM)
         }
      }
      DllCall("CloseClipboard")
   }
   Return ClipText
}
User avatar
haichen
Posts: 631
Joined: 09 Feb 2014, 08:24

Re: Critical Error: Invalid memory read/write

28 Sep 2020, 07:00

Hallo just me,
ich habe mit dem Clipboard_GetText() und ClipBoard rumgespielt. Dabei habe ich beim Kopieren in der Schleife immer mal woanders hingeklickt.
Mit einer Clipboardzuweisung kam es immer dann zu Abstürzen wenn ich SendInput anstelle von Send verwendet habe. Ein Sleep nach der Zuweisung hat die Abstürze verhindert.
Deine Funktion ist nie abgestürzt!

Code: Select all

#Persistent
#NoEnv
SetBatchLines, -1

;stürzt ab mit SendInput
;ein sleep verhindert abstürze

;stürzt mit send nicht ab:

o::
i:=0
loop, 1000
{
	SendInput, +{Right}^c
	x:=Clipboard
        ;sleep, 10
	tooltip % i++  " " x
}
return

;stürzt nicht ab:
p::
i:=0
loop, 1000
{
	Send, +{right}^c
	x:=Clipboard_GetText()
	tooltip % i++ " " x
}
return


return
Clipboard_GetText() {
   Static CF_NATIVETEXT := A_IsUnicode ? 13 : 1 ; CF_UNICODETEXT = 13, CF_TEXT = 1
   ClipText := ""
   If DllCall("OpenClipboard", "Ptr", 0, "UInt") {
      If (HMEM := DllCall("GetClipboardData", "UInt", CF_NATIVETEXT, "UPtr")) {
         Chrs := DllCall("GlobalSize", "Ptr", HMEM, "Ptr") >> !!A_IsUnicode
         If (PMEM := DllCall("GlobalLock", "Ptr", HMEM, "UPtr")) {
            ClipText := StrGet(PMEM, Chrs)
            DllCall("GlobalUnlock", "Ptr", HMEM)
         }
      }
      DllCall("CloseClipboard")
   }
   Return ClipText
}
just me
Posts: 9451
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Critical Error: Invalid memory read/write

28 Sep 2020, 08:03

Moin haichen,

danke für's Testen. Schaun wir mal, ob KHA's Probleme damit auch verschwinden.

:thumbup:
KHA
Posts: 403
Joined: 21 Aug 2018, 11:11

Re: Critical Error: Invalid memory read/write

28 Sep 2020, 09:39

Hallo ihr beiden, vielen Dank für die Arbeit und Mühe!
Habe es eingebaut, bis jetzt funktioniert es Tadellos ohne abstürze. :)
Werde jetzt damit ein paar Tage arbeiten, dann habe ich die Gewissheit
KHA
Posts: 403
Joined: 21 Aug 2018, 11:11

Re: Critical Error: Invalid memory read/write

05 Oct 2020, 09:49

Nutze jetzt eine Woche lang, 0 abstürze. Nochmal vielen Dank

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 60 guests