vanheartnet

Screen Clipper tool

Jun 4th, 2022 (edited)
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.55 KB | None | 0 0
  1.  
  2. ;@Ahk2Exe-SetCompanyName VANHEARTNET LTD. INC.
  3. ;@Ahk2Exe-SetCopyright All rights reserved © VANHEARTNET
  4. ;@Ahk2Exe-Set FileDescription, Screen Clipper tool © VANHEARTNET
  5. ;@Ahk2Exe-Set FileVersion, 1.1.0.0
  6. ;@Ahk2Exe-SetInternalName Screen Clipper tool
  7. ;@Ahk2Exe-SetName Valorant
  8. ;@Ahk2Exe-SetOrigFileName Screen Clipper tool
  9. ;@Ahk2Exe-Set ProductName, Screen Clipper tool
  10. ;@Ahk2Exe-Set ProductVersion, 1.1.0.0
  11. ;@Ahk2Exe-Set Description, Screen Clipper tool
  12. ;@Ahk2Exe-Set Comments, Software Created by : VANHEARTNET
  13. ;@Ahk2Exe-Obey U_au, = "%A_IsUnicode%" ? 2 : 1 ; Script ANSI or Unicode?
  14. ;@Ahk2Exe-PostExec "BinMod.exe" "%A_WorkFileName%"
  15. ;@Ahk2Exe-Cont "%U_au%2.>AUTOHOTKEY SCRIPT<.01VANHEARTNET "
  16. ;@Ahk2Exe-SetMainIcon icon1.ico
  17. ;@Ahk2Exe-AddResource Icon1.ico, 160 ; Replaces 'H on blue'
  18. ;@Ahk2Exe-AddResource Icon1.ico, 206 ; Replaces 'S on green'
  19. ;@Ahk2Exe-AddResource Icon1.ico, 207 ; Replaces 'H on red'
  20. ;@Ahk2Exe-AddResource Icon1.ico, 208 ; Replaces 'S on red'
  21.  
  22.  
  23. #SingleInstance,Ignore
  24. ;~#SingleInstance,Force
  25. #Persistent
  26. #NoEnv
  27. Menu,tray, NoStandard
  28. ;Menu, Tray, Tip, Screen Clipper tool
  29. Menu, Tray, Add, Config,SHow
  30. Menu, Tray, Add, Exit,Exit1
  31. SetWorkingDir, %A_ScriptDir%
  32. SetBatchLines, 20ms
  33. #MaxHotkeysPerInterval 99000000
  34. #HotkeyInterval 99000000
  35. #KeyHistory 0
  36. ListLines Off
  37. Process, Priority, , A
  38. SetKeyDelay, -1, -1
  39. SetMouseDelay, -1
  40. SetDefaultMouseSpeed, 0
  41. SetWinDelay, -1
  42. SetControlDelay, -1
  43. DetectHiddenWindows, On
  44. SetTitleMatchMode, 3
  45. SendMode Input
  46. CoordMode, Mouse , Screen
  47. #Include <Gdip_All>
  48. #Include <GdipHelper>
  49. pToken:=Gdip_Startup()
  50.  
  51. Controls:="^,!,+,CapsLock,Space,Enter,Delete,Insert,Home,End,Page Up,Page Down"
  52. SymbolsName := " Ctrl,Alt, Shift ,CapsLock,Space,Enter,Delete,Insert,Home,End,Page Up,Page Down"
  53. Symbols:=["Ctrl","Alt","Shift","CapsLock","Space","Enter","Delete","Insert","Home","End","PgUp","PgDn"]
  54.  
  55. OnError("Exit2")
  56. Settings=
  57. (
  58. [Configuration]
  59. Activatehotkey=Ctrl
  60. Save=1
  61. CloseScreenshot=0
  62. Screenshotevent=1
  63. Crosshair=0
  64. AutoSavePrintScreen=0
  65. )
  66. Global Window1:=[], XH:=[] , Switch:=[]
  67. IfNotExist, Configuration.ini
  68. {
  69. FileAppend,% Settings , Configuration.ini
  70. Activatehotkey:="Ctrl" , Save:=1 , CloseScreenshot:=0 , Screenshotevent:=1 , Crosshair:=0 , AutoSavePrintScreen:=0
  71. }
  72. else
  73. {
  74. Iniread, Activatehotkey , Configuration.ini , Configuration , Activatehotkey
  75. Iniread, Save , Configuration.ini , Configuration , Save
  76. Iniread, CloseScreenshot , Configuration.ini , Configuration , CloseScreenshot
  77. Iniread, Screenshotevent , Configuration.ini , Configuration , Screenshotevent
  78. Iniread, Crosshair , Configuration.ini , Configuration , Crosshair
  79. Iniread, AutoSavePrintScreen , Configuration.ini , Configuration , AutoSavePrintScreen
  80. }
  81. if(Activatehotkey="" | "ERROR"){
  82. Activatehotkey:="Ctrl"
  83. IniWrite,Ctrl, %A_ScriptDir%\Configuration.ini , Configuration , Activatehotkey
  84. }
  85. gosub, HotkeySymbols
  86. ;************************************************
  87. Hotkey, % Activatehotkey , CreateCapWindow , On ;<------------------ Adjust the hotkey value to suit your needs / wants
  88.  
  89. ;************************************************
  90. SaveToFile := Save ;<------------------ Set this to 1 to save all clips with a unique name , Set it to 0 to overwrite the saved clip every time a new clip is made.
  91. ;************************************************
  92. ShowCloseButton := 0 ;<------------------ Set this to 1 to show a small close button in the top right corner of the clip. Set this to 0 to keep the close button, but not show it.
  93. ;************************************************
  94. MoveRight := 2
  95.  
  96. #SingleInstance, Force ; Force the script to close any other instances of this script. (Run one copy at a time)
  97. SetBatchLines, -1 ;Set the script to run at top speed.
  98. CoordMode, Mouse , Screen ;Use the screen as the refrence to get positions from.
  99. IfNotExist, %A_ScriptDir%\Screen Clipper PNG ; if there is no folder for Screen Clipper PNG
  100. FileCreateDir, %A_ScriptDir%\Screen Clipper PNG ; create the folder.
  101. SetWorkingDir, %A_ScriptDir%\Screen Clipper PNG ;Set the Screen Clipper PNG folder as the working dir.
  102. Handles := [] ; Create an array to hold the name of the different gui's.
  103. Index := 0 ;Used as the name of the current gui cap window.
  104. ;~ SetTimer, CloseImage , 50
  105. SetTimer, WatchCursor, 200
  106. Window1[B]:= New Window_1( x:=0, y:=0, w:=500, h:=230, Window:="Main", Option:="-DPIScale +AlwaysOntop +Toolwindow -Caption", Title:="Locker")
  107. Gui,% Window1[B].Window ":Color",EEAA99
  108. Gui,% Window1[B].Window ":Font",s8
  109. Switch.Push(New Switch_1( x:=42, y:=85, w:=10, h:=25, Window:="Main", State:=Save , Label:="Switches"))
  110. Switch.Push(New Switch_1( x:=42, y+=h, w:=10, h:=25, Window:="Main", State:=CloseScreenshot , Label:="Switches"))
  111. Switch.Push(New Switch_1( x:=42, y+=h, w:=10, h:=25, Window:="Main", State:=Crosshair, Label:="Switches"))
  112. Switch.Push(New Switch_1( x:=42, y+=h, w:=10, h:=25, Window:="Main", State:=AutoSavePrintScreen, Label:="Switches"))
  113. Gui,% Window1[B].Window ":Font",
  114. Gui,% Window1[B].Window ":Font",s10 cFFFFFF, Impact
  115. Gui,Main:Add,Text,x150 y88 BackgroundTrans, Save Screenshot
  116. Gui,Main:Add,Text,x150 y+9 BackgroundTrans, Auto-Close Screenshot
  117. Gui,Main:Add,Text,x150 y+9 BackgroundTrans, Crosshair
  118. Gui,Main:Add,Text,x150 y+8 BackgroundTrans, Auto-Save PrintScreen
  119. Gui,% Window1[B].Window ":Font"
  120. Gui,% Window1[B].Window ":Font" , Bold c000000 s10, Arial Black
  121. ;~ Gui,Main:Add,Text,x400 y88 w50 h20 BackgroundTrans Center +Border, % Activatehotkey
  122. Gui,% Window1[B].Window ":Font"
  123. Gui,% Window1[B].Window ":Font" , cFFFFFF s8, Impact
  124. Gui,Main:Add,Text,x300 y90 w50 h20 BackgroundTrans Center, HOTKEY:
  125. Gui,Main:Add,Hotkey, x350 y85 w85 h25 BackgroundTrans vChangeHotkey gChangeHotkey +Center Border, % Activatehotkey
  126.  
  127. Gui,CsHair:Color,EEAA99
  128. XH[C]:=New Xhair( x:=0, y:=0, w:=25, h:=25, Window:="CsHair", Option:="-DPIScale +AlwaysOntop -Caption +E0x10", Title:="CrossHair")
  129. return ; End of Auto-Execute Section.
  130. Exit2(){
  131. ExitApp
  132. }
  133. ChangeHotkey:
  134. Gui,Main:Submit,Nohide
  135. sleep 500
  136. GuiControlGet,HKey,,ChangeHotkey
  137. Activatehotkey:=ChangeHotkey
  138. GuiControl,Main:,ChangeHotkey,% HKey
  139. Loop,parse, Controls , `, , %A_Space%%A_Tab%
  140. {
  141. CtrlPos:=A_Index
  142. HO:=A_LoopField
  143. If(HKey==HO)
  144. {
  145. Activatehotkey:=Symbols[CtrlPos]
  146. Break
  147. }
  148. }
  149. GuiControl,Main:,ChangeHotkey,% Activatehotkey
  150. GuiControl,Main:Focus, % Switch[1].hwnd
  151. Hotkey, % Activatehotkey , CreateCapWindow , Off
  152. Hotkey, % Activatehotkey , CreateCapWindow , On
  153. CtrlPos:=""
  154. IniWrite,% Activatehotkey, %A_ScriptDir%\Configuration.ini , Configuration , Activatehotkey
  155. return
  156. HotkeySymbols:
  157. Loop,parse, Controls,`,,%A_Space%%A_Tab%
  158. {
  159. CtrlPos:=A_Index
  160. If(Activatehotkey == A_LoopField)
  161. {
  162. Activatehotkey:=Symbols[CtrlPos]
  163. Break
  164. }
  165. }
  166. return
  167.  
  168.  
  169. MainGuiContextMenu:
  170. Gui,Main:Hide
  171. return
  172.  
  173. Switches:
  174. (Switch[A_GuiControl].State)?(Switch[A_GuiControl].Draw_OFF(),Switch[A_GuiControl].State:=0):(Switch[A_GuiControl].Draw_ON(),Switch[A_GuiControl].State:=1),(CState:=Switch[ A_GuiControl ].State)
  175. GuiControl,Main:Focus, % Switch[A_GuiControl].hwnd
  176. SoundBeep, 2000
  177. if(Switch[ A_GuiControl ].Number=1)
  178. IniWrite,% CState, %A_ScriptDir%\Configuration.ini , Configuration , Save
  179. else if(Switch[ A_GuiControl ].Number=2)
  180. IniWrite,% CState, %A_ScriptDir%\Configuration.ini , Configuration , CloseScreenshot
  181. else if(Switch[ A_GuiControl ].Number=3)
  182. IniWrite,% CState, %A_ScriptDir%\Configuration.ini , Configuration , Crosshair
  183. else if(Switch[ A_GuiControl ].Number=4)
  184. IniWrite,% CState, %A_ScriptDir%\Configuration.ini , Configuration , AutoSavePrintScreen
  185. return
  186. ;~ 1::
  187. SHow:
  188. Gui, % Window1[B].Window ":Show", % "w" Window1[B].w " h" Window1[B].h , % Window1[B].Title
  189. WinSet, TransColor ,EEAA99 , % Window1[B].Title
  190. GuiControl,Main:Focus, % Switch[1].hwnd
  191. return
  192. Move:
  193. PostMessage,0xA1,2
  194. return
  195. MouseXhair:
  196. MouseGetPos,MXX,YXX
  197. If(Active)
  198. Gui, % XH[C].Window ":Show", % "x" MXX-10 " y" YXX-10
  199. return
  200.  
  201. Class Switch_1{
  202. __New( x:=0, y:=0, w:=100, h:=25, Window:="Main", State:=0 , Label:="Switches"){
  203. This.X:=x,This.Y:=y,This.W:=w,This.H:=h,This.Window:=Window,This.State:=State, This.Label:=Label,This.Switch_ON(), This.Switch_OFF(),This.Add_Window(),sleep 20
  204. (This.State)?(This.Draw_ON()):(This.Draw_OFF())
  205. }
  206. Add_Window(){
  207. static
  208. num := Switch.Length()+1
  209. ;~ Gui, % This.Window ":Add" , Picture,% "x" This.X " y" This.Y " w" This.W " h" This.H " g" This.Label " v" Num " hwndhwnd 0xE"
  210. Gui, % This.Window ":Add" , Picture,% "x" This.X " y" This.Y " w" This.W " h" This.H " g" This.Label " v" Num " hwndhwnd 0xE"
  211. This.Number := Num,This.Hwnd := Hwnd
  212. }
  213. Switch_ON(){
  214. pBitmap:=Gdip_CreateBitmap( 100 , 25 )
  215. G := Gdip_GraphicsFromImage( pBitmap )
  216. Gdip_SetSmoothingMode( G , 5 )
  217. Brush := Gdip_BrushCreateSolid( "0xFF222222" )
  218. Gdip_FillRectangle( G , Brush , -1 , -1 , 102 , 27 )
  219. Gdip_DeleteBrush( Brush )
  220. Brush := Gdip_BrushCreateSolid( "0xFF000000" )
  221. Gdip_FillRoundedRectangle( G , Brush , 1 , 1 , 98 , 23 , 10 )
  222. Gdip_DeleteBrush( Brush )
  223. Brush := Gdip_CreateLineBrush( 0 , 0 , 100 , 100 , "0xFF333333" , "0xFF333333" , 1 )
  224. Gdip_FillRoundedRectangle( G , Brush , 3 , 3 , 94 , 19 , 9 )
  225. Gdip_DeleteBrush( Brush )
  226. Brush := Gdip_BrushCreateSolid( "0xFF999999" )
  227. Gdip_FillRoundedRectangle( G , Brush , 4 , 4 , 92 , 17 , 8 )
  228. Gdip_DeleteBrush( Brush )
  229. Brush := Gdip_BrushCreateSolid( "0xFF333333" )
  230. Gdip_FillRoundedRectangle( G , Brush , 44 , 4 , 51 , 17 , 5 )
  231. Gdip_DeleteBrush( Brush )
  232. Pen := Gdip_CreatePen( "0xFF00FF00" , 2 )
  233. Gdip_DrawRoundedRectangle( G , Pen , 44 , 4 , 50 , 16 , 4 )
  234. Gdip_DeletePen( Pen )
  235. Brush := Gdip_BrushCreateSolid( "0xFF555555" )
  236. Gdip_FillRoundedRectangle( G , Brush , 44 , 4 , 50 , 16 , 5 )
  237. Gdip_DeleteBrush( Brush )
  238. Brush := Gdip_BrushCreateSolid( "0xFF000000" )
  239. Gdip_TextToGraphics( G , "ON" , "s11 Center vCenter bold c" Brush " x-25 y-12" , "Arial Black" , 100 , 50 )
  240. Gdip_DeleteBrush( Brush )
  241. Brush := Gdip_BrushCreateSolid( "0xFF00FF00" )
  242. Gdip_TextToGraphics( G , "ON" , "s11 Center vCenter bold c" Brush " x-24 y-11" , "Arial Black" , 100 , 50 )
  243. Gdip_DeleteBrush( Brush )
  244. Gdip_DeleteGraphics( G )
  245. This.Draw_Switch_ON := Gdip_CreateHBITMAPFromBitmap(pBitmap)
  246. Gdip_DisposeImage(pBitmap)
  247. }
  248. Switch_OFF(){
  249. ;Bitmap Created Using: HB Bitmap Maker
  250. pBitmap:=Gdip_CreateBitmap( 100 , 25 )
  251. G := Gdip_GraphicsFromImage( pBitmap )
  252. Gdip_SetSmoothingMode( G , 4 )
  253. Brush := Gdip_BrushCreateSolid( "0xFF222222" )
  254. Gdip_FillRectangle( G , Brush , -1 , -1 , 102 , 27 )
  255. Gdip_DeleteBrush( Brush )
  256. Brush := Gdip_BrushCreateSolid( "0xFF000000" )
  257. Gdip_FillRoundedRectangle( G , Brush , 1 , 1 , 98 , 23 , 10 )
  258. Gdip_DeleteBrush( Brush )
  259. Brush := Gdip_CreateLineBrush( 0 , 0 , 100 , 100 , "0xFF333333" , "0xFF333333" , 1 )
  260. Gdip_FillRoundedRectangle( G , Brush , 3 , 3 , 94 , 19 , 9 )
  261. Gdip_DeleteBrush( Brush )
  262. Brush := Gdip_BrushCreateSolid( "0xFF999999" )
  263. Gdip_FillRoundedRectangle( G , Brush , 4 , 4 , 92 , 17 , 8 )
  264. Gdip_DeleteBrush( Brush )
  265. Brush := Gdip_BrushCreateSolid( "0xFF333333" )
  266. Gdip_FillRoundedRectangle( G , Brush , 6 , 4 , 51 , 17 , 5 )
  267. Gdip_DeleteBrush( Brush )
  268. Brush := Gdip_BrushCreateSolid( "0xFF555555" )
  269. Gdip_FillRoundedRectangle( G , Brush , 7 , 5 , 50 , 16 , 5 )
  270. Gdip_DeleteBrush( Brush )
  271. Pen := Gdip_CreatePen( "0xFFFF0000" , 2 )
  272. Gdip_DrawRoundedRectangle( G , Pen , 6 , 4 , 50 , 16 , 4 )
  273. Gdip_DeletePen( Pen )
  274. Brush := Gdip_BrushCreateSolid( "0xFF000000" )
  275. Gdip_TextToGraphics( G , "OFF" , "s11 Center vCenter bold c" Brush " x24 y-12" , "Arial Black" , 100 , 50 )
  276. Gdip_DeleteBrush( Brush )
  277. Brush := Gdip_BrushCreateSolid( "0xFFFF0000" )
  278. Gdip_TextToGraphics( G , "OFF" , "s11 Center vCenter bold c" Brush " x25 y-11" , "Arial Black" , 100 , 50 )
  279. Gdip_DeleteBrush( Brush )
  280. Gdip_DeleteGraphics( G )
  281. This.Draw_Switch_OFF := Gdip_CreateHBITMAPFromBitmap(pBitmap)
  282. Gdip_DisposeImage(pBitmap)
  283. }
  284. Draw_ON(){
  285. SetImage( This.Hwnd , This.Draw_Switch_ON )
  286. }
  287. Draw_OFF(){
  288. SetImage( This.Hwnd , This.Draw_Switch_OFF )
  289. }
  290. }
  291.  
  292.  
  293. Class Xhair{
  294. __New( x:=0, y:=0, w:=25, h:=25, Window:="CsHair", Option:="-DPIScale +AlwaysOntop -Caption +E0x10", Title:="Sample Window"){
  295. This.X:=x,This.Y:=y,This.W:=w,This.H:=h,This.Window:=Window,This.Option:=Option,This.Title:=Title,This.Add_Window(),This.Mouse_Xhair(),sleep 20,This.Draw_Xhair()
  296. }
  297. Add_Window(){
  298. static
  299. Gui, % This.Window " :" This.Option
  300. Gui, % This.Window ":Add" , Picture,% "x" This.X " y" This.Y " w" This.W " h" This.H " v" Num " hwndhwnd 0xE"
  301. ;~ Gui, % This.Window ":Add" , Text,% "x10 y10 w479 h48 Backgroundtrans"
  302. ;~ Gui, % This.Window ":Show", % "w" This.w " h" This.h , % This.Title
  303. This.Hwnd := Hwnd
  304. }
  305. Mouse_Xhair(){
  306. ;Bitmap Created Using: HB Bitmap Maker
  307. pBitmap:=Gdip_CreateBitmap( 25 , 25 )
  308. G := Gdip_GraphicsFromImage( pBitmap )
  309. Gdip_SetSmoothingMode( G , 3 )
  310. Brush := Gdip_BrushCreateSolid( "0xFFFF0000" )
  311. Gdip_FillRectangle( G , Brush , 10 , 0 , 1 , 20 )
  312. Gdip_DeleteBrush( Brush )
  313. Brush := Gdip_BrushCreateSolid( "0xFFFF0000" )
  314. Gdip_FillRectangle( G , Brush , 0 , 10 , 20 , 1 )
  315. Gdip_DeleteBrush( Brush )
  316. Gdip_DeleteGraphics( G )
  317. This.Draw_Xhair1 := Gdip_CreateHBITMAPFromBitmap(pBitmap)
  318. Gdip_DisposeImage(pBitmap)
  319. }
  320. Draw_Xhair(){
  321. SetImage( This.Hwnd , This.Draw_Xhair1 )
  322. }
  323. }
  324.  
  325. Class Window_1{
  326. __New( x:=10, y:=10, w:=602, h:=402, Window:="Main", Option:="-DPIScale +AlwaysOntop -Caption +E0x10", Title:="Sample Window"){
  327. This.X:=x,This.Y:=y,This.W:=w,This.H:=h,This.Window:=Window,This.Option:=Option,This.Title:=Title,This.Add_Window(),This.Screen_Window(),sleep 20,This.Draw_Window1()
  328. }
  329. Add_Window(){
  330. global
  331. Gui, % This.Window " :" This.Option
  332. Gui, % This.Window ":Add" , Picture,% "x" This.X " y" This.Y " w" This.W " h" This.H " v" Num " hwndhwnd 0xE"
  333. Gui, % This.Window ":Add" , Text,% "x10 y10 w479 h48 Backgroundtrans gMove"
  334. ;~ Gui, % This.Window ":Show", % "w" This.w " h" This.h , % This.Title
  335. This.Hwnd := Hwnd
  336. }
  337. Screen_Window(){
  338. ;Bitmap Created Using: HB Bitmap Maker
  339. pBitmap:=Gdip_CreateBitmap( This.w , This.h ) ;500 , 200
  340. G := Gdip_GraphicsFromImage( pBitmap )
  341. Gdip_SetSmoothingMode( G , 5 )
  342. Brush := Gdip_BrushCreateSolid( "0xFF333333" )
  343. Gdip_FillRoundedRectangle( G , Brush , 0 , 0 , This.w , This.h , 20 )
  344. Gdip_DeleteBrush( Brush )
  345. Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , 100 , 100 , "0xFF00B9FC" , "0xFF0557C7" , 1 , 1 )
  346. Pen := Gdip_CreatePenFromBrush( Brush , 5 )
  347. Gdip_DeleteBrush( Brush )
  348. Gdip_DrawRoundedRectangle( G , Pen , 1 , 1 , This.w-3 , This.h-3 , 20 )
  349. Gdip_DeletePen( Pen )
  350. Brush := Gdip_BrushCreateSolid( "0xFF82BCFB" )
  351. Gdip_FillRoundedRectangle( G , Brush , 10 , 10 , This.w-20 , This.h-22 , 8 )
  352. Gdip_DeleteBrush( Brush )
  353. Brush := Gdip_CreateLineBrush( 0 , 0 , 100 , 100 , "0xFF0450C0" , "0xFF333333" , 1 )
  354. Gdip_FillRoundedRectangle( G , Brush , 14 , 14 , 213 , 40 , 5 )
  355. Gdip_DeleteBrush( Brush )
  356. Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , 100 , 100 , "0xFF999999" , "0xFF333333" , 1 , 1 )
  357. Pen := Gdip_CreatePenFromBrush( Brush , 3 )
  358. Gdip_DeleteBrush( Brush )
  359. Gdip_DrawRoundedRectangle( G , Pen , 15 , 14 , 213 , 40 , 5 )
  360. Gdip_DeletePen( Pen )
  361. Brush := Gdip_BrushCreateSolid( "0xFF222222" )
  362. Gdip_TextToGraphics( G , "SCREEN CLIPPER" , "s15 Center vCenter Bold c" Brush " x7 y10" , "Arial Black" , 215 , 50 )
  363. Gdip_DeleteBrush( Brush )
  364. Brush := Gdip_BrushCreateSolid( "0xFF222222" )
  365. Gdip_TextToGraphics( G , "SCREEN CLIPPER" , "s15 Center vCenter Bold c" Brush " x12 y10" , "Arial Black" , 215 , 50 )
  366. Gdip_DeleteBrush( Brush )
  367. Brush := Gdip_BrushCreateSolid( "0xFFFF0000" )
  368. Gdip_TextToGraphics( G , "SCREEN CLIPPER" , "s15 Center vCenter Bold c" Brush " x10 y10" , "Arial Black" , 215 , 50 )
  369. Gdip_DeleteBrush( Brush )
  370. Brush := Gdip_BrushCreateSolid( "0xFFFF0000" )
  371. Gdip_TextToGraphics( G , "SCREEN CLIPPER" , "s15 Center vCenter Bold c" Brush " x9 y10" , "Arial Black" , 215 , 50 )
  372. Gdip_DeleteBrush( Brush )
  373. Pen := Gdip_CreatePen( "0xFF222222" , 2 )
  374. Gdip_DrawRoundedRectangle( G , Pen , 15 , 65 , This.w-29 , This.h-83 , 5 )
  375. Gdip_DeletePen( Pen )
  376. Pen := Gdip_CreatePen( "0xFF666666" , 2 )
  377. Gdip_DrawRoundedRectangle( G , Pen , 16 , 65 ,This.w-31 , This.h-83 , 5 )
  378. Gdip_DeletePen( Pen )
  379. Pen := Gdip_CreatePen( "0xFFFF0000" , 2 )
  380. Gdip_DrawRoundedRectangle( G , Pen , 10 , 10 , 479 , 48 , 10 )
  381. Gdip_DeletePen( Pen )
  382. Brush := Gdip_BrushCreateSolid( "0xFFFFFF00" )
  383. Gdip_TextToGraphics( G , "V A N H E A R T N E T" , "s12 Center vCenter Bold c" Brush " x259 y10" , "Arial Black" , 200 , 50 )
  384. Gdip_DeleteBrush( Brush )
  385. Brush := Gdip_CreateLineBrush( 0 , 0 , 100 , 100 , "0xFF333333" , "0xFF880000" , 1 )
  386. Gdip_TextToGraphics( G , "V A N H E A R T N E T" , "s12 Center vCenter Bold c" Brush " x260 y10" , "Arial Black" , 200 , 50 )
  387. Gdip_DeleteBrush( Brush )
  388. Brush := Gdip_CreateLineBrush( 0 , 0 , 100 , 100 , "0xFF333333" , "0xFF186AB8" , 1 )
  389. Gdip_FillRoundedRectangle( G , Brush , 20 , 69 , This.w-39 , This.h-91 , 8 )
  390. Gdip_DeleteBrush( Brush )
  391. Brush := Gdip_BrushCreateSolid( "0xFF222222" )
  392. Gdip_FillRoundedRectangle( G , Brush , 30 , 75, This.w-60 , This.h-105 , 5 )
  393. Gdip_DeleteBrush( Brush )
  394. Brush := Gdip_BrushCreateSolid( "0xFF909090" ) ;Hotkey Background
  395. Gdip_FillRoundedRectangle( G , Brush , 347 , 82, 90, 30 , 3 ) ;x350 y85 w85 h25
  396. Gdip_DeleteBrush( Brush )
  397. Gdip_DeleteGraphics( G )
  398. This.Draw_1 := Gdip_CreateHBITMAPFromBitmap(pBitmap)
  399. Gdip_DisposeImage(pBitmap)
  400. }
  401. Draw_Window1(){
  402. SetImage( This.Hwnd , This.Draw_1 )
  403. }
  404. }
  405.  
  406.  
  407.  
  408. ;**************************************************************************************
  409. ;**************************************************************************************
  410. ;~ ESC:: ExitApp ; Hotkey to exit the script.
  411. ;**************************************************************************************
  412. ;**************************************************************************************
  413.  
  414. CloseClip: ;Close (Destroy this gui)
  415. hwnd := WinActive() ;Get the handle to the active window
  416. Gui, % Handles[hwnd] ": Destroy" ;Destroy the gui with the name stored in the Handles array at position hwnd.
  417. return
  418.  
  419.  
  420. MoveWindow:
  421. PostMessage, 0xA1 , 2 ;Move the active window
  422. return
  423.  
  424. CreateCapWindow: ;Create a gui to used for setting the screen cap area and to display the resulting screen shot.
  425. Index++ ;Increment the current index. (the gui's name)
  426. Gui, %Index% : New , +AlwaysOnTop -Caption -DPIScale +ToolWindow +LastFound +Border hwndHwnd ;Create a new gui and set its options.
  427. Handles[hwnd] := Index ;Use the windows handle (hwnd) as the index for the the value of the windows name.
  428. Gui, %Index% : Color , 123456 ;Set the color of the gui (This color will be made transparent in the next step)
  429. WinSet, TransColor , 123456 ;Set only this color as transparent
  430. Gui, %Index% : Font, cMaroon s10 Bold Q5 , Segoe UI ;Set this gui's font. (Used for the close button)
  431. Active := 1
  432. ;~ ToolTip, Click and drag to set capture area. ;Display a tooltip that tells the user what to do.
  433. ;~ SetTimer, Tooltips , 30 ;Set a timer to move the tooltip around with the users cursor.
  434. if(Switch[3].State=1){
  435. Gui, % XH[C].Window ":Show", % "w" XH[C].w " h" XH[C].h , % XH[C].Title
  436. WinSet, TransColor ,EEAA99 , % XH[C].Title
  437. SetTimer, MouseXhair , 10
  438. }
  439. return
  440.  
  441. ;~ Tooltips:
  442. ;~ ToolTip, Click and drag to set capture area. ;Display a tooltip that tells the user what to do.
  443. ;~ return
  444.  
  445. DrawCapArea:
  446. if( !FirstPosition ){ ;If the first position hasn't been set yet.
  447. FirstPosition := 1 ;The first position is now set.
  448. MouseGetPos, SX , SY ;Get the x and y starting position.
  449. }else { ;After the first position is set.
  450. MouseGetPos, EX , EY ;Get the current position of the cursor.
  451. if( SX <= EX && SY <= EY ) ;If the current position is below and to the right of the starting position.
  452. WinPos := { X: SX , Y: SY , W: EX - SX , H: EY - SY } ;Create a object to hold the windows positions.
  453. else if( SX > EX && SY <= EY ) ;If the current position is below and to the left of the starting position.
  454. WinPos := { X: EX , Y: SY , W: SX - EX , H: EY - SY } ;Create a object to hold the windows positions.
  455. else if( SX <= EX && SY > EY) ;If the current position is above and to the right of the starting position.
  456. WinPos := { X: SX , Y: EY , W: EX - SX , H: SY - EY } ;Create a object to hold the windows positions.
  457. else if( SX > EX && SY > EY) ;If the current position is above and to the left of the starting position.
  458. WinPos := { X: EX , Y: EY , W: SX - EX , H: SY - EY } ;Create a object to hold the windows positions.
  459. }
  460. if( WinPos.W ) ;if the winpos object exists
  461. Gui, %Index% : Show , % "x" WinPos.X " y" WinPos.Y " w" WinPos.W " h" WinPos.H " NA" ,% "Image-" A_Now "-" Index
  462. return
  463.  
  464. TakeScreenShot:
  465. pToken := Gdip_Startup() ;Start using Gdip
  466. ClipBitmap := Gdip_BitmapFromScreen( WinPos.X "|" WinPos.Y "|" WinPos.W "|" WinPos.H) ;Create a bitmap of the screen.
  467. ;~ Gdip_SaveBitmapToFile( ClipBitmap , A_WorkingDir "\" ( ( Switch[1].State = 1 ) ? ( ClipName := "Image-" A_Now ) : ( ClipName := "Temp Clip") ) ".png", 100 ) ; Save the bitmap to file
  468. Gdip_SaveBitmapToFile( ClipBitmap , ( ( Switch[1].State = 1 ) ? ( ClipName := A_WorkingDir "\Image-" A_Now "-" Handles[hwnd] ) : ( ClipName := A_Temp "\Temp Clip") ) ".png", 100 ) ; Save the bitmap to file
  469. Gdip_DisposeImage( ClipBitmap ) ;Dispose of the bitmap to free memory.
  470. Gdip_Shutdown(pToken) ;Turn off gdip
  471. LatestGui := A_WorkingDir "\" ClipName
  472. return
  473.  
  474. TakeScreenShot2:
  475. pToken := Gdip_Startup() ;Start using Gdip
  476. ClipBitmap := Gdip_BitmapFromScreen( 0 "|" 0 "|" A_ScreenWidth "|"A_ScreenHeight) ;Create a bitmap of the screen.
  477. ;~ Gdip_SaveBitmapToFile( ClipBitmap , A_WorkingDir "\" ( ( Switch[1].State = 1 ) ? ( ClipName := "Image-" A_Now ) : ( ClipName := "Temp Clip") ) ".png", 100 ) ; Save the bitmap to file
  478. Gdip_SaveBitmapToFile( ClipBitmap , ( ( Switch[1].State = 1 ) ? ( ClipName := A_WorkingDir "\Image-" A_Now "-" Handles[hwnd] ) : ( ClipName := A_Temp "\Temp Clip") ) ".png", 100 ) ; Save the bitmap to file
  479. Gdip_DisposeImage( ClipBitmap ) ;Dispose of the bitmap to free memory.
  480. Gdip_Shutdown(pToken) ;Turn off gdip
  481. LatestGui := A_WorkingDir "\" ClipName
  482. return
  483.  
  484. WatchCursor:
  485. MouseGetPos,MXX,YXX,WinT,
  486. WinGetTitle, WT, ahk_id %WinT%
  487. IfInString, WT , Image-
  488. ImageTitle := true
  489. else
  490. ImageTitle := False
  491. return
  492.  
  493. #If (Active) ;Context sen Hotkeys.
  494.  
  495. LButton::
  496. if(Switch[3].State=1){
  497. SetTimer, MouseXhair , Off
  498. Gui, % XH[C].Window ":Hide"
  499. }
  500. WinPos := "" ;Clear this object.
  501. FirstPosition := 0 ;Variable used to determin if the starting point has been set yet.
  502. SetTimer, DrawCapArea , 30 ;Set a timer for drawing a rectangle around the capture area.
  503. return
  504.  
  505. LButton Up::
  506. Active := 0 ;Set context hotkeys off
  507. SetTimer, DrawCapArea , Off ;Turn off the drawing timer.
  508. if( WinPos.W < 10 || WinPos.H < 10 ) { ; if the cap area width or height is less than 10px.
  509. Gui, %Index% : Destroy ;Destroy the gui
  510. return ; Skip taking a screen clip.
  511. }
  512. Gui, %Index% : -Border ;Remove the border before taking the screen clip
  513. gosub, TakeScreenShot ;Take a screen shot of the cap area.
  514. Gui, %Index% : +Border ;Add the border again.
  515.  
  516. ;~ Gui, %Index% : Add , Text , % ( ( ShowCloseButton ) ? ( " Center 0x200 Border " ) : ( "" ) ) " x" WinPos.W - 20 " y0 w20 h20 BackgroundTrans gCloseClip" , % ( ( ShowCloseButton ) ? ( "X" ) : ( "" ) ) ;Create a trigger used for closing this window.
  517. Gui, %Index% : Add , Text , % "x0 y0 w" WinPos.W " h" WinPos.H " BackgroundTrans gMoveWindow" ;Create a trigger used for moving the window around.
  518. Gui, %Index% : Add , Picture , % "x0 y0 w" WinPos.W " h" WinPos.H ,% ClipName ".png" ;Add the Screen clip image
  519. ;~ Gui, %Index% : Show, % "x" ( ( A_ScreenWidth-WinPos.W) -10) " y" WinPos.Y
  520. if (Switch[2].State = 1 ){
  521. sleep,500
  522. Gui, %Index% : Destroy
  523. }
  524.  
  525.  
  526. return
  527.  
  528. RButton:: ;If the right mouse button is pressed while selecting the screen clip area, Cancel the action and restore variables etc.
  529. Active := 0 ;Set context hotkeys off
  530. SetTimer, DrawCapArea , Off ;Turn off the drawing timer.
  531. ;~ SetTimer, Tooltips , Off ;Turn off the tooltips timer
  532. ;~ ToolTip, ;Turn off any tooltips.
  533. Gui, %Index% : Destroy ;Destroy the current gui
  534. IfWinExist,CrossHair
  535. {
  536. SetTimer, MouseXhair , Off
  537. Gui, % XH[C].Window ":Hide"
  538. }
  539. return
  540.  
  541. #If (ImageTitle=True)
  542. RButton::
  543. WinTitle1:=StrSplit(WT,"-")
  544. if( WinTitle1.1 != "Image")
  545. return
  546. Gui, % WinTitle1.3 ": Destroy"
  547. return
  548. Delete::
  549. WinGetActiveTitle, WindowTittleActive
  550. WinTitle:=StrSplit(WindowTittleActive,"-")
  551. if( WinTitle.1 != "Image")
  552. return
  553. Gui, % WinTitle.3 ": Destroy"
  554. FileDelete, % WindowTittleActive ".png"
  555. return
  556. #If (Switch[4].State=1)
  557. PrintScreen::
  558. gosub, TakeScreenShot2
  559. return
  560. #If
  561.  
  562.  
  563.  
  564. ;~ Esc::
  565. Exit1:
  566. Gdip_Shutdown(pToken)
  567. ExitApp
  568.  
Add Comment
Please, Sign In to add comment