when i try to load any blueprint in game through GUI using ALT+F i'm getting this kind of error :
edit..
Issue seams to appear in GetWinPath function only when running on 64 bit system ( DllCall("CreateRemoteThread"... to be exact).
I'm to lazy to learn how it work, so i copy/past similar function from google, and it's working quite well for me
diff -r 57015457b164 quickfort/lib/convert.ahk
--- a/quickfort/lib/convert.ahk Mon Jan 16 10:29:14 2012 -0800
+++ b/quickfort/lib/convert.ahk Wed Feb 22 18:35:07 2012 +0100
@@ -38,13 +38,14 @@
title := GetRandomFileName() "-" SubStr(title, 1, 30)
; Clock how long it takes
- starttime := A_TickCount
+ ;starttime := A_TickCount
; convert and save
- destfile := ConvertAndSaveMacro(title)
+ ;destfile := ConvertAndSaveMacro(title) ; it's to slow now
; measure elapsed time for run
- elapsed := A_TickCount - starttime
+ ;elapsed := A_TickCount - starttime
+ elapsed := 0
; Play the macro.
@@ -85,7 +86,7 @@
outfile := A_ScriptDir "\" title ".mak"
ActivateGameWin() ; TODO try to get dfpath without focusing the game window
- dfpath := GetWinPath("A") ; active window is the instance of DF we want to send to
+ dfpath := GetWinPath("Dwarf Fortress.exe") ; active window is the instance of DF we want to send to
SplitPath, dfpath, , dfpath
destfile := dfpath "\data\init\macros\" title ".mak"
diff -r 57015457b164 quickfort/lib/win32.ahk
--- a/quickfort/lib/win32.ahk Mon Jan 16 10:29:14 2012 -0800
+++ b/quickfort/lib/win32.ahk Wed Feb 22 18:35:07 2012 +0100
@@ -4,29 +4,8 @@
;; Get the path of the window with given title parameter.
GetWinPath(title)
{
- WinGet, pid, PID, %title%
-
- VarSetCapacity(sFilePath, 260)
-
- pFunc := DllCall("GetProcAddress"
- , "Uint", DllCall("GetModuleHandle", "str", "kernel32.dll")
- , "str", "GetCommandLineA")
-
- hProc := DllCall("OpenProcess", "Uint", 0x043A, "int", 0, "Uint", pid)
-
- hThrd := DllCall("CreateRemoteThread", "Uint", hProc, "Uint", 0, "Uint", 0
- , "Uint", pFunc, "Uint", 0, "Uint", 0, "Uint", 0)
-
- DllCall("WaitForSingleObject", "Uint", hThrd, "Uint", 0xFFFFFFFF)
- DllCall("GetExitCodeThread", "Uint", hThrd, "UintP", pcl)
-
- DllCall("psapi\GetModuleFileNameExA", "Uint", hProc, "Uint", 0, "str", sFilePath, "Uint", 260)
- ; DllCall("psapi\GetProcessImageFileNameA", "Uint", hProc, "str", sFilePath, "Uint", 281)
-
- DllCall("CloseHandle", "Uint", hThrd)
- DllCall("CloseHandle", "Uint", hProc)
-
- return sFilePath
+ for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process where name ='" title "'")
+ return process.ExecutablePath
}