Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

printing listlines into a file

  • Please log in to reply
5 replies to this topic
  • Members
  • 4 posts
  • Last active: Sep 30 2010 06:17 AM
  • Joined: 18 Sep 2010
So, i love making little scripts for games with tedious tasks (most rpgs have those in some way) to improve the gaming experience as well as get better at ahk. Currently im "working" on ff8. Biggest problem here is that i can't tab out.

Why is that a problem? I am more or less unable to debug properly. I can't view listvars or listlines :(

Now i was searching for a solution to print my xx last executed lines to a txt, but to my surprise my search yielded no result. So maybe there is some painfully obvious way to go about this, which i haven't found or no one found the need for something like this yet...

Thank you very much in advance.

  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
Look up FileAppend. It adds the given text to a file.
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

  • Members
  • 901 posts
  • Last active: Jul 08 2011 02:12 PM
  • Joined: 29 Feb 2008
From what I've seen, there is unfortunately no way to access the ListLines data directly.

Might my Debugging Library be of use instead? When I'm working in-game, I'll leave DebugViewer open on my secondary monitor. While it doesn't display each line automatically, it can print out each function call (with parameter names+values) and print out variable names+values or just whatever you tell it to print out. It is better than writing to a file because DebugViewer will update in real time (and you can still save the logs if you wish).

  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
I've adapted ListGlobalVars() to return ListLines instead:

    static hwndEdit, pSFW, pSW, bkpSFW, bkpSW
    ListLines Off
    if !hwndEdit
        ; Retrieve the handle of our main window's Edit control:
        dhw := A_DetectHiddenWindows
        DetectHiddenWindows, On
        Process, Exist
        ControlGet, hwndEdit, Hwnd,, Edit1, ahk_class AutoHotkey ahk_pid %ErrorLevel%
        DetectHiddenWindows, %dhw%
        astr := A_IsUnicode ? "astr" : "str"
        hmod := DllCall("GetModuleHandle", "str", "user32.dll")
        ; Get addresses of these two functions:
        pSFW := DllCall("GetProcAddress", "uint", hmod, astr, "SetForegroundWindow")
        pSW := DllCall("GetProcAddress", "uint", hmod, astr, "ShowWindow")
        ; Make them writable:
        DllCall("VirtualProtect", "uint", pSFW, "uint", 8, "uint", 0x40, "uint*", 0)
        DllCall("VirtualProtect", "uint", pSW, "uint", 8, "uint", 0x40, "uint*", 0)
        ; Save initial values of the first 8 bytes:
        bkpSFW := NumGet(pSFW+0, 0, "int64")
        bkpSW := NumGet(pSW+0, 0, "int64")
    ; Overwrite SetForegroundWindow() and ShowWindow() temporarily:
    NumPut(0x0004C200000001B8, pSFW+0, 0, "int64")  ; return TRUE
    NumPut(0x0008C200000001B8, pSW+0, 0, "int64")   ; return TRUE
    ; Dump ListLines into hidden AutoHotkey main window:
    ; Restore SetForegroundWindow() and ShowWindow():
    NumPut(bkpSFW, pSFW+0, 0, "int64")
    NumPut(bkpSW, pSW+0, 0, "int64")
    ; Retrieve ListLines text and strip out some unnecessary stuff:
    ControlGetText, ListLinesText,, ahk_id %hwndEdit%
    RegExMatch(ListLinesText, ".*`r`n`r`n\K[\s\S]*(?=`r`n`r`n.*$)", ListLinesText)
    StringReplace, ListLinesText, ListLinesText, `r`n, `n, All

    ListLines On
    return ListLinesText  ; This line appears in ListLines if we're called more than once.

  • Members
  • 4 posts
  • Last active: Sep 30 2010 06:17 AM
  • Joined: 18 Sep 2010
sadly i have no access to a second monitor on this pc (got a notebook here, but that won't help in that case).

I got the problem itself fixed (as usual, just some minor detail i overlooked). But i will look into your debugging library, looks promising so far.

  • Members
  • 901 posts
  • Last active: Jul 08 2011 02:12 PM
  • Joined: 29 Feb 2008
DebugViewer can connect remotely... so maybe the notebook could help? I've never actually tried it, but I'm pretty sure it'll work.

EDIT: Yay Lexikos!