; 对着记事本或编辑器使用,模拟拖拽文件到编辑器打开
F1::
vPath := A_Desktop "\已经禁用独显.txt"
; WM_DROPFILES := 0x233,vPath路径可以是文件夹
PostMessage, 0x233, % JEE_DropCreate(vPath), 0,, A  ; A代表当前激活窗口,可换成WinTitle
return

;get 'JEE_DropCreate' from:
;notepad get/set path (get/set text file path) - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=30050

JEE_DropCreate(vPaths, vPosX=0, vPosY=0) {
  ;GMEM_ZEROINIT := 0x40, GMEM_MOVEABLE := 0x2
  vWidth := A_IsUnicode?2:1
  hDrop := DllCall("GlobalAlloc", UInt,0x42, UPtr,20+(StrLen(vPaths)+2)*vWidth, Ptr)
  pDrop := DllCall("GlobalLock", Ptr,hDrop)

  ;DROPFILES struct
  NumPut(20, pDrop+0, 0, "UInt")
  NumPut(vPosX, pDrop+4, 0, "UInt")
  NumPut(vPosY, pDrop+8, 0, "UInt")
  NumPut(A_IsUnicode?1:0, pDrop+16, 0, "UInt")

  ;e.g. CF_HDROP with 3 paths: 'path1 null path2 null path3 null null'
  vOffset := 20
  Loop, Parse, vPaths, `n, `r
    if !(A_LoopField = "")
    {
      DllCall("RtlMoveMemory", UInt,pDrop+vOffset, Str,A_LoopField, UInt,StrLen(A_LoopField)*vWidth)
      vOffset += (StrLen(A_LoopField)+1)*vWidth
    }

  DllCall("GlobalUnlock", Ptr,hDrop)
  return hDrop
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。