From d3b97678933f10c37931da4f561559f03483bd59 Mon Sep 17 00:00:00 2001 From: ElectronicsArchiver <85485984+ElectronicsArchiver@users.noreply.github.com> Date: Sat, 10 Sep 2022 09:09:20 -0400 Subject: [PATCH 01/13] Sorted Files --- {Sai => Resources}/OpacitySlider(gray).png | Bin {Misc Old => Resources}/steamkeylisting.bmp | Bin .../steamremovethislisting.bmp | Bin {Sai => Resources}/tester.png | Bin {Misc Old => Resources}/topleft.bmp | Bin Sai/Do Gray Tone.ahk.bak | 30 ---- Sai/SaiToolkit.ahk.bak | 134 ------------------ .../Discord/Message Purger.ahk | 0 .../Sai/Animate Playback.ahk | 1 + {Sai => Scripts/Sai}/Do Gray Tone.ahk | 0 {Sai => Scripts/Sai}/Gdip.ahk | 0 {Sai => Scripts/Sai}/Gdip_ImageSearch.ahk | 0 {Sai => Scripts/Sai}/Layer Chain Renamer.ahk | 0 {Sai => Scripts/Sai}/Layer Exporter.ahk | 0 {Sai => Scripts/Sai}/SaiToolkit.ahk | 0 .../Steam/Remove All Markets.ahk | 0 16 files changed, 1 insertion(+), 164 deletions(-) rename {Sai => Resources}/OpacitySlider(gray).png (100%) rename {Misc Old => Resources}/steamkeylisting.bmp (100%) rename {Misc Old => Resources}/steamremovethislisting.bmp (100%) rename {Sai => Resources}/tester.png (100%) rename {Misc Old => Resources}/topleft.bmp (100%) delete mode 100644 Sai/Do Gray Tone.ahk.bak delete mode 100644 Sai/SaiToolkit.ahk.bak rename Misc Old/Discord Deleter.ahk => Scripts/Discord/Message Purger.ahk (100%) rename Misc Old/Sai Animate Playback.ahk => Scripts/Sai/Animate Playback.ahk (99%) rename {Sai => Scripts/Sai}/Do Gray Tone.ahk (100%) rename {Sai => Scripts/Sai}/Gdip.ahk (100%) rename {Sai => Scripts/Sai}/Gdip_ImageSearch.ahk (100%) rename {Sai => Scripts/Sai}/Layer Chain Renamer.ahk (100%) rename {Sai => Scripts/Sai}/Layer Exporter.ahk (100%) rename {Sai => Scripts/Sai}/SaiToolkit.ahk (100%) rename Misc Old/Steam RemoveAll Markets.ahk => Scripts/Steam/Remove All Markets.ahk (100%) diff --git a/Sai/OpacitySlider(gray).png b/Resources/OpacitySlider(gray).png similarity index 100% rename from Sai/OpacitySlider(gray).png rename to Resources/OpacitySlider(gray).png diff --git a/Misc Old/steamkeylisting.bmp b/Resources/steamkeylisting.bmp similarity index 100% rename from Misc Old/steamkeylisting.bmp rename to Resources/steamkeylisting.bmp diff --git a/Misc Old/steamremovethislisting.bmp b/Resources/steamremovethislisting.bmp similarity index 100% rename from Misc Old/steamremovethislisting.bmp rename to Resources/steamremovethislisting.bmp diff --git a/Sai/tester.png b/Resources/tester.png similarity index 100% rename from Sai/tester.png rename to Resources/tester.png diff --git a/Misc Old/topleft.bmp b/Resources/topleft.bmp similarity index 100% rename from Misc Old/topleft.bmp rename to Resources/topleft.bmp diff --git a/Sai/Do Gray Tone.ahk.bak b/Sai/Do Gray Tone.ahk.bak deleted file mode 100644 index ffe2b8f..0000000 --- a/Sai/Do Gray Tone.ahk.bak +++ /dev/null @@ -1,30 +0,0 @@ -;Pre-select areas to NOT shade -;Invert selection -;Contract -;Add folder -;Add shade layer -;Fill with black -;Change opacity to like 25% -;Add blush layer -;Add hilight layer - -#Include ./SaiToolkit.ahk -#Include .\Gdip.ahk -#Include .\Gdip_ImageSearch.ahk -coordMode,pixel -focusSai() - -sleep 100 -invertSelection() -erodeSelection() -newFolder() -renameLayer("Tone") -newLayer() -renameLayer("Gray") -fillLayer() -imageSearchc(fx,fy,0,0,a_screenWidth,a_screenHeight,"./OpacitySlider(gray).png") -MouseClick, left, fx+110, fy+20 -newLayer() -renameLayer("Blush") -newLayer() -renameLayer("Hilights") \ No newline at end of file diff --git a/Sai/SaiToolkit.ahk.bak b/Sai/SaiToolkit.ahk.bak deleted file mode 100644 index a059277..0000000 --- a/Sai/SaiToolkit.ahk.bak +++ /dev/null @@ -1,134 +0,0 @@ - -;SaiToolkit -#SingleInstance Force -CoordMode, Mouse, Screen -CoordMode, Pixel, Screen -;Define globals -global acceptKey := "Enter" -global forwardLayerKey := "F1" -global backwardLayerKey := "F3" -global showAloneLayerKey := "F4" -global layerPropertiesKey := "F5" -global exportPngKey := "F8" -global erodeSelectionKey := "F7" -global invertSelectionKey := "F6" -global newLayerKey := "F10" -global newFolderKey := "F9" -global fillKey := "F12" -;exportCurrent("test") - -renameLayer(newName){ - pressButton(layerPropertiesKey) - Sleep 50 - thisLayerName := getHighlighted() - send %newName% - pressButton(acceptKey) -} - -fillLayer(){ - pressButton(fillKey) -} -newLayer(){ - pressButton(newLayerKey) -} -newFolder(){ - pressButton(newFolderKey) -} -invertSelection(){ - pressButton(invertSelectionKey) -} -erodeSelection(){ - pressButton(erodeSelectionKey) - Sleep 100 - pressButton(acceptKey) -} - -exportCurrent(fileName := ""){ - focusSai() - ctrlDown() - pressButton(exportPngKey) - ctrlUp() - Sleep 100 - if(fileName != "") - Send %fileName% - pressButton(acceptKey) - Sleep 500 - WinGetTitle, title, Confirm - if(title == "Confirm Save As"){ - pressButton("Tab") - Sleep 100 - pressButton(acceptKey) - } - Sleep 1000 -} - -showAloneLayer(){ - pressButton(showAloneLayerKey) -} - -getCurrentLayerName(){ - result := "" - focusSai() - pressButton(layerPropertiesKey) - result := getHighlighted() - pressButton("Tab") - pressButton("Tab") - pressButton(acceptKey) - return result -} - -;Uses the clipboard to get whatever's currently highlighted -getHighlighted(){ - clipsaved:= clipboard ;Save clipboard - clipboard := "" ;Erase clipboard - Send, ^c ;Set clipboard - Sleep 200 ;Wait so Windows can process - clipsaved2 := clipboard ;Get Clipboard contents - clipboard := clipsaved ;Reset clipboard back to what it was before - Sleep 200 - return clipsaved2 ;Return whatever text was highlighted -} - -focusSai(){ - WinActivate, PaintTool SAI -} -shiftDown(){ -Send, {Shift Down} -} -shiftUp(){ -Send, {Shift Up} -} -ctrlDown(){ -Send, {Ctrl Down} -} -ctrlUp(){ -Send, {Ctrl Up} -} -pressButton(butt){ - Send, {%butt% Down} - Sleep 50 - Send, {%butt% Up} -} -goUpLayer(){ - pressButton(forwardLayerKey) -} - -;https://github.com/Masonjar13/AHK-Library -imageSearchc(byRef out1,byRef out2,x1,y1,x2,y2,image,vari:=0,trans:="",direction:=5,debug:=0){ - static ptok:=gdip_startup() - imageB:=gdip_createBitmapFromFile(image) - scrn:=gdip_bitmapfromscreen(x1 "|" y1 "|" x2 - x1 "|" y2 - y1) - if(debug) - gdip_saveBitmapToFile(scrn,a_now ".png") - errorlev:=gdip_imageSearch(scrn,imageB,tempxy,0,0,0,0,vari,trans,direction) - gdip_disposeImage(scrn) - gdip_disposeImage(imageB) - - if (errorlev) { - out:=strSplit(tempxy,"`,") - out1:=out[1] + x1 - out2:=out[2] + y1 - return % errorlev - } - return 0 -} \ No newline at end of file diff --git a/Misc Old/Discord Deleter.ahk b/Scripts/Discord/Message Purger.ahk similarity index 100% rename from Misc Old/Discord Deleter.ahk rename to Scripts/Discord/Message Purger.ahk diff --git a/Misc Old/Sai Animate Playback.ahk b/Scripts/Sai/Animate Playback.ahk similarity index 99% rename from Misc Old/Sai Animate Playback.ahk rename to Scripts/Sai/Animate Playback.ahk index 6181eaa..595e3bf 100644 --- a/Misc Old/Sai Animate Playback.ahk +++ b/Scripts/Sai/Animate Playback.ahk @@ -1,3 +1,4 @@ + #SingleInstance Force global numberOfFrames := 4 global isPlaying := false diff --git a/Sai/Do Gray Tone.ahk b/Scripts/Sai/Do Gray Tone.ahk similarity index 100% rename from Sai/Do Gray Tone.ahk rename to Scripts/Sai/Do Gray Tone.ahk diff --git a/Sai/Gdip.ahk b/Scripts/Sai/Gdip.ahk similarity index 100% rename from Sai/Gdip.ahk rename to Scripts/Sai/Gdip.ahk diff --git a/Sai/Gdip_ImageSearch.ahk b/Scripts/Sai/Gdip_ImageSearch.ahk similarity index 100% rename from Sai/Gdip_ImageSearch.ahk rename to Scripts/Sai/Gdip_ImageSearch.ahk diff --git a/Sai/Layer Chain Renamer.ahk b/Scripts/Sai/Layer Chain Renamer.ahk similarity index 100% rename from Sai/Layer Chain Renamer.ahk rename to Scripts/Sai/Layer Chain Renamer.ahk diff --git a/Sai/Layer Exporter.ahk b/Scripts/Sai/Layer Exporter.ahk similarity index 100% rename from Sai/Layer Exporter.ahk rename to Scripts/Sai/Layer Exporter.ahk diff --git a/Sai/SaiToolkit.ahk b/Scripts/Sai/SaiToolkit.ahk similarity index 100% rename from Sai/SaiToolkit.ahk rename to Scripts/Sai/SaiToolkit.ahk diff --git a/Misc Old/Steam RemoveAll Markets.ahk b/Scripts/Steam/Remove All Markets.ahk similarity index 100% rename from Misc Old/Steam RemoveAll Markets.ahk rename to Scripts/Steam/Remove All Markets.ahk From 651136e66e0ac287fad21f6a2afd0b45dca51613 Mon Sep 17 00:00:00 2001 From: ElectronicsArchiver <85485984+ElectronicsArchiver@users.noreply.github.com> Date: Sat, 10 Sep 2022 09:09:41 -0400 Subject: [PATCH 02/13] Disabled Script As It was In 'Old' --- Scripts/Sai/Animate Playback.ahk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Scripts/Sai/Animate Playback.ahk b/Scripts/Sai/Animate Playback.ahk index 595e3bf..d9012c0 100644 --- a/Scripts/Sai/Animate Playback.ahk +++ b/Scripts/Sai/Animate Playback.ahk @@ -1,4 +1,6 @@ +Exit + #SingleInstance Force global numberOfFrames := 4 global isPlaying := false From 97c6b0339f756ad242de7d1d0373109761b46d31 Mon Sep 17 00:00:00 2001 From: ElectronicsArchiver <85485984+ElectronicsArchiver@users.noreply.github.com> Date: Sat, 10 Sep 2022 09:15:22 -0400 Subject: [PATCH 03/13] Adjusted Resource Paths --- .../{OpacitySlider(gray).png => Opacity Slider.png} | Bin ...steamremovethislisting.bmp => RemoveListing.bmp} | Bin Resources/{steamkeylisting.bmp => SteamKey.bmp} | Bin Resources/{tester.png => Test.png} | Bin Resources/{topleft.bmp => TopLeft.bmp} | Bin Scripts/Sai/Do Gray Tone.ahk | 2 +- Scripts/Steam/Remove All Markets.ahk | 4 ++-- 7 files changed, 3 insertions(+), 3 deletions(-) rename Resources/{OpacitySlider(gray).png => Opacity Slider.png} (100%) rename Resources/{steamremovethislisting.bmp => RemoveListing.bmp} (100%) rename Resources/{steamkeylisting.bmp => SteamKey.bmp} (100%) rename Resources/{tester.png => Test.png} (100%) rename Resources/{topleft.bmp => TopLeft.bmp} (100%) diff --git a/Resources/OpacitySlider(gray).png b/Resources/Opacity Slider.png similarity index 100% rename from Resources/OpacitySlider(gray).png rename to Resources/Opacity Slider.png diff --git a/Resources/steamremovethislisting.bmp b/Resources/RemoveListing.bmp similarity index 100% rename from Resources/steamremovethislisting.bmp rename to Resources/RemoveListing.bmp diff --git a/Resources/steamkeylisting.bmp b/Resources/SteamKey.bmp similarity index 100% rename from Resources/steamkeylisting.bmp rename to Resources/SteamKey.bmp diff --git a/Resources/tester.png b/Resources/Test.png similarity index 100% rename from Resources/tester.png rename to Resources/Test.png diff --git a/Resources/topleft.bmp b/Resources/TopLeft.bmp similarity index 100% rename from Resources/topleft.bmp rename to Resources/TopLeft.bmp diff --git a/Scripts/Sai/Do Gray Tone.ahk b/Scripts/Sai/Do Gray Tone.ahk index 310319f..bec770f 100644 --- a/Scripts/Sai/Do Gray Tone.ahk +++ b/Scripts/Sai/Do Gray Tone.ahk @@ -22,7 +22,7 @@ renameLayer("Tone") newLayer() renameLayer("Gray") fillLayer() -imageSearchc(fx,fy,0,0,a_screenWidth,a_screenHeight,"./OpacitySlider(gray).png") +imageSearchc(fx,fy,0,0,a_screenWidth,a_screenHeight,"..\..\Resources\OpacitySlider.png") MouseClick, left, fx+110, fy+20 newLayer() renameLayer("Blush") diff --git a/Scripts/Steam/Remove All Markets.ahk b/Scripts/Steam/Remove All Markets.ahk index ab749d1..19846d2 100644 --- a/Scripts/Steam/Remove All Markets.ahk +++ b/Scripts/Steam/Remove All Markets.ahk @@ -4,7 +4,7 @@ Loop{ Loop{ - onScreen := checkIfImageIsOnScreen(".\steamkeylisting.bmp") + onScreen := checkIfImageIsOnScreen("..\..\Resources\SteamKey.bmp") if(onScreen == 1) break Sleep, 500 @@ -12,7 +12,7 @@ Loop{ justClickLocation(1286, 374) Loop{ - onScreen := checkIfImageIsOnScreen(".\steamremovethislisting.bmp") + onScreen := checkIfImageIsOnScreen("..\..\Resources\RemoveListing.bmp") if(onScreen == 1) break Sleep, 500 From b82b4729bf818d887d031b3e838b2e9b3d833994 Mon Sep 17 00:00:00 2001 From: ElectronicsArchiver <85485984+ElectronicsArchiver@users.noreply.github.com> Date: Sat, 10 Sep 2022 09:17:46 -0400 Subject: [PATCH 04/13] Added Editorconfig --- .editorconfig | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..bc7e24c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +insert_final_newline = true +end_of_line = lf + +[*.{md,ahk}] +indent_style = space +indent_size = 4 +charset = utf-8 From b5fc5282f5afd4c2592a5e72f4ee0c0984f7bcba Mon Sep 17 00:00:00 2001 From: ElectronicsArchiver <85485984+ElectronicsArchiver@users.noreply.github.com> Date: Sat, 10 Sep 2022 09:19:01 -0400 Subject: [PATCH 05/13] Formatted Steam Market Remover --- Scripts/Steam/Remove All Markets.ahk | 44 ++++++++++++++++++---------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/Scripts/Steam/Remove All Markets.ahk b/Scripts/Steam/Remove All Markets.ahk index 19846d2..25ed7ed 100644 --- a/Scripts/Steam/Remove All Markets.ahk +++ b/Scripts/Steam/Remove All Markets.ahk @@ -1,27 +1,41 @@ -;Deletes all your market listings + +; +; Removes all your market listings +; + #Include .\RunescapeToolkit.ahk -Loop{ - Loop{ +Loop { + Loop { + onScreen := checkIfImageIsOnScreen("..\..\Resources\SteamKey.bmp") - if(onScreen == 1) - break - Sleep, 500 + + if(onScreen == 1) + break + + Sleep , 500 } - justClickLocation(1286, 374) + + justClickLocation( 1286 , 374 ) - Loop{ + Loop { + onScreen := checkIfImageIsOnScreen("..\..\Resources\RemoveListing.bmp") - if(onScreen == 1) - break - Sleep, 500 + + if(onScreen == 1) + break + + Sleep , 500 } - justClickLocation(1144, 561) - Sleep, 3000 + + justClickLocation( 1144 , 561 ) + + Sleep , 3000 } - return -Esc::ExitApp ;Escape key will exit... place this at the bottom of the script \ No newline at end of file +; Escape key will exit the process + +Esc::ExitApp From e46894c680b8a86f6cc7b7a9d4bc0d5ca872a085 Mon Sep 17 00:00:00 2001 From: ElectronicsArchiver <85485984+ElectronicsArchiver@users.noreply.github.com> Date: Sat, 10 Sep 2022 09:33:36 -0400 Subject: [PATCH 06/13] Formatted Message Purger --- Scripts/Discord/Message Purger.ahk | 247 ++++++++++++++++++----------- 1 file changed, 155 insertions(+), 92 deletions(-) diff --git a/Scripts/Discord/Message Purger.ahk b/Scripts/Discord/Message Purger.ahk index a99f472..1bd1dd6 100644 --- a/Scripts/Discord/Message Purger.ahk +++ b/Scripts/Discord/Message Purger.ahk @@ -1,111 +1,174 @@ -;Do a search for whoever on Discord, this goes through and deletes every message -;Handy for purging messages without banning the OP + +; +; Searches & removes all messages of the +; given person without having to ban them. +; + #Include .\Gdip.ahk #Include .\Gdip_ImageSearch.ahk -CoordMode, Mouse, Screen -CoordMode, Pixel, Screen -Sleep, 1000 +CoordMode , Mouse , Screen +CoordMode , Pixel , Screen + +Sleep , 1000 + + outer: -Loop{ -loopTimer := 0 - Sleep, 1000 - ;Click search bar - Click, 1751, 46 Left, Down - Sleep, 78 - Click, 1751, 46 Left, Down - Sleep, 200 - Send, {Enter} - ;Sleep, 200 - Loop{ - loopTimer := loopTimer+1 - if(loopTimer>50) - { - continue outer + + Loop { + + loopTimer := 0 + + Sleep , 1000 + + ;Click search bar + + Click , 1751 , 46 Left , Down + Sleep , 78 + Click , 1751 , 46 Left , Down + Sleep , 200 + Send , {Enter} + + ;Sleep, 200 + + Loop { + + loopTimer := loopTimer + 1 + + if(loopTimer > 50) + continue outer + + onScreen := checkIfImageIsOnScreen("C:\searching.bmp") + + Sleep , 100 + + if(!onScreen) + break } - onScreen := checkIfImageIsOnScreen("C:\searching.bmp") - Sleep, 100 - if(!onScreen) - break - } - loopTimer := 0 - Sleep, 300 - ;Click post - Click, 1553, 199 Right, Down - Sleep, 47 - Click, 1553, 199 Right, Up - Sleep, 100 - ;Click, 1616, 290 Left, Down - ;Sleep, 100 - ;Click, 1616, 290 Left, Up - ;Use keys instead, fuck it - Sleep, 200 - Send, {Down} - Sleep, 100 - Send, {Down} - Sleep, 100 - Send, {Down} - Sleep, 100 - Send, {Down} - Sleep, 100 - Send, {Enter} - Sleep, 100 - Loop{ - loopTimer := loopTimer+1 - if(loopTimer>50) - { - continue outer + + loopTimer := 0 + + Sleep, 300 + + ;Click post + + Click , 1553 , 199 Right , Down + Sleep , 47 + Click , 1553 , 199 Right , Up + Sleep , 100 + + ;Click, 1616, 290 Left, Down + ;Sleep, 100 + ;Click, 1616, 290 Left, Up + + ; Use keys instead, fuck it + + Sleep , 200 + Send , {Down} + Sleep , 100 + Send , {Down} + Sleep , 100 + Send , {Down} + Sleep , 100 + Send , {Down} + Sleep , 100 + Send , {Enter} + Sleep , 100 + + Loop { + + loopTimer := loopTimer + 1 + + if(loopTimer>50) + continue outer + + onScreen := checkIfImageIsOnScreen2("C:\deletebutton.bmp") + + if(onScreen != 1) + onScreen := checkIfImageIsOnScreen2("C:\deletebutton2.bmp") + + Sleep, 100 + + if(onScreen) + break } - onScreen := checkIfImageIsOnScreen2("C:\deletebutton.bmp") - if(onScreen != 1) - onScreen := checkIfImageIsOnScreen2("C:\deletebutton2.bmp") - Sleep, 100 - if(onScreen) - break + + ; Tab to delete + + Send , {Tab} + Sleep , 100 + Send , {Tab} + Sleep , 100 + + ; Delete + + Send , {Enter} } - ;Tab to delete - Send, {Tab} - Sleep, 100 - Send, {Tab} - Sleep, 100 - ;Delete - Send, {Enter} -} + + return -return +; Escape key will exit the process -Esc::ExitApp ;Escape key will exit... place this at the bottom of the script +Esc::ExitApp -checkIfImageIsOnScreen(topLeftImageLocation){ - imageSearchc(x1,y1,1460,66,1674,140,topLeftImageLocation) - if(x1 == null) - return false - return true + +checkIfImageIsOnScreen( topLeftImageLocation ){ + + imageSearchc( + x1 , y1 , + 1460 , 66 , + 1674 , 140 , + topLeftImageLocation + ) + + return x1 != null } -checkIfImageIsOnScreen2(topLeftImageLocation){ - imageSearchc(x1,y1,1500,400,1700,950,topLeftImageLocation) - if(x1 == null) - return false - return true + +checkIfImageIsOnScreen2( topLeftImageLocation ){ + + imageSearchc( + x1 , y1 , + 1500 , 400 , + 1700 , 950 , + topLeftImageLocation + ) + + return x1 != null } -imageSearchc(byRef out1,byRef out2,x1,y1,x2,y2,image,vari=0,trans="",direction=5,debug=0){ - ptok:=gdip_startup() - imageB:=gdip_createBitmapFromFile(image) - scrn:=gdip_bitmapfromscreen(x1 . "|" . y1 . "|" . x2 - x1 . "|" . y2 - y1) + + +imageSearchc( + byRef out1 , byRef out2 , + Ax , Ay , Bx , By , + image , + vari = 0 , + trans = "" , + direction = 5 , + debug = 0 +){ + + ptok := gdip_startup() + fileMap := gdip_createBitmapFromFile(image) + screenMap := gdip_bitmapfromscreen(Ax . "|" . Ay . "|" . Bx - Ax . "|" . By - Ay) + if(debug) - gdip_saveBitmapToFile(scrn,a_now . ".png") - errorlev:=gdip_imageSearch(scrn,imageB,tempxy,0,0,0,0,vari,trans,direction) - gdip_disposeImage(scrn) - gdip_disposeImage(imageB) -Gdip_Shutdown(ptok) - if(errorlev){ - out:=strSplit(tempxy,"`,") - out1:=out[1] + x1 - out2:=out[2] + y1 - return % errorlev + gdip_saveBitmapToFile(screenMap,a_now . ".png") + + error := gdip_imageSearch(screenMap,fileMap,tempxy,0,0,0,0,vari,trans,direction) + + gdip_disposeImage(screenMap) + gdip_disposeImage(fileMap) + Gdip_Shutdown(ptok) + + if(error){ + out := strSplit(tempxy,"`,") + out1 := out[1] + Ax + out2 := out[2] + Ay + return % error } + return 0 } From e91697cc2b440fe8519b933e7449f9704b08769e Mon Sep 17 00:00:00 2001 From: ElectronicsArchiver <85485984+ElectronicsArchiver@users.noreply.github.com> Date: Sat, 10 Sep 2022 09:44:22 -0400 Subject: [PATCH 07/13] Formatted Sai Animate Playback --- Scripts/Sai/Animate Playback.ahk | 140 ++++++++++++++++++++----------- 1 file changed, 90 insertions(+), 50 deletions(-) diff --git a/Scripts/Sai/Animate Playback.ahk b/Scripts/Sai/Animate Playback.ahk index d9012c0..d78ef9c 100644 --- a/Scripts/Sai/Animate Playback.ahk +++ b/Scripts/Sai/Animate Playback.ahk @@ -2,15 +2,24 @@ Exit #SingleInstance Force + global numberOfFrames := 4 global isPlaying := false + keyFrameUp := Numpad4 keyFrameDown := Numpad5 keyFrameShowOnlyOneLater := Numpad6 + global FPS = 8 -global FPSsleepTime = 1 / FPS * 1000 ;milliseconds to wait on each frame + +; Milliseconds to wait on each frame +global FPSsleepTime = 1 / FPS * 1000 + global BreakLoop -;Go up numberOfFrames pressing keyFrameShowOnlyOneLater each time per framerate, then spam down numberOfFrames + +; Go up numberOfFrames pressing keyFrameShowOnlyOneLater +; each time per framerate, then spam down numberOfFrames + GetFrameNumber() ;pressButton(Numpad4) @@ -22,88 +31,119 @@ GetFrameNumber() ;} -DoLoop(numberOfFrames, FPSsleepTime){ -;MsgBox, %numberOfFrames% - Loop{ - if (BreakLoop = 1) - break - Loop, % numberOfFrames - 1 - { - if (BreakLoop = 1) + +DoLoop( frames , delay ){ + + ;MsgBox, %frames% + + Loop { + + if(BreakLoop = 1) break - moveUpFrame() - Sleep FPSsleepTime + + Loop , % frames - 1 { + + if(BreakLoop = 1) + break + + moveUpFrame() + + Sleep delay } - if (BreakLoop = 1) + + if(BreakLoop = 1) break - resetToBottom(numberOfFrames - 1) - Sleep FPSsleepTime + + resetToBottom(frames - 1) + + Sleep delay } } + return -;Esc::ExitApp ;Escape key will exit... place this at the bottom of the script + +; Escape key will exit the process +;Esc::ExitApp + + moveUpFrame(){ - Send, {Numpad4 Down} - Send, {Numpad4 Up} + + Send , { Numpad4 Down } + Send , { Numpad4 Up } + ShowOnlyCurrentLayer() } + ShowOnlyCurrentLayer(){ - Send, {Numpad6 Down} - Send, {Numpad6 Up} + Send , { Numpad6 Down } + Send , { Numpad6 Up } } + resetToBottom(numberOfFrames){ - Loop, % numberOfFrames{ - Send, {Numpad5 Down} - Sleep 15 - ;Send, {Numpad5 Up} + + Loop , % numberOfFrames { + + Send , { Numpad5 Down } + + Sleep 15 + + ;Send, { Numpad5 Up } } - Send, {Numpad5 Up} + + Send , {Numpad5 Up} + ShowOnlyCurrentLayer() } -pressButton(butt){ - Send, {%butt% Down} +pressButton( button ){ + Send , { %button% Down } Sleep 50 - Send, {%butt% Up} + Send , { %button% Up } } traverseUpWithOnionSkin(){ -;Set layer transparency to 30 -;Make new layer -;Fill new layer with green -;Make new layer be masked by previous -;Move up layer selection + ;Set layer transparency to 30 + ;Make new layer + ;Fill new layer with green + ;Make new layer be masked by previous + ;Move up layer selection } shiftDown(){ -Send, {Shift Down} + Send , { Shift Down } } + shiftUp(){ -Send, {Shift Up} + Send , { Shift Up } } -RandSleep(x,y) { - Random, rand, %x%, %y% + +RandSleep( x , y ){ + Random , rand , %x% , %y% Sleep %rand% } + GetFrameNumber(){ -InputBox, numberOfFrames, Number of Frames, Enter number of frames., , 150, 150 + InputBox , numberOfFrames, Number of Frames, Enter number of frames., , 150, 150 } + Esc:: -BreakLoop = 1 -isPlaying := !isPlaying -return + BreakLoop = 1 + isPlaying := !isPlaying + return 1:: GetFrameNumber() -return + return `:: -if(!isPlaying){ - BreakLoop := 0 - DoLoop(numberOfFrames, FPSsleepTime) -}else{ - BreakLoop := 1 -} -isPlaying := !isPlaying -return \ No newline at end of file + if(!isPlaying){ + BreakLoop := 0 + DoLoop(numberOfFrames,FPSsleepTime) + } else { + BreakLoop := 1 + } + + isPlaying := !isPlaying + + return From fac98a7f35fc0f9795b00f2eefa5df9ee938242b Mon Sep 17 00:00:00 2001 From: ElectronicsArchiver <85485984+ElectronicsArchiver@users.noreply.github.com> Date: Sat, 10 Sep 2022 09:45:44 -0400 Subject: [PATCH 08/13] Formatted Do Gray Tone --- Scripts/Sai/Do Gray Tone.ahk | 41 +++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/Scripts/Sai/Do Gray Tone.ahk b/Scripts/Sai/Do Gray Tone.ahk index bec770f..3e73f8f 100644 --- a/Scripts/Sai/Do Gray Tone.ahk +++ b/Scripts/Sai/Do Gray Tone.ahk @@ -1,20 +1,24 @@ -;Pre-select areas to NOT shade -;Invert selection -;Contract -;Add folder -;Add shade layer -;Fill with black -;Change opacity to like 25% -;Add blush layer -;Add hilight layer + +; Pre-select areas to NOT shade +; Invert selection +; Contract +; Add folder +; Add shade layer +; Fill with black +; Change opacity to like 25% +; Add blush layer +; Add hilight layer #Include ./SaiToolkit.ahk -#Include .\Gdip.ahk -#Include .\Gdip_ImageSearch.ahk -coordMode,pixel +#Include ./Gdip.ahk +#Include ./Gdip_ImageSearch.ahk + +coordMode , pixel + focusSai() sleep 200 + invertSelection() erodeSelection() newFolder() @@ -22,9 +26,16 @@ renameLayer("Tone") newLayer() renameLayer("Gray") fillLayer() -imageSearchc(fx,fy,0,0,a_screenWidth,a_screenHeight,"..\..\Resources\OpacitySlider.png") -MouseClick, left, fx+110, fy+20 + +imageSearchc( + fx , fy , 0 , 0 , + a_screenWidth , a_screenHeight , + "..\..\Resources\OpacitySlider.png" +) + +MouseClick , left , fx + 110 , fy + 20 + newLayer() renameLayer("Blush") newLayer() -renameLayer("Hilights") \ No newline at end of file +renameLayer("Hilights") From 3605c1656697c251fb5a37525b07a5b3380b4c88 Mon Sep 17 00:00:00 2001 From: ElectronicsArchiver <85485984+ElectronicsArchiver@users.noreply.github.com> Date: Sat, 10 Sep 2022 09:48:48 -0400 Subject: [PATCH 09/13] Formatted Layer Chain Renamer --- Scripts/Sai/Layer Chain Renamer.ahk | 94 +++++++++++++++++------------ 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/Scripts/Sai/Layer Chain Renamer.ahk b/Scripts/Sai/Layer Chain Renamer.ahk index 865ee29..a42e7f6 100644 --- a/Scripts/Sai/Layer Chain Renamer.ahk +++ b/Scripts/Sai/Layer Chain Renamer.ahk @@ -1,48 +1,62 @@ -;Layer renamer -;Goes up from the currently selected layer and renames all layers to [your input]-# + +; +; Layer Renamer +; +; Goes up from the currently selected layer +; and renames all layers to [your input]-# +; + #Include ./SaiToolkit.ahk -topLayerHit := false -previousLayerName :="" -thisLayerName :="" +previousLayerName := "" +baseLayerName := "Frame" +thisLayerName := "" newLayerName := "" +topLayerHit := false counter := 1 -baseLayerName := "Frame" -InputBox, baseLayerName, Enter Name, Enter layer base name (result will be "Basename-#"):, , 300, 150 +InputBox , baseLayerName , Enter Name , Enter layer base name (result will be "Basename-#"): , , 300 , 150 focusSai() -While !topLayerHit{ - - ;Get the layer name - pressButton(layerPropertiesKey) - thisLayerName := getHighlighted() - - if(thisLayerName = previousLayerName){ - topLayerHit := true - ;MsgBox dsfgdfg %topLayerHit% - } - else - { - newLayerName := baseLayerName "-" counter - ;MsgBox %newLayerName% - send %newLayerName% - pressButton("Enter") - goUpLayer() - counter := counter+1 - ;MsgBox thisLayerName %thisLayerName% previousLayerName %previousLayerName% - previousLayerName := newLayerName - } - - ;Close properties pane - ;pressButton("Tab") - ;pressButton("Tab") - pressButton(acceptKey) - -;MsgBox topLayerHit %topLayerHit% - -sleep, 150 - } - - Esc::ExitApp \ No newline at end of file + +While ! topLayerHit { + + ; Get the layer name + + pressButton(layerPropertiesKey) + thisLayerName := getHighlighted() + + if(thisLayerName = previousLayerName){ + topLayerHit := true + ;MsgBox dsfgdfg %topLayerHit% + } else { + + newLayerName := baseLayerName "-" counter + + ;MsgBox %newLayerName% + + send %newLayerName% + + pressButton("Enter") + goUpLayer() + + counter := counter + 1 + + ;MsgBox thisLayerName %thisLayerName% previousLayerName %previousLayerName% + + previousLayerName := newLayerName + } + + ; Close properties pane + + ;pressButton("Tab") + ;pressButton("Tab") + pressButton(acceptKey) + + ;MsgBox topLayerHit %topLayerHit% + + sleep , 150 +} + +Esc::ExitApp From eae3fb8dfc4fbe7e2742c9491413256411d85559 Mon Sep 17 00:00:00 2001 From: ElectronicsArchiver <85485984+ElectronicsArchiver@users.noreply.github.com> Date: Sat, 10 Sep 2022 09:50:38 -0400 Subject: [PATCH 10/13] Formatted Layer Exporter --- Scripts/Sai/Layer Exporter.ahk | 59 ++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/Scripts/Sai/Layer Exporter.ahk b/Scripts/Sai/Layer Exporter.ahk index 534356b..c1053e5 100644 --- a/Scripts/Sai/Layer Exporter.ahk +++ b/Scripts/Sai/Layer Exporter.ahk @@ -1,40 +1,49 @@ -;Layer exporter -;Go up from current layer until top layer is reached -;Detect top layer by scraping the layer name from the clipboard? and when it's the same one twice then end? + +; +; Layer exporter +; +; Go up from current layer until top layer is reached +; +; Detect top layer by scraping the layer name from the +; clipboard? and when it's the same one twice then end? +; + #Include ./SaiToolkit.ahk -topLayerHit := false -previousLayerName :="" -thisLayerName :="" +previousLayerName := "" +baseLayerName := "Frame-" +thisLayerName := "" newLayerName := "" +topLayerHit := false counter := 1 -baseLayerName := "Frame-" + focusSai() showAloneLayer() -While !topLayerHit{ - ;Get the layer name - ;pressButton(layerPropertiesKey) - thisLayerName := getCurrentLayerName() +While ! topLayerHit { + + ; Get the layer name - if(thisLayerName = previousLayerName){ - topLayerHit := true - ;MsgBox dsfgdfg %topLayerHit% - } - else - { + ;pressButton(layerPropertiesKey) + thisLayerName := getCurrentLayerName() - exportCurrent(thisLayerName) - previousLayerName := thisLayerName - goUpLayer() - } + if(thisLayerName = previousLayerName){ + + topLayerHit := true + + ;MsgBox dsfgdfg %topLayerHit% + } else { + exportCurrent(thisLayerName) + previousLayerName := thisLayerName + goUpLayer() + } -;MsgBox topLayerHit %topLayerHit% + ;MsgBox topLayerHit %topLayerHit% -sleep, 150 - } + sleep , 150 +} - Esc::ExitApp \ No newline at end of file +Esc::ExitApp From 6d0622205e03e1d54505fbcaa93ebe45dd1ccaee Mon Sep 17 00:00:00 2001 From: ElectronicsArchiver <85485984+ElectronicsArchiver@users.noreply.github.com> Date: Sat, 10 Sep 2022 10:48:38 -0400 Subject: [PATCH 11/13] Formatted SaiToolkit --- Scripts/Sai/SaiToolkit.ahk | 215 ++++++++++++++++++++++++++----------- 1 file changed, 152 insertions(+), 63 deletions(-) diff --git a/Scripts/Sai/SaiToolkit.ahk b/Scripts/Sai/SaiToolkit.ahk index 93bcb85..955ca1c 100644 --- a/Scripts/Sai/SaiToolkit.ahk +++ b/Scripts/Sai/SaiToolkit.ahk @@ -1,64 +1,94 @@ -;SaiToolkit +; SaiToolkit + #SingleInstance Force + CoordMode, Mouse, Screen CoordMode, Pixel, Screen -;Define globals -global acceptKey := "Enter" -global forwardLayerKey := "F1" -global backwardLayerKey := "F3" -global showAloneLayerKey := "F4" + + +; Define globals + global layerPropertiesKey := "F5" -global exportPngKey := "F8" -global erodeSelectionKey := "F7" global invertSelectionKey := "F6" -global newLayerKey := "F10" +global showAloneLayerKey := "F4" +global erodeSelectionKey := "F7" +global backwardLayerKey := "F3" +global forwardLayerKey := "F1" +global exportPngKey := "F8" global newFolderKey := "F9" +global newLayerKey := "F10" +global acceptKey := "Enter" global fillKey := "F12" + ;exportCurrent("test") + renameLayer(newName){ - pressButton(layerPropertiesKey) - Sleep 50 - thisLayerName := getHighlighted() - send %newName% - pressButton(acceptKey) + + pressButton(layerPropertiesKey) + + Sleep 50 + + thisLayerName := getHighlighted() + + send %newName% + + pressButton(acceptKey) } fillLayer(){ pressButton(fillKey) } + newLayer(){ pressButton(newLayerKey) } + newFolder(){ pressButton(newFolderKey) } + invertSelection(){ pressButton(invertSelectionKey) } + erodeSelection(){ + pressButton(erodeSelectionKey) + Sleep 100 + pressButton(acceptKey) } -exportCurrent(fileName := ""){ - focusSai() +exportCurrent( fileName := "" ){ + + focusSai() ctrlDown() pressButton(exportPngKey) ctrlUp() - Sleep 100 - if(fileName != "") + + Sleep 100 + + if(fileName != "") Send %fileName% - pressButton(acceptKey) + + pressButton(acceptKey) + Sleep 500 - WinGetTitle, title, Confirm - if(title == "Confirm Save As"){ - pressButton("Tab") - Sleep 100 - pressButton(acceptKey) + + WinGetTitle , title , Confirm + + if(title == "Confirm Save As"){ + + pressButton("Tab") + + Sleep 100 + + pressButton(acceptKey) } + Sleep 1000 } @@ -67,69 +97,128 @@ showAloneLayer(){ } getCurrentLayerName(){ + result := "" - focusSai() + + focusSai() pressButton(layerPropertiesKey) - result := getHighlighted() - pressButton("Tab") + + result := getHighlighted() + + pressButton("Tab") pressButton("Tab") pressButton(acceptKey) - return result + + return result } -;Uses the clipboard to get whatever's currently highlighted + +; Uses the clipboard to get +; whatever's currently highlighted + getHighlighted(){ - clipsaved:= clipboard ;Save clipboard - clipboard := "" ;Erase clipboard - Send, ^c ;Set clipboard - Sleep 200 ;Wait so Windows can process - clipsaved2 := clipboard ;Get Clipboard contents - clipboard := clipsaved ;Reset clipboard back to what it was before - Sleep 200 - return clipsaved2 ;Return whatever text was highlighted + + ; Save clipboard + + clipsaved := clipboard + + ; Erase clipboard + + clipboard := "" + + ; Set clipboard + + Send , ^c + + ; Wait so Windows can process + + Sleep 200 + + ; Get Clipboard contents + + clipsaved2 := clipboard + + ; Reset clipboard back to what it was before + + clipboard := clipsaved + + Sleep 200 + + ; Return whatever text was highlighted + + return clipsaved2 } focusSai(){ - WinActivate, PaintTool SAI + WinActivate , PaintTool SAI } + shiftDown(){ -Send, {Shift Down} + Send , { Shift Down } } + shiftUp(){ -Send, {Shift Up} + Send , { Shift Up } } + ctrlDown(){ -Send, {Ctrl Down} + Send , { Ctrl Down} } + ctrlUp(){ -Send, {Ctrl Up} + Send , { Ctrl Up } } -pressButton(butt){ - Send, {%butt% Down} + +pressButton( button ){ + + Send , { %button% Down } + Sleep 50 - Send, {%butt% Up} + + Send , { %button% Up } } + goUpLayer(){ pressButton(forwardLayerKey) } -;https://github.com/Masonjar13/AHK-Library -;TODO figure out if I can put this into the standard library and still have it be accessable for others -imageSearchc(byRef out1,byRef out2,x1,y1,x2,y2,image,vari:=0,trans:="",direction:=5,debug:=0){ - static ptok:=gdip_startup() - imageB:=gdip_createBitmapFromFile(image) - scrn:=gdip_bitmapfromscreen(x1 "|" y1 "|" x2 - x1 "|" y2 - y1) - if(debug) - gdip_saveBitmapToFile(scrn,a_now ".png") - errorlev:=gdip_imageSearch(scrn,imageB,tempxy,0,0,0,0,vari,trans,direction) - gdip_disposeImage(scrn) - gdip_disposeImage(imageB) - - if (errorlev) { - out:=strSplit(tempxy,"`,") - out1:=out[1] + x1 - out2:=out[2] + y1 - return % errorlev + +; https://github.com/Masonjar13/AHK-Library +; TODO figure out if I can put this into the standard library and still have it be accessable for others + +imageSearchc( + byRef out1 , byRef out2 , + Ax , Ay , Bx , By , + image , + vari := 0 , + trans := "" , + direction := 5 , + debug := 0 +){ + + static ptok := gdip_startup() + + fileMap := gdip_createBitmapFromFile(image) + screenMap := gdip_bitmapfromscreen( Ax "|" Ay "|" Bx - Ax "|" By - Ay ) + + if(debug) + gdip_saveBitmapToFile(screenMap,a_now ".png") + + error := gdip_imageSearch( + screenMap , fileMap , tempxy , + 0 , 0 , 0 , 0 , vari , trans , + direction + ) + + gdip_disposeImage(screenMap) + gdip_disposeImage(fileMap) + + if(error){ + out := strSplit(tempxy,"`,") + out1 := out[1] + Ax + out2 := out[2] + Ay + return % error } + return 0 -} \ No newline at end of file +} From 1f082ab694823a98b2bcf49a9063a19817b6f14f Mon Sep 17 00:00:00 2001 From: ElectronicsArchiver <85485984+ElectronicsArchiver@users.noreply.github.com> Date: Sun, 11 Sep 2022 21:40:27 -0400 Subject: [PATCH 12/13] Fixed Up Code --- Scripts/Discord/Message Purger.ahk | 103 +- Scripts/{Sai => Libraries}/Gdip.ahk | 1699 ++++++----------- .../{Sai => Libraries}/Gdip_ImageSearch.ahk | 2 +- Scripts/Libraries/ImageSearch.ahk | 46 + .../{Sai/SaiToolkit.ahk => Libraries/Sai.ahk} | 50 +- Scripts/Sai/Animate Playback.ahk | 19 +- Scripts/Sai/Do Gray Tone.ahk | 25 +- Scripts/Sai/Layer Chain Renamer.ahk | 9 +- Scripts/Sai/Layer Exporter.ahk | 3 +- Scripts/Steam/Remove All Markets.ahk | 3 +- 10 files changed, 660 insertions(+), 1299 deletions(-) rename Scripts/{Sai => Libraries}/Gdip.ahk (51%) rename Scripts/{Sai => Libraries}/Gdip_ImageSearch.ahk (99%) create mode 100644 Scripts/Libraries/ImageSearch.ahk rename Scripts/{Sai/SaiToolkit.ahk => Libraries/Sai.ahk} (71%) diff --git a/Scripts/Discord/Message Purger.ahk b/Scripts/Discord/Message Purger.ahk index 1bd1dd6..44ee01a 100644 --- a/Scripts/Discord/Message Purger.ahk +++ b/Scripts/Discord/Message Purger.ahk @@ -1,12 +1,14 @@ ; -; Searches & removes all messages of the -; given person without having to ban them. +; Searches & removes all messages of the +; given person without having to ban them. ; -#Include .\Gdip.ahk -#Include .\Gdip_ImageSearch.ahk +#Include ..\Libraries\Gdip.ahk +#Include ..\Libraries\Gdip_ImageSearch.ahk +#Include ..\Libraries\ImageSearch.ahk + CoordMode , Mouse , Screen CoordMode , Pixel , Screen @@ -28,7 +30,7 @@ outer: Sleep , 78 Click , 1751 , 46 Left , Down Sleep , 200 - Send , {Enter} + Send , { Enter } ;Sleep, 200 @@ -39,7 +41,7 @@ outer: if(loopTimer > 50) continue outer - onScreen := checkIfImageIsOnScreen("C:\searching.bmp") + onScreen := isImageOnScreenA("C:\searching.bmp") Sleep , 100 @@ -65,28 +67,28 @@ outer: ; Use keys instead, fuck it Sleep , 200 - Send , {Down} + Send , { Down } Sleep , 100 - Send , {Down} + Send , { Down } Sleep , 100 - Send , {Down} + Send , { Down } Sleep , 100 - Send , {Down} + Send , { Down } Sleep , 100 - Send , {Enter} + Send , { Enter } Sleep , 100 Loop { loopTimer := loopTimer + 1 - if(loopTimer>50) + if(loopTimer > 50) continue outer - onScreen := checkIfImageIsOnScreen2("C:\deletebutton.bmp") + onScreen := isImageOnScreenB("C:\deletebutton.bmp") if(onScreen != 1) - onScreen := checkIfImageIsOnScreen2("C:\deletebutton2.bmp") + onScreen := isImageOnScreenB("C:\deletebutton2.bmp") Sleep, 100 @@ -96,14 +98,14 @@ outer: ; Tab to delete - Send , {Tab} + Send , { Tab } Sleep , 100 - Send , {Tab} + Send , { Tab } Sleep , 100 ; Delete - Send , {Enter} + Send , { Enter } } @@ -115,60 +117,25 @@ outer: Esc::ExitApp -checkIfImageIsOnScreen( topLeftImageLocation ){ - - imageSearchc( - x1 , y1 , - 1460 , 66 , - 1674 , 140 , - topLeftImageLocation - ) - - return x1 != null +isImageOnScreenA( image ){ + return isImageOnScreen( image + , [ 1460 , 66 ] + , [ 1674 , 140 ] ) } -checkIfImageIsOnScreen2( topLeftImageLocation ){ - - imageSearchc( - x1 , y1 , - 1500 , 400 , - 1700 , 950 , - topLeftImageLocation - ) - - return x1 != null +isImageOnScreenB( image ){ + return isImageOnScreen( image + , [ 1500 , 400 ] + , [ 1700 , 950 ] ) } - -imageSearchc( - byRef out1 , byRef out2 , - Ax , Ay , Bx , By , - image , - vari = 0 , - trans = "" , - direction = 5 , - debug = 0 -){ +isImageOnScreen( image , from , to ){ - ptok := gdip_startup() - fileMap := gdip_createBitmapFromFile(image) - screenMap := gdip_bitmapfromscreen(Ax . "|" . Ay . "|" . Bx - Ax . "|" . By - Ay) - - if(debug) - gdip_saveBitmapToFile(screenMap,a_now . ".png") - - error := gdip_imageSearch(screenMap,fileMap,tempxy,0,0,0,0,vari,trans,direction) - - gdip_disposeImage(screenMap) - gdip_disposeImage(fileMap) - Gdip_Shutdown(ptok) - - if(error){ - out := strSplit(tempxy,"`,") - out1 := out[1] + Ax - out2 := out[2] + Ay - return % error - } - - return 0 + options := { image : image + , from : from + , to : to } + + imageSearchc( x1 , y1 , options ) + + return x1 != null } diff --git a/Scripts/Sai/Gdip.ahk b/Scripts/Libraries/Gdip.ahk similarity index 51% rename from Scripts/Sai/Gdip.ahk rename to Scripts/Libraries/Gdip.ahk index 5e6d888..b387d8a 100644 --- a/Scripts/Sai/Gdip.ahk +++ b/Scripts/Libraries/Gdip.ahk @@ -1,21 +1,4 @@ -; Gdip standard library v1.54 on 11/15/2017 -; Gdip standard library v1.53 on 6/19/2017 -; Gdip standard library v1.52 on 6/11/2017 -; Gdip standard library v1.51 on 1/27/2017 -; Gdip standard library v1.50 on 11/20/16 ; Gdip standard library v1.45 by tic (Tariq Porter) 07/09/11 -; Modifed by Rseding91 using fincs 64 bit compatible Gdip library 5/1/2013 -; Supports: Basic, _L ANSi, _L Unicode x86 and _L Unicode x64 -; -; Updated 11/15/2017 - compatibility with both AHK v2 and v1, restored by nnnik -; Updated 6/19/2017 - Fixed few bugs from old syntax by Bartlomiej Uliasz -; Updated 6/11/2017 - made code compatible with new AHK v2.0-a079-be5df98 by Bartlomiej Uliasz -; Updated 1/27/2017 - fixed some bugs and made #Warn All compatible by Bartlomiej Uliasz -; Updated 11/20/2016 - fixed Gdip_BitmapFromBRA() by 'just me' -; Updated 11/18/2016 - backward compatible support for both AHK v1.1 and AHK v2 -; Updated 11/15/2016 - initial AHK v2 support by guest3456 -; Updated 2/20/2014 - fixed Gdip_CreateRegion() and Gdip_GetClipRegion() on AHK Unicode x86 -; Updated 5/13/2013 - fixed Gdip_SetBitmapToClipboard() on AHK Unicode x64 ; ;##################################################################################### ;##################################################################################### @@ -51,64 +34,49 @@ ; FUNCTIONS ;##################################################################################### ; -; UpdateLayeredWindow(hwnd, hdc, x:="", y:="", w:="", h:="", Alpha:=255) -; BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster:="") -; StretchBlt(dDC, dx, dy, dw, dh, sDC, sx, sy, sw, sh, Raster:="") +; UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255) +; BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="") +; StretchBlt(dDC, dx, dy, dw, dh, sDC, sx, sy, sw, sh, Raster="") ; SetImage(hwnd, hBitmap) -; Gdip_BitmapFromScreen(Screen:=0, Raster:="") +; Gdip_BitmapFromScreen(Screen=0, Raster="") ; CreateRectF(ByRef RectF, x, y, w, h) ; CreateSizeF(ByRef SizeF, w, h) ; CreateDIBSection ; ;##################################################################################### -; Function: UpdateLayeredWindow -; Description: Updates a layered window with the handle to the DC of a gdi bitmap -; -; hwnd Handle of the layered window to update -; hdc Handle to the DC of the GDI bitmap to update the window with -; Layeredx x position to place the window -; Layeredy y position to place the window -; Layeredw Width of the window -; Layeredh Height of the window -; Alpha Default = 255 : The transparency (0-255) to set the window transparency +; Function: UpdateLayeredWindow +; Description: Updates a layered window with the handle to the DC of a gdi bitmap +; +; hwnd Handle of the layered window to update +; hdc Handle to the DC of the GDI bitmap to update the window with +; Layeredx x position to place the window +; Layeredy y position to place the window +; Layeredw Width of the window +; Layeredh Height of the window +; Alpha Default = 255 : The transparency (0-255) to set the window transparency ; -; return If the function succeeds, the return value is nonzero +; return If the function succeeds, the return value is nonzero ; ; notes If x or y omitted, then layered window will use its current coordinates ; If w or h omitted then current width and height will be used -UpdateLayeredWindow(hwnd, hdc, x:="", y:="", w:="", h:="", Alpha:=255) +UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - if ((x != "") && (y != "")) - VarSetCapacity(pt, 8), NumPut(x, pt, 0, "UInt"), NumPut(y, pt, 4, "UInt") + VarSetCapacity(pt, 8), NumPut(x, pt, 0), NumPut(y, pt, 4) - if (w = "") || (h = "") - { - CreateRect( winRect, 0, 0, 0, 0 ) ;is 16 on both 32 and 64 - DllCall( "GetWindowRect", Ptr, hwnd, Ptr, &winRect ) - w := NumGet(winRect, 8, "UInt") - NumGet(winRect, 0, "UInt") - h := NumGet(winRect, 12, "UInt") - NumGet(winRect, 4, "UInt") - } - - return DllCall("UpdateLayeredWindow" - , Ptr, hwnd - , Ptr, 0 - , Ptr, ((x = "") && (y = "")) ? 0 : &pt - , "int64*", w|h<<32 - , Ptr, hdc - , "int64*", 0 - , "uint", 0 - , "UInt*", Alpha<<16|1<<24 - , "uint", 2) + if (w = "") ||(h = "") + WinGetPos,,, w, h, ahk_id %hwnd% + + return DllCall("UpdateLayeredWindow", "uint", hwnd, "uint", 0, "uint", ((x = "") && (y = "")) ? 0 : &pt + , "int64*", w|h<<32, "uint", hdc, "int64*", 0, "uint", 0, "uint*", Alpha<<16|1<<24, "uint", 2) } ;##################################################################################### ; Function BitBlt -; Description The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle +; Description The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle ; of pixels from the specified source device context into a destination device context. ; ; dDC handle to destination DC @@ -143,26 +111,16 @@ UpdateLayeredWindow(hwnd, hdc, x:="", y:="", w:="", h:="", Alpha:=255) ; CAPTUREBLT = 0x40000000 ; NOMIRRORBITMAP = 0x80000000 -BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster:="") +BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="") { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdi32\BitBlt" - , Ptr, dDC - , "int", dx - , "int", dy - , "int", dw - , "int", dh - , Ptr, sDC - , "int", sx - , "int", sy - , "uint", Raster ? Raster : 0x00CC0020) + return DllCall("gdi32\BitBlt", "uint", dDC, "int", dx, "int", dy, "int", dw, "int", dh + , "uint", sDC, "int", sx, "int", sy, "uint", Raster ? Raster : 0x00CC0020) } ;##################################################################################### ; Function StretchBlt -; Description The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, +; Description The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, ; stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary. ; The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context. ; @@ -180,24 +138,12 @@ BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster:="") ; ; return If the function succeeds, the return value is nonzero ; -; notes If no raster operation is specified, then SRCCOPY is used. It uses the same raster operations as BitBlt +; notes If no raster operation is specified, then SRCCOPY is used. It uses the same raster operations as BitBlt -StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster:="") +StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster="") { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdi32\StretchBlt" - , Ptr, ddc - , "int", dx - , "int", dy - , "int", dw - , "int", dh - , Ptr, sdc - , "int", sx - , "int", sy - , "int", sw - , "int", sh - , "uint", Raster ? Raster : 0x00CC0020) + return DllCall("gdi32\StretchBlt", "uint", ddc, "int", dx, "int", dy, "int", dw, "int", dh + , "uint", sdc, "int", sx, "int", sy, "int", sw, "int", sh, "uint", Raster ? Raster : 0x00CC0020) } ;##################################################################################### @@ -215,11 +161,9 @@ StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster:="") ; STRETCH_DELETESCANS = 0x03 ; STRETCH_HALFTONE = 0x04 -SetStretchBltMode(hdc, iStretchMode:=4) +SetStretchBltMode(hdc, iStretchMode=4) { - return DllCall("gdi32\SetStretchBltMode" - , A_PtrSize ? "UPtr" : "UInt", hdc - , "int", iStretchMode) + return DllCall("gdi32\SetStretchBltMode", "uint", hdc, "int", iStretchMode) } ;##################################################################################### @@ -234,8 +178,8 @@ SetStretchBltMode(hdc, iStretchMode:=4) SetImage(hwnd, hBitmap) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - E := DllCall( "SendMessage", Ptr, hwnd, "UInt", 0x172, "UInt", 0x0, Ptr, hBitmap ) + SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd% + E := ErrorLevel DeleteObject(E) return E } @@ -290,22 +234,18 @@ SetImage(hwnd, hBitmap) ; COLOR_WINDOWFRAME = 6 ; COLOR_WINDOWTEXT = 8 -SetSysColorToControl(hwnd, SysColor:=15) -{ - Ptr := A_PtrSize ? "UPtr" : "UInt" - CreateRect( winRect, 0, 0, 0, 0 ) ;is 16 on both 32 and 64 - DllCall( "GetWindowRect", Ptr, hwnd, Ptr, &winRect ) - w := NumGet(winRect, 8, "UInt") - NumGet(winRect, 0, "UInt") - h := NumGet(winRect, 12, "UInt") - NumGet(winRect, 4, "UInt") - bc := DllCall("GetSysColor", "Int", SysColor, "UInt") - pBrushClear := Gdip_BrushCreateSolid(0xff000000 | (bc >> 16 | bc & 0xff00 | (bc & 0xff) << 16)) - pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap) - Gdip_FillRectangle(G, pBrushClear, 0, 0, w, h) - hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap) - SetImage(hwnd, hBitmap) - Gdip_DeleteBrush(pBrushClear) - Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), DeleteObject(hBitmap) - return 0 +SetSysColorToControl(hwnd, SysColor=15) +{ + WinGetPos,,, w, h, ahk_id %hwnd% + bc := DllCall("GetSysColor", "Int", SysColor) + pBrushClear := Gdip_BrushCreateSolid(0xff000000 | (bc >> 16 | bc & 0xff00 | (bc & 0xff) << 16)) + pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap) + Gdip_FillRectangle(G, pBrushClear, 0, 0, w, h) + hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap) + SetImage(hwnd, hBitmap) + Gdip_DeleteBrush(pBrushClear) + Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), DeleteObject(hBitmap) + return 0 } ;##################################################################################### @@ -318,52 +258,47 @@ SetSysColorToControl(hwnd, SysColor:=15) ; x|y|w|h = Take specific coordinates with a width and height ; Raster raster operation code ; -; return If the function succeeds, the return value is a pointer to a gdi+ bitmap +; return If the function succeeds, the return value is a pointer to a gdi+ bitmap ; -1: one or more of x,y,w,h not passed properly ; ; notes If no raster operation is specified, then SRCCOPY is used to the returned bitmap -Gdip_BitmapFromScreen(Screen:=0, Raster:="") +Gdip_BitmapFromScreen(Screen=0, Raster="") { - hhdc := 0 - Ptr := A_PtrSize ? "UPtr" : "UInt" if (Screen = 0) { - _x := DllCall( "GetSystemMetrics", "Int", 76 ) - _y := DllCall( "GetSystemMetrics", "Int", 77 ) - _w := DllCall( "GetSystemMetrics", "Int", 78 ) - _h := DllCall( "GetSystemMetrics", "Int", 79 ) + Sysget, x, 76 + Sysget, y, 77 + Sysget, w, 78 + Sysget, h, 79 } else if (SubStr(Screen, 1, 5) = "hwnd:") { Screen := SubStr(Screen, 6) - if !WinExist("ahk_id " Screen) + if !WinExist( "ahk_id " Screen) return -2 - CreateRect( winRect, 0, 0, 0, 0 ) ;is 16 on both 32 and 64 - DllCall( "GetWindowRect", Ptr, Screen, Ptr, &winRect ) - _w := NumGet(winRect, 8, "UInt") - NumGet(winRect, 0, "UInt") - _h := NumGet(winRect, 12, "UInt") - NumGet(winRect, 4, "UInt") - _x := _y := 0 + WinGetPos,,, w, h, ahk_id %Screen% + x := y := 0 hhdc := GetDCEx(Screen, 3) } - else if IsInteger(Screen) + else if (Screen&1 != "") { - M := GetMonitorInfo(Screen) - _x := M.Left, _y := M.Top, _w := M.Right-M.Left, _h := M.Bottom-M.Top + Sysget, M, Monitor, %Screen% + x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop } else { - S := StrSplit(Screen, "|") - _x := S[1], _y := S[2], _w := S[3], _h := S[4] + StringSplit, S, Screen, | + x := S1, y := S2, w := S3, h := S4 } - if (_x = "") || (_y = "") || (_w = "") || (_h = "") + if (x = "") || (y = "") || (w = "") || (h = "") return -1 - chdc := CreateCompatibleDC(), hbm := CreateDIBSection(_w, _h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC() - BitBlt(chdc, 0, 0, _w, _h, hhdc, _x, _y, Raster) + chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC() + BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster) ReleaseDC(hhdc) - + pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm) SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc) return pBitmap @@ -382,11 +317,7 @@ Gdip_BitmapFromScreen(Screen:=0, Raster:="") Gdip_BitmapFromHWND(hwnd) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - CreateRect( winRect, 0, 0, 0, 0 ) ;is 16 on both 32 and 64 - DllCall( "GetWindowRect", Ptr, hwnd, Ptr, &winRect ) - Width := NumGet(winRect, 8, "UInt") - NumGet(winRect, 0, "UInt") - Height := NumGet(winRect, 12, "UInt") - NumGet(winRect, 4, "UInt") + WinGetPos,,, Width, Height, ahk_id %hwnd% hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm) PrintWindow(hwnd, hdc) pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm) @@ -396,35 +327,35 @@ Gdip_BitmapFromHWND(hwnd) ;##################################################################################### -; Function CreateRectF +; Function CreateRectF ; Description Creates a RectF object, containing a the coordinates and dimensions of a rectangle ; -; RectF Name to call the RectF object -; x x-coordinate of the upper left corner of the rectangle -; y y-coordinate of the upper left corner of the rectangle -; w Width of the rectangle -; h Height of the rectangle +; RectF Name to call the RectF object +; x x-coordinate of the upper left corner of the rectangle +; y y-coordinate of the upper left corner of the rectangle +; w Width of the rectangle +; h Height of the rectangle ; -; return No return value +; return No return value CreateRectF(ByRef RectF, x, y, w, h) { - VarSetCapacity(RectF, 16) - NumPut(x, RectF, 0, "float"), NumPut(y, RectF, 4, "float"), NumPut(w, RectF, 8, "float"), NumPut(h, RectF, 12, "float") + VarSetCapacity(RectF, 16) + NumPut(x, RectF, 0, "float"), NumPut(y, RectF, 4, "float"), NumPut(w, RectF, 8, "float"), NumPut(h, RectF, 12, "float") } ;##################################################################################### -; Function CreateRect +; Function CreateRect ; Description Creates a Rect object, containing a the coordinates and dimensions of a rectangle ; -; RectF Name to call the RectF object -; x x-coordinate of the upper left corner of the rectangle -; y y-coordinate of the upper left corner of the rectangle -; w Width of the rectangle -; h Height of the rectangle +; RectF Name to call the RectF object +; x x-coordinate of the upper left corner of the rectangle +; y y-coordinate of the upper left corner of the rectangle +; w Width of the rectangle +; h Height of the rectangle ; -; return No return value +; return No return value CreateRect(ByRef Rect, x, y, w, h) { @@ -433,35 +364,35 @@ CreateRect(ByRef Rect, x, y, w, h) } ;##################################################################################### -; Function CreateSizeF +; Function CreateSizeF ; Description Creates a SizeF object, containing an 2 values ; -; SizeF Name to call the SizeF object -; w w-value for the SizeF object -; h h-value for the SizeF object +; SizeF Name to call the SizeF object +; w w-value for the SizeF object +; h h-value for the SizeF object ; -; return No Return value +; return No Return value CreateSizeF(ByRef SizeF, w, h) { - VarSetCapacity(SizeF, 8) - NumPut(w, SizeF, 0, "float"), NumPut(h, SizeF, 4, "float") + VarSetCapacity(SizeF, 8) + NumPut(w, SizeF, 0, "float"), NumPut(h, SizeF, 4, "float") } ;##################################################################################### -; Function CreatePointF +; Function CreatePointF ; Description Creates a SizeF object, containing an 2 values ; -; SizeF Name to call the SizeF object -; w w-value for the SizeF object -; h h-value for the SizeF object +; SizeF Name to call the SizeF object +; w w-value for the SizeF object +; h h-value for the SizeF object ; -; return No Return value +; return No Return value CreatePointF(ByRef PointF, x, y) { - VarSetCapacity(PointF, 8) - NumPut(x, PointF, 0, "float"), NumPut(y, PointF, 4, "float") + VarSetCapacity(PointF, 8) + NumPut(x, PointF, 0, "float"), NumPut(y, PointF, 4, "float") } ;##################################################################################### @@ -478,27 +409,12 @@ CreatePointF(ByRef PointF, x, y) ; ; notes ppvBits will receive the location of the pixels in the DIB -CreateDIBSection(w, h, hdc:="", bpp:=32, ByRef ppvBits:=0) +CreateDIBSection(w, h, hdc="", bpp=32, ByRef ppvBits=0) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - hdc2 := hdc ? hdc : GetDC() VarSetCapacity(bi, 40, 0) - - NumPut(w, bi, 4, "uint") - , NumPut(h, bi, 8, "uint") - , NumPut(40, bi, 0, "uint") - , NumPut(1, bi, 12, "ushort") - , NumPut(0, bi, 16, "uInt") - , NumPut(bpp, bi, 14, "ushort") - - hbm := DllCall("CreateDIBSection" - , Ptr, hdc2 - , Ptr, &bi - , "uint", 0 - , A_PtrSize ? "UPtr*" : "uint*", ppvBits - , Ptr, 0 - , "uint", 0, Ptr) + NumPut(w, bi, 4), NumPut(h, bi, 8), NumPut(40, bi, 0), NumPut(1, bi, 12, "ushort"), NumPut(0, bi, 16), NumPut(bpp, bi, 14, "ushort") + hbm := DllCall("CreateDIBSection", "uint" , hdc2, "uint" , &bi, "uint" , 0, "uint*", ppvBits, "uint" , 0, "uint" , 0) if !hdc ReleaseDC(hdc2) @@ -518,11 +434,9 @@ CreateDIBSection(w, h, hdc:="", bpp:=32, ByRef ppvBits:=0) ; ; PW_CLIENTONLY = 1 -PrintWindow(hwnd, hdc, Flags:=0) +PrintWindow(hwnd, hdc, Flags=0) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("PrintWindow", Ptr, hwnd, Ptr, hdc, "uint", Flags) + return DllCall("PrintWindow", "uint", hwnd, "uint", hdc, "uint", Flags) } ;##################################################################################### @@ -536,63 +450,21 @@ PrintWindow(hwnd, hdc, Flags:=0) DestroyIcon(hIcon) { - return DllCall("DestroyIcon", A_PtrSize ? "UPtr" : "UInt", hIcon) -} - -;##################################################################################### - -; Function: GetIconDimensions -; Description: Retrieves a given icon/cursor's width and height -; -; hIcon Pointer to an icon or cursor -; Width ByRef variable. This variable is set to the icon's width -; Height ByRef variable. This variable is set to the icon's height -; -; return If the function succeeds, the return value is zero, otherwise: -; -1 = Could not retrieve the icon's info. Check A_LastError for extended information -; -2 = Could not delete the icon's bitmask bitmap -; -3 = Could not delete the icon's color bitmap - -GetIconDimensions(hIcon, ByRef Width, ByRef Height) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - Width := Height := 0 - - VarSetCapacity(ICONINFO, size := 16 + 2 * A_PtrSize, 0) - - if !DllCall("user32\GetIconInfo", Ptr, hIcon, Ptr, &ICONINFO) - return -1 - - hbmMask := NumGet(&ICONINFO, 16, Ptr) - hbmColor := NumGet(&ICONINFO, 16 + A_PtrSize, Ptr) - VarSetCapacity(BITMAP, size, 0) - - if DllCall("gdi32\GetObject", Ptr, hbmColor, "Int", size, Ptr, &BITMAP) - { - Width := NumGet(&BITMAP, 4, "Int") - Height := NumGet(&BITMAP, 8, "Int") - } - - if !DllCall("gdi32\DeleteObject", Ptr, hbmMask) - return -2 - - if !DllCall("gdi32\DeleteObject", Ptr, hbmColor) - return -3 - - return 0 + return DllCall("DestroyIcon", "uint", hIcon) } ;##################################################################################### PaintDesktop(hdc) { - return DllCall("PaintDesktop", A_PtrSize ? "UPtr" : "UInt", hdc) + return DllCall("PaintDesktop", "uint", hdc) } ;##################################################################################### CreateCompatibleBitmap(hdc, w, h) { - return DllCall("gdi32\CreateCompatibleBitmap", A_PtrSize ? "UPtr" : "UInt", hdc, "int", w, "int", h) + return DllCall("gdi32\CreateCompatibleBitmap", "uint", hdc, "int", w, "int", h) } ;##################################################################################### @@ -600,15 +472,15 @@ CreateCompatibleBitmap(hdc, w, h) ; Function CreateCompatibleDC ; Description This function creates a memory device context (DC) compatible with the specified device ; -; hdc Handle to an existing device context +; hdc Handle to an existing device context ; ; return returns the handle to a device context or 0 on failure ; ; notes If this handle is 0 (by default), the function creates a memory device context compatible with the application's current screen -CreateCompatibleDC(hdc:=0) +CreateCompatibleDC(hdc=0) { - return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc) + return DllCall("CreateCompatibleDC", "uint", hdc) } ;##################################################################################### @@ -636,9 +508,7 @@ CreateCompatibleDC(hdc:=0) SelectObject(hdc, hgdiobj) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj) + return DllCall("SelectObject", "uint", hdc, "uint", hgdiobj) } ;##################################################################################### @@ -653,22 +523,22 @@ SelectObject(hdc, hgdiobj) DeleteObject(hObject) { - return DllCall("DeleteObject", A_PtrSize ? "UPtr" : "UInt", hObject) + return DllCall("DeleteObject", "uint", hObject) } ;##################################################################################### ; Function GetDC ; Description This function retrieves a handle to a display device context (DC) for the client area of the specified window. -; The display device context can be used in subsequent graphics display interface (GDI) functions to draw in the client area of the window. +; The display device context can be used in subsequent graphics display interface (GDI) functions to draw in the client area of the window. ; -; hwnd Handle to the window whose device context is to be retrieved. If this value is NULL, GetDC retrieves the device context for the entire screen +; hwnd Handle to the window whose device context is to be retrieved. If this value is NULL, GetDC retrieves the device context for the entire screen ; ; return The handle the device context for the specified window's client area indicates success. NULL indicates failure -GetDC(hwnd:=0) +GetDC(hwnd=0) { - return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd) + return DllCall("GetDC", "uint", hwnd) } ;##################################################################################### @@ -687,11 +557,9 @@ GetDC(hwnd:=0) ; DCX_VALIDATE = 0x200000 ; DCX_WINDOW = 0x1 -GetDCEx(hwnd, flags:=0, hrgnClip:=0) +GetDCEx(hwnd, flags=0, hrgnClip=0) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("GetDCEx", Ptr, hwnd, Ptr, hrgnClip, "int", flags) + return DllCall("GetDCEx", "uint", hwnd, "uint", hrgnClip, "int", flags) } ;##################################################################################### @@ -706,13 +574,11 @@ GetDCEx(hwnd, flags:=0, hrgnClip:=0) ; 0 = not released ; ; notes The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC function that retrieves a common device context -; An application cannot use the ReleaseDC function to release a device context that was created by calling the CreateDC function; instead, it must use the DeleteDC function. +; An application cannot use the ReleaseDC function to release a device context that was created by calling the CreateDC function; instead, it must use the DeleteDC function. -ReleaseDC(hdc, hwnd:=0) +ReleaseDC(hdc, hwnd=0) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc) + return DllCall("ReleaseDC", "uint", hwnd, "uint", hdc) } ;##################################################################################### @@ -728,7 +594,7 @@ ReleaseDC(hdc, hwnd:=0) DeleteDC(hdc) { - return DllCall("DeleteDC", A_PtrSize ? "UPtr" : "UInt", hdc) + return DllCall("DeleteDC", "uint", hdc) } ;##################################################################################### @@ -746,105 +612,53 @@ Gdip_LibraryVersion() ;##################################################################################### -; Function Gdip_LibrarySubVersion -; Description Get the current library sub version -; -; return the library sub version -; -; notes This is the sub-version currently maintained by Rseding91 -; Updated by guest3456 preliminary AHK v2 support -Gdip_LibrarySubVersion() -{ - return 1.54 -} - -;##################################################################################### - -; Function: Gdip_BitmapFromBRA +; Function: Gdip_BitmapFromBRA ; Description: Gets a pointer to a gdi+ bitmap from a BRA file ; ; BRAFromMemIn The variable for a BRA file read to memory ; File The name of the file, or its number that you would like (This depends on alternate parameter) ; Alternate Changes whether the File parameter is the file name or its number ; -; return If the function succeeds, the return value is a pointer to a gdi+ bitmap +; return If the function succeeds, the return value is a pointer to a gdi+ bitmap ; -1 = The BRA variable is empty ; -2 = The BRA has an incorrect header ; -3 = The BRA has information missing ; -4 = Could not find file inside the BRA -Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File, Alternate := 0) { - pBitmap := 0 - pStream := 0 - - If !(BRAFromMemIn) - Return -1 - Headers := StrSplit(StrGet(&BRAFromMemIn, 256, "CP0"), "`n") - Header := StrSplit(Headers[1], "|") - HeaderLength := (A_AhkVersion < "2") ? Header.Length() : Header.Length - If (HeaderLength != 4) || (Header[2] != "BRA!") - Return -2 - _Info := StrSplit(Headers[2], "|") - _InfoLength := (A_AhkVersion < "2") ? _Info.Length() : _Info.Length - If (_InfoLength != 3) - Return -3 - OffsetTOC := StrPut(Headers[1], "CP0") + StrPut(Headers[2], "CP0") ; + 2 - OffsetData := _Info[2] - SearchIndex := Alternate ? 1 : 2 - TOC := StrGet(&BRAFromMemIn + OffsetTOC, OffsetData - OffsetTOC - 1, "CP0") - RX1 := A_AhkVersion < "2" ? "mi`nO)^" : "mi`n)^" - Offset := Size := 0 - If RegExMatch(TOC, RX1 . (Alternate ? File "\|.+?" : "\d+\|" . File) . "\|(\d+)\|(\d+)$", FileInfo) { - Offset := OffsetData + FileInfo[1] - Size := FileInfo[2] - } - If (Size = 0) - Return -4 - hData := DllCall("GlobalAlloc", "UInt", 2, "UInt", Size, "UPtr") - pData := DllCall("GlobalLock", "Ptr", hData, "UPtr") - DllCall("RtlMoveMemory", "Ptr", pData, "Ptr", &BRAFromMemIn + Offset, "Ptr", Size) - DllCall("GlobalUnlock", "Ptr", hData) - DllCall("Ole32.dll\CreateStreamOnHGlobal", "Ptr", hData, "Int", 1, "PtrP", pStream) - DllCall("Gdiplus.dll\GdipCreateBitmapFromStream", "Ptr", pStream, "PtrP", pBitmap) - ObjRelease(pStream) - Return pBitmap -} - -;##################################################################################### - -; Function: Gdip_BitmapFromBase64 -; Description: Creates a bitmap from a Base64 encoded string -; -; Base64 ByRef variable. Base64 encoded string. Immutable, ByRef to avoid performance overhead of passing long strings. -; -; return If the function succeeds, the return value is a pointer to a bitmap, otherwise: -; -1 = Could not calculate the length of the required buffer -; -2 = Could not decode the Base64 encoded string -; -3 = Could not create a memory stream - -Gdip_BitmapFromBase64(ByRef Base64) +Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File, Alternate=0) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - DecLen := 0 - pBitmap := 0 - - ; calculate the length of the buffer needed - if !(DllCall("crypt32\CryptStringToBinary", Ptr, &Base64, "UInt", 0, "UInt", 0x01, Ptr, 0, "UIntP", DecLen, Ptr, 0, Ptr, 0)) + if !BRAFromMemIn return -1 + Loop, Parse, BRAFromMemIn, `n + { + if (A_Index = 1) + { + StringSplit, Header, A_LoopField, | + if (Header0 != 4 || Header2 != "BRA!") + return -2 + } + else if (A_Index = 2) + { + StringSplit, Info, A_LoopField, | + if (Info0 != 3) + return -3 + } + else + break + } + if !Alternate + StringReplace, File, File, \, \\, All + RegExMatch(BRAFromMemIn, "mi`n)^" (Alternate ? File "\|.+?\|(\d+)\|(\d+)" : "\d+\|" File "\|(\d+)\|(\d+)") "$", FileInfo) + if !FileInfo + return -4 - VarSetCapacity(Dec, DecLen, 0) - - ; decode the Base64 encoded string - if !(DllCall("crypt32\CryptStringToBinary", Ptr, &Base64, "UInt", 0, "UInt", 0x01, Ptr, &Dec, "UIntP", DecLen, Ptr, 0, Ptr, 0)) - return -2 - - ; create a memory stream - if !(pStream := DllCall("shlwapi\SHCreateMemStream", Ptr, &Dec, "UInt", DecLen, "UPtr")) - return -3 - - DllCall("gdiplus\GdipCreateBitmapFromStreamICM", Ptr, pStream, "PtrP", pBitmap) - ObjRelease(pStream) - + hData := DllCall("GlobalAlloc", "uint", 2, "uint", FileInfo2) + pData := DllCall("GlobalLock", "uint", hData) + DllCall("RtlMoveMemory", "uint", pData, "uint", &BRAFromMemIn+Info2+FileInfo1, "uint", FileInfo2) + DllCall("GlobalUnlock", "uint", hData) + DllCall("ole32\CreateStreamOnHGlobal", "uint", hData, "int", 1, "uint*", pStream) + DllCall("gdiplus\GdipCreateBitmapFromStream", "uint", pStream, "uint*", pBitmap) + DllCall(NumGet(NumGet(1*pStream)+8), "uint", pStream) return pBitmap } @@ -866,9 +680,7 @@ Gdip_BitmapFromBase64(ByRef Base64) Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdiplus\GdipDrawRectangle", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h) + return DllCall("gdiplus\GdipDrawRectangle", "uint", pGraphics, "uint", pPen, "float", x, "float", y, "float", w, "float", h) } ;##################################################################################### @@ -894,7 +706,7 @@ Gdip_DrawRoundedRectangle(pGraphics, pPen, x, y, w, h, r) Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4) Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4) Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4) - _E := Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h) + E := Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h) Gdip_ResetClip(pGraphics) Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4) Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4) @@ -903,7 +715,7 @@ Gdip_DrawRoundedRectangle(pGraphics, pPen, x, y, w, h, r) Gdip_DrawEllipse(pGraphics, pPen, x, y+h-(2*r), 2*r, 2*r) Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y+h-(2*r), 2*r, 2*r) Gdip_ResetClip(pGraphics) - return _E + return E } ;##################################################################################### @@ -924,9 +736,7 @@ Gdip_DrawRoundedRectangle(pGraphics, pPen, x, y, w, h, r) Gdip_DrawEllipse(pGraphics, pPen, x, y, w, h) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdiplus\GdipDrawEllipse", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h) + return DllCall("gdiplus\GdipDrawEllipse", "uint", pGraphics, "uint", pPen, "float", x, "float", y, "float", w, "float", h) } ;##################################################################################### @@ -951,19 +761,9 @@ Gdip_DrawEllipse(pGraphics, pPen, x, y, w, h) Gdip_DrawBezier(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdiplus\GdipDrawBezier" - , Ptr, pgraphics - , Ptr, pPen - , "float", x1 - , "float", y1 - , "float", x2 - , "float", y2 - , "float", x3 - , "float", y3 - , "float", x4 - , "float", y4) + return DllCall("gdiplus\GdipDrawBezier", "uint", pgraphics, "uint", pPen + , "float", x1, "float", y1, "float", x2, "float", y2 + , "float", x3, "float", y3, "float", x4, "float", y4) } ;##################################################################################### @@ -986,17 +786,8 @@ Gdip_DrawBezier(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4) Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdiplus\GdipDrawArc" - , Ptr, pGraphics - , Ptr, pPen - , "float", x - , "float", y - , "float", w - , "float", h - , "float", StartAngle - , "float", SweepAngle) + return DllCall("gdiplus\GdipDrawArc", "uint", pGraphics, "uint", pPen, "float", x + , "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle) } ;##################################################################################### @@ -1019,9 +810,7 @@ Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle) Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdiplus\GdipDrawPie", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle) + return DllCall("gdiplus\GdipDrawPie", "uint", pGraphics, "uint", pPen, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle) } ;##################################################################################### @@ -1036,19 +825,12 @@ Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle) ; x2 x-coordinate of the end of the line ; y2 y-coordinate of the end of the line ; -; return status enumeration. 0 = success +; return status enumeration. 0 = success Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdiplus\GdipDrawLine" - , Ptr, pGraphics - , Ptr, pPen - , "float", x1 - , "float", y1 - , "float", x2 - , "float", y2) + return DllCall("gdiplus\GdipDrawLine", "uint", pGraphics, "uint", pPen + , "float", x1, "float", y1, "float", x2, "float", y2) } ;##################################################################################### @@ -1060,20 +842,18 @@ Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2) ; pPen Pointer to a pen ; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3..... ; -; return status enumeration. 0 = success +; return status enumeration. 0 = success Gdip_DrawLines(pGraphics, pPen, Points) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - Points := StrSplit(Points, "|") - PointsLength := (A_AhkVersion < "2") ? Points.Length() : Points.Length - VarSetCapacity(PointF, 8*PointsLength) - for eachPoint, Point in Points - { - Coord := StrSplit(Point, ",") - NumPut(Coord[1], PointF, 8*(A_Index-1), "float"), NumPut(Coord[2], PointF, (8*(A_Index-1))+4, "float") - } - return DllCall("gdiplus\GdipDrawLines", Ptr, pGraphics, Ptr, pPen, Ptr, &PointF, "int", PointsLength) + StringSplit, Points, Points, | + VarSetCapacity(PointF, 8*Points0) + Loop, %Points0% + { + StringSplit, Coord, Points%A_Index%, `, + NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float") + } + return DllCall("gdiplus\GdipDrawLines", "uint", pGraphics, "uint", pPen, "uint", &PointF, "int", Points0) } ;##################################################################################### @@ -1092,15 +872,8 @@ Gdip_DrawLines(pGraphics, pPen, Points) Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdiplus\GdipFillRectangle" - , Ptr, pGraphics - , Ptr, pBrush - , "float", x - , "float", y - , "float", w - , "float", h) + return DllCall("gdiplus\GdipFillRectangle", "uint", pGraphics, "int", pBrush + , "float", x, "float", y, "float", w, "float", h) } ;##################################################################################### @@ -1125,7 +898,7 @@ Gdip_FillRoundedRectangle(pGraphics, pBrush, x, y, w, h, r) Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4) Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4) Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4) - _E := Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h) + E := Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h) Gdip_SetClipRegion(pGraphics, Region, 0) Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4) Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4) @@ -1135,7 +908,7 @@ Gdip_FillRoundedRectangle(pGraphics, pBrush, x, y, w, h, r) Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y+h-(2*r), 2*r, 2*r) Gdip_SetClipRegion(pGraphics, Region, 0) Gdip_DeleteRegion(Region) - return _E + return E } ;##################################################################################### @@ -1153,19 +926,16 @@ Gdip_FillRoundedRectangle(pGraphics, pBrush, x, y, w, h, r) ; Alternate = 0 ; Winding = 1 -Gdip_FillPolygon(pGraphics, pBrush, Points, FillMode:=0) +Gdip_FillPolygon(pGraphics, pBrush, Points, FillMode=0) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - Points := StrSplit(Points, "|") - PointsLength := (A_AhkVersion < "2") ? Points.Length() : Points.Length - VarSetCapacity(PointF, 8*PointsLength) - For eachPoint, Point in Points - { - Coord := StrSplit(Point, ",") - NumPut(Coord[1], PointF, 8*(A_Index-1), "float"), NumPut(Coord[2], PointF, (8*(A_Index-1))+4, "float") - } - return DllCall("gdiplus\GdipFillPolygon", Ptr, pGraphics, Ptr, pBrush, Ptr, &PointF, "int", PointsLength, "int", FillMode) + StringSplit, Points, Points, | + VarSetCapacity(PointF, 8*Points0) + Loop, %Points0% + { + StringSplit, Coord, Points%A_Index%, `, + NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float") + } + return DllCall("gdiplus\GdipFillPolygon", "uint", pGraphics, "uint", pBrush, "uint", &PointF, "int", Points0, "int", FillMode) } ;##################################################################################### @@ -1186,17 +956,8 @@ Gdip_FillPolygon(pGraphics, pBrush, Points, FillMode:=0) Gdip_FillPie(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdiplus\GdipFillPie" - , Ptr, pGraphics - , Ptr, pBrush - , "float", x - , "float", y - , "float", w - , "float", h - , "float", StartAngle - , "float", SweepAngle) + return DllCall("gdiplus\GdipFillPie", "uint", pGraphics, "uint", pBrush + , "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle) } ;##################################################################################### @@ -1215,9 +976,7 @@ Gdip_FillPie(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle) Gdip_FillEllipse(pGraphics, pBrush, x, y, w, h) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdiplus\GdipFillEllipse", Ptr, pGraphics, Ptr, pBrush, "float", x, "float", y, "float", w, "float", h) + return DllCall("gdiplus\GdipFillEllipse", "uint", pGraphics, "uint", pBrush, "float", x, "float", y, "float", w, "float", h) } ;##################################################################################### @@ -1235,9 +994,7 @@ Gdip_FillEllipse(pGraphics, pBrush, x, y, w, h) Gdip_FillRegion(pGraphics, pBrush, Region) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdiplus\GdipFillRegion", Ptr, pGraphics, Ptr, pBrush, Ptr, Region) + return DllCall("gdiplus\GdipFillRegion", "uint", pGraphics, "uint", pBrush, "uint", Region) } ;##################################################################################### @@ -1251,11 +1008,9 @@ Gdip_FillRegion(pGraphics, pBrush, Region) ; ; return status enumeration. 0 = success -Gdip_FillPath(pGraphics, pBrush, pPath) +Gdip_FillPath(pGraphics, pBrush, Path) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdiplus\GdipFillPath", Ptr, pGraphics, Ptr, pBrush, Ptr, pPath) + return DllCall("gdiplus\GdipFillPath", "uint", pGraphics, "uint", pBrush, "uint", Path) } ;##################################################################################### @@ -1279,24 +1034,21 @@ Gdip_FillPath(pGraphics, pBrush, pPath) ; Matrix may be passed as a digit from 0 - 1 to change just transparency ; Matrix can be passed as a matrix with any delimiter -Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx:="", sy:="", sw:="", sh:="", Matrix:=1) +Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", Matrix=1) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - Points := StrSplit(Points, "|") - PointsLength := (A_AhkVersion < "2") ? Points.Length() : Points.Length - VarSetCapacity(PointF, 8*PointsLength) - For eachPoint, Point in Points + StringSplit, Points, Points, | + VarSetCapacity(PointF, 8*Points0) + Loop, %Points0% { - Coord := StrSplit(Point, ",") - NumPut(Coord[1], PointF, 8*(A_Index-1), "float"), NumPut(Coord[2], PointF, (8*(A_Index-1))+4, "float") + StringSplit, Coord, Points%A_Index%, `, + NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float") } - if !IsNumber(Matrix) + if (Matrix&1 = "") ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix) else if (Matrix != 1) ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1") - + if (sx = "" && sy = "" && sw = "" && sh = "") { sx := 0, sy := 0 @@ -1304,22 +1056,12 @@ Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx:="", sy:="", sw:="", sh: sh := Gdip_GetImageHeight(pBitmap) } - _E := DllCall("gdiplus\GdipDrawImagePointsRect" - , Ptr, pGraphics - , Ptr, pBitmap - , Ptr, &PointF - , "int", PointsLength - , "float", sx - , "float", sy - , "float", sw - , "float", sh - , "int", 2 - , Ptr, ImageAttr - , Ptr, 0 - , Ptr, 0) + E := DllCall("gdiplus\GdipDrawImagePointsRect", "uint", pGraphics, "uint", pBitmap + , "uint", &PointF, "int", Points0, "float", sx, "float", sy, "float", sw, "float", sh + , "int", 2, "uint", ImageAttr, "uint", 0, "uint", 0) if ImageAttr Gdip_DisposeImageAttributes(ImageAttr) - return _E + return E } ;##################################################################################### @@ -1357,13 +1099,11 @@ Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx:="", sy:="", sw:="", sh: ; ; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1 ; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1 -; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|1|1|1|0|1 +; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1 -Gdip_DrawImage(pGraphics, pBitmap, dx:="", dy:="", dw:="", dh:="", sx:="", sy:="", sw:="", sh:="", Matrix:=1) +Gdip_DrawImage(pGraphics, pBitmap, dx="", dy="", dw="", dh="", sx="", sy="", sw="", sh="", Matrix=1) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - if !IsNumber(Matrix) + if (Matrix&1 = "") ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix) else if (Matrix != 1) ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1") @@ -1384,24 +1124,13 @@ Gdip_DrawImage(pGraphics, pBitmap, dx:="", dy:="", dw:="", dh:="", sx:="", sy:=" } } - _E := DllCall("gdiplus\GdipDrawImageRectRect" - , Ptr, pGraphics - , Ptr, pBitmap - , "float", dx - , "float", dy - , "float", dw - , "float", dh - , "float", sx - , "float", sy - , "float", sw - , "float", sh - , "int", 2 - , Ptr, ImageAttr ? ImageAttr : 0 - , Ptr, 0 - , Ptr, 0) + E := DllCall("gdiplus\GdipDrawImageRectRect", "uint", pGraphics, "uint", pBitmap + , "float", dx, "float", dy, "float", dw, "float", dh + , "float", sx, "float", sy, "float", sw, "float", sh + , "int", 2, "uint", ImageAttr, "uint", 0, "uint", 0) if ImageAttr Gdip_DisposeImageAttributes(ImageAttr) - return _E + return E } ;##################################################################################### @@ -1416,22 +1145,20 @@ Gdip_DrawImage(pGraphics, pBitmap, dx:="", dy:="", dw:="", dh:="", sx:="", sy:=" ; ; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1 ; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1 -; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|1|1|1|0|1 +; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1 Gdip_SetImageAttributesColorMatrix(Matrix) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - ImageAttr := 0 VarSetCapacity(ColourMatrix, 100, 0) - Matrix := RegExReplace(RegExReplace(Matrix, "^[^\d-\.]+([\d\.])", "$1", , 1), "[^\d-\.]+", "|") - Matrix := StrSplit(Matrix, "|") - Loop 25 + Matrix := RegExReplace(RegExReplace(Matrix, "^[^\d-\.]+([\d\.])", "$1", "", 1), "[^\d-\.]+", "|") + StringSplit, Matrix, Matrix, | + Loop, 25 { - M := (Matrix[A_Index] != "") ? Matrix[A_Index] : Mod(A_Index-1, 6) ? 0 : 1 - NumPut(M, ColourMatrix, (A_Index-1)*4, "float") + Matrix := (Matrix%A_Index% != "") ? Matrix%A_Index% : Mod(A_Index-1, 6) ? 0 : 1 + NumPut(Matrix, ColourMatrix, (A_Index-1)*4, "float") } - DllCall("gdiplus\GdipCreateImageAttributes", A_PtrSize ? "UPtr*" : "uint*", ImageAttr) - DllCall("gdiplus\GdipSetImageAttributesColorMatrix", Ptr, ImageAttr, "int", 1, "int", 1, Ptr, &ColourMatrix, Ptr, 0, "int", 0) + DllCall("gdiplus\GdipCreateImageAttributes", "uint*", ImageAttr) + DllCall("gdiplus\GdipSetImageAttributesColorMatrix", "uint", ImageAttr, "int", 1, "int", 1, "uint", &ColourMatrix, "int", 0, "int", 0) return ImageAttr } @@ -1448,9 +1175,8 @@ Gdip_SetImageAttributesColorMatrix(Matrix) Gdip_GraphicsFromImage(pBitmap) { - pGraphics := 0 - DllCall("gdiplus\GdipGetImageGraphicsContext", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", pGraphics) - return pGraphics + DllCall("gdiplus\GdipGetImageGraphicsContext", "uint", pBitmap, "uint*", pGraphics) + return pGraphics } ;##################################################################################### @@ -1466,10 +1192,8 @@ Gdip_GraphicsFromImage(pBitmap) Gdip_GraphicsFromHDC(hdc) { - pGraphics := 0 - - DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics) - return pGraphics + DllCall("gdiplus\GdipCreateFromHDC", "uint", hdc, "uint*", pGraphics) + return pGraphics } ;##################################################################################### @@ -1483,8 +1207,7 @@ Gdip_GraphicsFromHDC(hdc) Gdip_GetDC(pGraphics) { - hdc := 0 - DllCall("gdiplus\GdipGetDC", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", hdc) + DllCall("gdiplus\GdipGetDC", "uint", pGraphics, "uint*", hdc) return hdc } @@ -1500,9 +1223,7 @@ Gdip_GetDC(pGraphics) Gdip_ReleaseDC(pGraphics, hdc) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdiplus\GdipReleaseDC", Ptr, pGraphics, Ptr, hdc) + return DllCall("gdiplus\GdipReleaseDC", "uint", pGraphics, "uint", hdc) } ;##################################################################################### @@ -1518,9 +1239,9 @@ Gdip_ReleaseDC(pGraphics, hdc) ; notes By default this will make the background invisible ; Using clipping regions you can clear a particular area on the graphics rather than clearing the entire graphics -Gdip_GraphicsClear(pGraphics, ARGB:=0x00ffffff) +Gdip_GraphicsClear(pGraphics, ARGB=0x00ffffff) { - return DllCall("gdiplus\GdipGraphicsClear", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", ARGB) + return DllCall("gdiplus\GdipGraphicsClear", "uint", pGraphics, "int", ARGB) } ;##################################################################################### @@ -1539,8 +1260,8 @@ Gdip_GraphicsClear(pGraphics, ARGB:=0x00ffffff) Gdip_BlurBitmap(pBitmap, Blur) { if (Blur > 100) || (Blur < 1) - return -1 - + return -1 + sWidth := Gdip_GetImageWidth(pBitmap), sHeight := Gdip_GetImageHeight(pBitmap) dWidth := sWidth//Blur, dHeight := sHeight//Blur @@ -1563,14 +1284,14 @@ Gdip_BlurBitmap(pBitmap, Blur) ;##################################################################################### -; Function: Gdip_SaveBitmapToFile -; Description: Saves a bitmap to a file in any supported format onto disk -; +; Function: Gdip_SaveBitmapToFile +; Description: Saves a bitmap to a file in any supported format onto disk +; ; pBitmap Pointer to a bitmap -; sOutput The name of the file that the bitmap will be saved to. Supported extensions are: .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG -; Quality If saving as jpg (.JPG,.JPEG,.JPE,.JFIF) then quality can be 1-100 with default at maximum quality +; sOutput The name of the file that the bitmap will be saved to. Supported extensions are: .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG +; Quality If saving as jpg (.JPG,.JPEG,.JPE,.JFIF) then quality can be 1-100 with default at maximum quality ; -; return If the function succeeds, the return value is zero, otherwise: +; return If the function succeeds, the return value is zero, otherwise: ; -1 = Extension supplied is not a supported file format ; -2 = Could not get a list of encoders on system ; -3 = Could not find matching encoder for specified file format @@ -1579,92 +1300,78 @@ Gdip_BlurBitmap(pBitmap, Blur) ; ; notes This function will use the extension supplied from the sOutput parameter to determine the output format -Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality:=75) +Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality=75) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - nCount := 0 - nSize := 0 - _p := 0 - - SplitPath sOutput,,, Extension - if !RegExMatch(Extension, "^(?i:BMP|DIB|RLE|JPG|JPEG|JPE|JFIF|GIF|TIF|TIFF|PNG)$") + SplitPath, sOutput,,, Extension + if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG return -1 Extension := "." Extension DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize) VarSetCapacity(ci, nSize) - DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci) + DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, "uint", &ci) if !(nCount && nSize) return -2 - - If (A_IsUnicode){ - StrGet_Name := "StrGet" - - N := (A_AhkVersion < 2) ? nCount : "nCount" - Loop %N% + + Loop, %nCount% + { + Location := NumGet(ci, 76*(A_Index-1)+44) + if !A_IsUnicode { - sString := %StrGet_Name%(NumGet(ci, (idx := (48+7*A_PtrSize)*(A_Index-1))+32+3*A_PtrSize), "UTF-16") + nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int", 0, "uint", 0, "uint", 0) + VarSetCapacity(sString, nSize) + DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0) if !InStr(sString, "*" Extension) continue - - pCodec := &ci+idx - break } - } else { - N := (A_AhkVersion < 2) ? nCount : "nCount" - Loop %N% + else { - Location := NumGet(ci, 76*(A_Index-1)+44) nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int", 0, "uint", 0, "uint", 0) - VarSetCapacity(sString, nSize) - DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0) + sString := "" + Loop, %nSize% + sString .= Chr(NumGet(Location+0, 2*(A_Index-1), "char")) if !InStr(sString, "*" Extension) continue - - pCodec := &ci+76*(A_Index-1) - break } + pCodec := &ci+76*(A_Index-1) + break } - if !pCodec return -3 if (Quality != 75) { Quality := (Quality < 0) ? 0 : (Quality > 100) ? 100 : Quality - if RegExMatch(Extension, "^\.(?i:JPG|JPEG|JPE|JFIF)$") + if Extension in .JPG,.JPEG,.JPE,.JFIF { - DllCall("gdiplus\GdipGetEncoderParameterListSize", Ptr, pBitmap, Ptr, pCodec, "uint*", nSize) + DllCall("gdiplus\GdipGetEncoderParameterListSize", "uint", pBitmap, "uint", pCodec, "uint*", nSize) VarSetCapacity(EncoderParameters, nSize, 0) - DllCall("gdiplus\GdipGetEncoderParameterList", Ptr, pBitmap, Ptr, pCodec, "uint", nSize, Ptr, &EncoderParameters) - nCount := NumGet(EncoderParameters, "UInt") - N := (A_AhkVersion < 2) ? nCount : "nCount" - Loop %N% + DllCall("gdiplus\GdipGetEncoderParameterList", "uint", pBitmap, "uint", pCodec, "uint", nSize, "uint", &EncoderParameters) + Loop, % NumGet(EncoderParameters) ;% { - elem := (24+(A_PtrSize ? A_PtrSize : 4))*(A_Index-1) + 4 + (pad := A_PtrSize = 8 ? 4 : 0) - if (NumGet(EncoderParameters, elem+16, "UInt") = 1) && (NumGet(EncoderParameters, elem+20, "UInt") = 6) + if (NumGet(EncoderParameters, (28*(A_Index-1))+20) = 1) && (NumGet(EncoderParameters, (28*(A_Index-1))+24) = 6) { - _p := elem+&EncoderParameters-pad-4 - NumPut(Quality, NumGet(NumPut(4, NumPut(1, _p+0)+20, "UInt")), "UInt") - break + p := (28*(A_Index-1))+&EncoderParameters + NumPut(Quality, NumGet(NumPut(4, NumPut(1, p+0)+20))) + break } - } - } + } + } } - if (!A_IsUnicode) + if !A_IsUnicode { - nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, 0, "int", 0) + nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &sOutput, "int", -1, "uint", 0, "int", 0) VarSetCapacity(wOutput, nSize*2) - DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, &wOutput, "int", nSize) + DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &sOutput, "int", -1, "uint", &wOutput, "int", nSize) VarSetCapacity(wOutput, -1) if !VarSetCapacity(wOutput) return -4 - _E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &wOutput, Ptr, pCodec, "uint", _p ? _p : 0) + E := DllCall("gdiplus\GdipSaveImageToFile", "uint", pBitmap, "uint", &wOutput, "uint", pCodec, "uint", p ? p : 0) } else - _E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &sOutput, Ptr, pCodec, "uint", _p ? _p : 0) - return _E ? -5 : 0 + E := DllCall("gdiplus\GdipSaveImageToFile", "uint", pBitmap, "uint", &sOutput, "uint", pCodec, "uint", p ? p : 0) + return E ? -5 : 0 } ;##################################################################################### @@ -1680,9 +1387,7 @@ Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality:=75) Gdip_GetPixel(pBitmap, x, y) { - ARGB := 0 - - DllCall("gdiplus\GdipBitmapGetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "uint*", ARGB) + DllCall("gdiplus\GdipBitmapGetPixel", "uint", pBitmap, "int", x, "int", y, "uint*", ARGB) return ARGB } @@ -1699,7 +1404,7 @@ Gdip_GetPixel(pBitmap, x, y) Gdip_SetPixel(pBitmap, x, y, ARGB) { - return DllCall("gdiplus\GdipBitmapSetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "int", ARGB) + return DllCall("gdiplus\GdipBitmapSetPixel", "uint", pBitmap, "int", x, "int", y, "int", ARGB) } ;##################################################################################### @@ -1713,9 +1418,8 @@ Gdip_SetPixel(pBitmap, x, y, ARGB) Gdip_GetImageWidth(pBitmap) { - Width := 0 - DllCall("gdiplus\GdipGetImageWidth", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Width) - return Width + DllCall("gdiplus\GdipGetImageWidth", "uint", pBitmap, "uint*", Width) + return Width } ;##################################################################################### @@ -1729,9 +1433,8 @@ Gdip_GetImageWidth(pBitmap) Gdip_GetImageHeight(pBitmap) { - Height := 0 - DllCall("gdiplus\GdipGetImageHeight", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Height) - return Height + DllCall("gdiplus\GdipGetImageHeight", "uint", pBitmap, "uint*", Height) + return Height } ;##################################################################################### @@ -1748,11 +1451,8 @@ Gdip_GetImageHeight(pBitmap) Gdip_GetImageDimensions(pBitmap, ByRef Width, ByRef Height) { - Width := 0 - Height := 0 - Ptr := A_PtrSize ? "UPtr" : "UInt" - DllCall("gdiplus\GdipGetImageWidth", Ptr, pBitmap, "uint*", Width) - DllCall("gdiplus\GdipGetImageHeight", Ptr, pBitmap, "uint*", Height) + DllCall("gdiplus\GdipGetImageWidth", "uint", pBitmap, "uint*", Width) + DllCall("gdiplus\GdipGetImageHeight", "uint", pBitmap, "uint*", Height) } ;##################################################################################### @@ -1766,8 +1466,7 @@ Gdip_GetDimensions(pBitmap, ByRef Width, ByRef Height) Gdip_GetImagePixelFormat(pBitmap) { - Format := 0 - DllCall("gdiplus\GdipGetImagePixelFormat", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", Format) + DllCall("gdiplus\GdipGetImagePixelFormat", "uint", pBitmap, "uint*", Format) return Format } @@ -1785,8 +1484,7 @@ Gdip_GetImagePixelFormat(pBitmap) Gdip_GetDpiX(pGraphics) { - dpix := 0 - DllCall("gdiplus\GdipGetDpiX", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpix) + DllCall("gdiplus\GdipGetDpiX", "uint", pGraphics, "float*", dpix) return Round(dpix) } @@ -1794,8 +1492,7 @@ Gdip_GetDpiX(pGraphics) Gdip_GetDpiY(pGraphics) { - dpiy := 0 - DllCall("gdiplus\GdipGetDpiY", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpiy) + DllCall("gdiplus\GdipGetDpiY", "uint", pGraphics, "float*", dpiy) return Round(dpiy) } @@ -1803,8 +1500,7 @@ Gdip_GetDpiY(pGraphics) Gdip_GetImageHorizontalResolution(pBitmap) { - dpix := 0 - DllCall("gdiplus\GdipGetImageHorizontalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpix) + DllCall("gdiplus\GdipGetImageHorizontalResolution", "uint", pBitmap, "float*", dpix) return Round(dpix) } @@ -1812,8 +1508,7 @@ Gdip_GetImageHorizontalResolution(pBitmap) Gdip_GetImageVerticalResolution(pBitmap) { - dpiy := 0 - DllCall("gdiplus\GdipGetImageVerticalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpiy) + DllCall("gdiplus\GdipGetImageVerticalResolution", "uint", pBitmap, "float*", dpiy) return Round(dpiy) } @@ -1821,42 +1516,33 @@ Gdip_GetImageVerticalResolution(pBitmap) Gdip_BitmapSetResolution(pBitmap, dpix, dpiy) { - return DllCall("gdiplus\GdipBitmapSetResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float", dpix, "float", dpiy) + return DllCall("gdiplus\GdipBitmapSetResolution", "uint", pBitmap, "float", dpix, "float", dpiy) } ;##################################################################################### -Gdip_CreateBitmapFromFile(sFile, IconNumber:=1, IconSize:="") +Gdip_CreateBitmapFromFile(sFile, IconNumber=1, IconSize="") { - pBitmap := 0 - pBitmapOld := 0 - hIcon := 0 - Ptr := A_PtrSize ? "UPtr" : "UInt" - , PtrA := A_PtrSize ? "UPtr*" : "UInt*" - - SplitPath sFile,,, Extension - if RegExMatch(Extension, "^(?i:exe|dll)$") + SplitPath, sFile,,, ext + if ext in exe,dll { Sizes := IconSize ? IconSize : 256 "|" 128 "|" 64 "|" 48 "|" 32 "|" 16 - BufSize := 16 + (2*(A_PtrSize ? A_PtrSize : 4)) - - VarSetCapacity(buf, BufSize, 0) - For eachSize, Size in StrSplit( Sizes, "|" ) + VarSetCapacity(buf, 40) + Loop, Parse, Sizes, | { - DllCall("PrivateExtractIcons", "str", sFile, "int", IconNumber-1, "int", Size, "int", Size, PtrA, hIcon, PtrA, 0, "uint", 1, "uint", 0) - + DllCall("PrivateExtractIcons", "str", sFile, "int", IconNumber-1, "int", A_LoopField, "int", A_LoopField, "uint*", hIcon, "uint*", 0, "uint", 1, "uint", 0) if !hIcon continue - if !DllCall("GetIconInfo", Ptr, hIcon, Ptr, &buf) + if !DllCall("GetIconInfo", "uint", hIcon, "uint", &buf) { DestroyIcon(hIcon) continue } + hbmColor := NumGet(buf, 16) + hbmMask := NumGet(buf, 12) - hbmMask := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4)) - hbmColor := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4) + (A_PtrSize ? A_PtrSize : 4)) - if !(hbmColor && DllCall("GetObject", Ptr, hbmColor, "int", BufSize, Ptr, &buf)) + if !(hbmColor && DllCall("GetObject", "uint", hbmColor, "int", 24, "uint", &buf)) { DestroyIcon(hIcon) continue @@ -1866,57 +1552,53 @@ Gdip_CreateBitmapFromFile(sFile, IconNumber:=1, IconSize:="") if !hIcon return -1 - Width := NumGet(buf, 4, "int"), Height := NumGet(buf, 8, "int") + Width := NumGet(buf, 4, "int"), Height := NumGet(buf, 8, "int") hbm := CreateDIBSection(Width, -Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm) - if !DllCall("DrawIconEx", Ptr, hdc, "int", 0, "int", 0, Ptr, hIcon, "uint", Width, "uint", Height, "uint", 0, Ptr, 0, "uint", 3) + + if !DllCall("DrawIconEx", "uint", hdc, "int", 0, "int", 0, "uint", hIcon, "uint", Width, "uint", Height, "uint", 0, "uint", 0, "uint", 3) { DestroyIcon(hIcon) return -2 } - VarSetCapacity(dib, 104) - DllCall("GetObject", Ptr, hbm, "int", A_PtrSize = 8 ? 104 : 84, Ptr, &dib) ; sizeof(DIBSECTION) = 76+2*(A_PtrSize=8?4:0)+2*A_PtrSize - Stride := NumGet(dib, 12, "Int"), Bits := NumGet(dib, 20 + (A_PtrSize = 8 ? 4 : 0)) ; padding - DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", Stride, "int", 0x26200A, Ptr, Bits, PtrA, pBitmapOld) - pBitmap := Gdip_CreateBitmap(Width, Height) - _G := Gdip_GraphicsFromImage(pBitmap) - , Gdip_DrawImage(_G, pBitmapOld, 0, 0, Width, Height, 0, 0, Width, Height) + VarSetCapacity(dib, 84) + DllCall("GetObject", "uint", hbm, "int", 84, "uint", &dib) + Stride := NumGet(dib, 12), Bits := NumGet(dib, 20) + + DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", Stride, "int", 0x26200A, "uint", Bits, "uint*", pBitmapOld) + pBitmap := Gdip_CreateBitmap(Width, Height), G := Gdip_GraphicsFromImage(pBitmap) + Gdip_DrawImage(G, pBitmapOld, 0, 0, Width, Height, 0, 0, Width, Height) SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc) - Gdip_DeleteGraphics(_G), Gdip_DisposeImage(pBitmapOld) + Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmapOld) DestroyIcon(hIcon) } else { - if (!A_IsUnicode) + if !A_IsUnicode { - VarSetCapacity(wFile, 1024) - DllCall("kernel32\MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sFile, "int", -1, Ptr, &wFile, "int", 512) - DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &wFile, PtrA, pBitmap) + VarSetCapacity(wFile, 1023) + DllCall("kernel32\MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &sFile, "int", -1, "uint", &wFile, "int", 512) + DllCall("gdiplus\GdipCreateBitmapFromFile", "uint", &wFile, "uint*", pBitmap) } else - DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &sFile, PtrA, pBitmap) + DllCall("gdiplus\GdipCreateBitmapFromFile", "uint", &sFile, "uint*", pBitmap) } - return pBitmap } ;##################################################################################### -Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette:=0) +Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - pBitmap := 0 - - DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", Ptr, hBitmap, Ptr, Palette, A_PtrSize ? "UPtr*" : "uint*", pBitmap) + DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "uint", hBitmap, "uint", Palette, "uint*", pBitmap) return pBitmap } ;##################################################################################### -Gdip_CreateHBITMAPFromBitmap(pBitmap, Background:=0xffffffff) +Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff) { - hbm := 0 - DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hbm, "int", Background) + DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "uint", pBitmap, "uint*", hbm, "int", Background) return hbm } @@ -1924,9 +1606,7 @@ Gdip_CreateHBITMAPFromBitmap(pBitmap, Background:=0xffffffff) Gdip_CreateBitmapFromHICON(hIcon) { - pBitmap := 0 - - DllCall("gdiplus\GdipCreateBitmapFromHICON", A_PtrSize ? "UPtr" : "UInt", hIcon, A_PtrSize ? "UPtr*" : "uint*", pBitmap) + DllCall("gdiplus\GdipCreateBitmapFromHICON", "uint", hIcon, "uint*", pBitmap) return pBitmap } @@ -1934,39 +1614,32 @@ Gdip_CreateBitmapFromHICON(hIcon) Gdip_CreateHICONFromBitmap(pBitmap) { - hIcon := 0 - - DllCall("gdiplus\GdipCreateHICONFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hIcon) + DllCall("gdiplus\GdipCreateHICONFromBitmap", "uint", pBitmap, "uint*", hIcon) return hIcon } ;##################################################################################### -Gdip_CreateBitmap(Width, Height, Format:=0x26200A) +Gdip_CreateBitmap(Width, Height, Format=0x26200A) { - pBitmap := 0 - - DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", 0, "int", Format, A_PtrSize ? "UPtr" : "UInt", 0, A_PtrSize ? "UPtr*" : "uint*", pBitmap) - Return pBitmap + DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", 0, "int", Format, "uint", 0, "uint*", pBitmap) + Return pBitmap } ;##################################################################################### Gdip_CreateBitmapFromClipboard() { - Ptr := A_PtrSize ? "UPtr" : "UInt" - + if !DllCall("OpenClipboard", "uint", 0) + return -1 if !DllCall("IsClipboardFormatAvailable", "uint", 8) return -2 - if !DllCall("OpenClipboard", Ptr, 0) - return -1 - hBitmap := DllCall("GetClipboardData", "uint", 2, Ptr) - if !DllCall("CloseClipboard") - return -5 - if !hBitmap + if !hBitmap := DllCall("GetClipboardData", "uint", 2) return -3 if !pBitmap := Gdip_CreateBitmapFromHBITMAP(hBitmap) return -4 + if !DllCall("CloseClipboard") + return -5 DeleteObject(hBitmap) return pBitmap } @@ -1975,35 +1648,26 @@ Gdip_CreateBitmapFromClipboard() Gdip_SetBitmapToClipboard(pBitmap) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - off1 := A_PtrSize = 8 ? 52 : 44, off2 := A_PtrSize = 8 ? 32 : 24 hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap) - DllCall("GetObject", Ptr, hBitmap, "int", VarSetCapacity(oi, A_PtrSize = 8 ? 104 : 84, 0), Ptr, &oi) - hdib := DllCall("GlobalAlloc", "uint", 2, Ptr, 40+NumGet(oi, off1, "UInt"), Ptr) - pdib := DllCall("GlobalLock", Ptr, hdib, Ptr) - DllCall("RtlMoveMemory", Ptr, pdib, Ptr, &oi+off2, Ptr, 40) - DllCall("RtlMoveMemory", Ptr, pdib+40, Ptr, NumGet(oi, off2 - (A_PtrSize ? A_PtrSize : 4), Ptr), Ptr, NumGet(oi, off1, "UInt")) - DllCall("GlobalUnlock", Ptr, hdib) - DllCall("DeleteObject", Ptr, hBitmap) - DllCall("OpenClipboard", Ptr, 0) + DllCall("GetObject", "uint", hBitmap, "int", VarSetCapacity(oi, 84, 0), "uint", &oi) + hdib := DllCall("GlobalAlloc", "uint", 2, "uint", 40+NumGet(oi, 44)) + pdib := DllCall("GlobalLock", "uint", hdib) + DllCall("RtlMoveMemory", "uint", pdib, "uint", &oi+24, "uint", 40) + DllCall("RtlMoveMemory", "Uint", pdib+40, "Uint", NumGet(oi, 20), "uint", NumGet(oi, 44)) + DllCall("GlobalUnlock", "uint", hdib) + DllCall("DeleteObject", "uint", hBitmap) + DllCall("OpenClipboard", "uint", 0) DllCall("EmptyClipboard") - DllCall("SetClipboardData", "uint", 8, Ptr, hdib) + DllCall("SetClipboardData", "uint", 8, "uint", hdib) DllCall("CloseClipboard") } ;##################################################################################### -Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format:=0x26200A) +Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format=0x26200A) { - pBitmapDest := 0 - DllCall("gdiplus\GdipCloneBitmapArea" - , "float", x - , "float", y - , "float", w - , "float", h - , "int", Format - , A_PtrSize ? "UPtr" : "UInt", pBitmap - , A_PtrSize ? "UPtr*" : "UInt*", pBitmapDest) + DllCall("gdiplus\GdipCloneBitmapArea", "float", x, "float", y, "float", w, "float", h + , "int", Format, "uint", pBitmap, "uint*", pBitmapDest) return pBitmapDest } @@ -2013,28 +1677,23 @@ Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format:=0x26200A) Gdip_CreatePen(ARGB, w) { - pPen := 0 - DllCall("gdiplus\GdipCreatePen1", "UInt", ARGB, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen) - return pPen + DllCall("gdiplus\GdipCreatePen1", "int", ARGB, "float", w, "int", 2, "uint*", pPen) + return pPen } ;##################################################################################### Gdip_CreatePenFromBrush(pBrush, w) { - pPen := 0 - - DllCall("gdiplus\GdipCreatePen2", A_PtrSize ? "UPtr" : "UInt", pBrush, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen) + DllCall("gdiplus\GdipCreatePen2", "uint", pBrush, "float", w, "int", 2, "uint*", pPen) return pPen } ;##################################################################################### -Gdip_BrushCreateSolid(ARGB:=0xff000000) +Gdip_BrushCreateSolid(ARGB=0xff000000) { - pBrush := 0 - - DllCall("gdiplus\GdipCreateSolidFill", "UInt", ARGB, A_PtrSize ? "UPtr*" : "UInt*", pBrush) + DllCall("gdiplus\GdipCreateSolidFill", "int", ARGB, "uint*", pBrush) return pBrush } @@ -2094,26 +1753,20 @@ Gdip_BrushCreateSolid(ARGB:=0xff000000) ; HatchStyleOutlinedDiamond = 51 ; HatchStyleSolidDiamond = 52 ; HatchStyleTotal = 53 -Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle:=0) +Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0) { - pBrush := 0 - - DllCall("gdiplus\GdipCreateHatchBrush", "int", HatchStyle, "UInt", ARGBfront, "UInt", ARGBback, A_PtrSize ? "UPtr*" : "UInt*", pBrush) + DllCall("gdiplus\GdipCreateHatchBrush", "int", HatchStyle, "int", ARGBfront, "int", ARGBback, "uint*", pBrush) return pBrush } ;##################################################################################### -Gdip_CreateTextureBrush(pBitmap, WrapMode:=1, x:=0, y:=0, w:="", h:="") +Gdip_CreateTextureBrush(pBitmap, WrapMode=1, x=0, y=0, w="", h="") { - Ptr := A_PtrSize ? "UPtr" : "UInt" - , PtrA := A_PtrSize ? "UPtr*" : "UInt*" - pBrush := 0 - if !(w && h) - DllCall("gdiplus\GdipCreateTexture", Ptr, pBitmap, "int", WrapMode, PtrA, pBrush) + DllCall("gdiplus\GdipCreateTexture", "uint", pBitmap, "int", WrapMode, "uint*", pBrush) else - DllCall("gdiplus\GdipCreateTexture2", Ptr, pBitmap, "int", WrapMode, "float", x, "float", y, "float", w, "float", h, PtrA, pBrush) + DllCall("gdiplus\GdipCreateTexture2", "uint", pBitmap, "int", WrapMode, "float", x, "float", y, "float", w, "float", h, "uint*", pBrush) return pBrush } @@ -2124,13 +1777,10 @@ Gdip_CreateTextureBrush(pBitmap, WrapMode:=1, x:=0, y:=0, w:="", h:="") ; WrapModeTileFlipY = 2 ; WrapModeTileFlipXY = 3 ; WrapModeClamp = 4 -Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode:=1) +Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - LGpBrush := 0 - CreatePointF(PointF1, x1, y1), CreatePointF(PointF2, x2, y2) - DllCall("gdiplus\GdipCreateLineBrush", Ptr, &PointF1, Ptr, &PointF2, "Uint", ARGB1, "Uint", ARGB2, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush) + DllCall("gdiplus\GdipCreateLineBrush", "uint", &PointF1, "uint", &PointF2, "int", ARGB1, "int", ARGB2, "int", WrapMode, "uint*", LGpBrush) return LGpBrush } @@ -2140,11 +1790,10 @@ Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode:=1) ; LinearGradientModeVertical = 1 ; LinearGradientModeForwardDiagonal = 2 ; LinearGradientModeBackwardDiagonal = 3 -Gdip_CreateLineBrushFromRect(x, y, w, h, ARGB1, ARGB2, LinearGradientMode:=1, WrapMode:=1) +Gdip_CreateLineBrushFromRect(x, y, w, h, ARGB1, ARGB2, LinearGradientMode=1, WrapMode=1) { CreateRectF(RectF, x, y, w, h) - LGpBrush := 0 - DllCall("gdiplus\GdipCreateLineBrushFromRect", A_PtrSize ? "UPtr" : "UInt", &RectF, "int", ARGB1, "int", ARGB2, "int", LinearGradientMode, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush) + DllCall("gdiplus\GdipCreateLineBrushFromRect", "uint", &RectF, "int", ARGB1, "int", ARGB2, "int", LinearGradientMode, "int", WrapMode, "uint*", LGpBrush) return LGpBrush } @@ -2152,8 +1801,7 @@ Gdip_CreateLineBrushFromRect(x, y, w, h, ARGB1, ARGB2, LinearGradientMode:=1, Wr Gdip_CloneBrush(pBrush) { - pBrushClone := 0 - DllCall("gdiplus\GdipCloneBrush", A_PtrSize ? "UPtr" : "UInt", pBrush, A_PtrSize ? "UPtr*" : "UInt*", pBrushClone) + DllCall("gdiplus\GdipCloneBrush", "uint", pBrush, "uint*", pBrushClone) return pBrushClone } @@ -2163,112 +1811,111 @@ Gdip_CloneBrush(pBrush) Gdip_DeletePen(pPen) { - return DllCall("gdiplus\GdipDeletePen", A_PtrSize ? "UPtr" : "UInt", pPen) + return DllCall("gdiplus\GdipDeletePen", "uint", pPen) } ;##################################################################################### Gdip_DeleteBrush(pBrush) { - return DllCall("gdiplus\GdipDeleteBrush", A_PtrSize ? "UPtr" : "UInt", pBrush) + return DllCall("gdiplus\GdipDeleteBrush", "uint", pBrush) } ;##################################################################################### Gdip_DisposeImage(pBitmap) { - return DllCall("gdiplus\GdipDisposeImage", A_PtrSize ? "UPtr" : "UInt", pBitmap) + return DllCall("gdiplus\GdipDisposeImage", "uint", pBitmap) } ;##################################################################################### Gdip_DeleteGraphics(pGraphics) { - return DllCall("gdiplus\GdipDeleteGraphics", A_PtrSize ? "UPtr" : "UInt", pGraphics) + return DllCall("gdiplus\GdipDeleteGraphics", "uint", pGraphics) } ;##################################################################################### Gdip_DisposeImageAttributes(ImageAttr) { - return DllCall("gdiplus\GdipDisposeImageAttributes", A_PtrSize ? "UPtr" : "UInt", ImageAttr) + return DllCall("gdiplus\GdipDisposeImageAttributes", "uint", ImageAttr) } ;##################################################################################### Gdip_DeleteFont(hFont) { - return DllCall("gdiplus\GdipDeleteFont", A_PtrSize ? "UPtr" : "UInt", hFont) + return DllCall("gdiplus\GdipDeleteFont", "uint", hFont) } ;##################################################################################### Gdip_DeleteStringFormat(hFormat) { - return DllCall("gdiplus\GdipDeleteStringFormat", A_PtrSize ? "UPtr" : "UInt", hFormat) + return DllCall("gdiplus\GdipDeleteStringFormat", "uint", hFormat) } ;##################################################################################### Gdip_DeleteFontFamily(hFamily) { - return DllCall("gdiplus\GdipDeleteFontFamily", A_PtrSize ? "UPtr" : "UInt", hFamily) + return DllCall("gdiplus\GdipDeleteFontFamily", "uint", hFamily) } ;##################################################################################### Gdip_DeleteMatrix(Matrix) { - return DllCall("gdiplus\GdipDeleteMatrix", A_PtrSize ? "UPtr" : "UInt", Matrix) + return DllCall("gdiplus\GdipDeleteMatrix", "uint", Matrix) } ;##################################################################################### ; Text functions ;##################################################################################### -Gdip_TextToGraphics(pGraphics, Text, Options, Font:="Arial", Width:="", Height:="", Measure:=0) +Gdip_TextToGraphics(pGraphics, Text, Options, Font="Arial", Width="", Height="", Measure=0) { IWidth := Width, IHeight:= Height - - pattern_opts := (A_AhkVersion < "2") ? "iO)" : "i)" - RegExMatch(Options, pattern_opts "X([\-\d\.]+)(p*)", xpos) - RegExMatch(Options, pattern_opts "Y([\-\d\.]+)(p*)", ypos) - RegExMatch(Options, pattern_opts "W([\-\d\.]+)(p*)", Width) - RegExMatch(Options, pattern_opts "H([\-\d\.]+)(p*)", Height) - RegExMatch(Options, pattern_opts "C(?!(entre|enter))([a-f\d]+)", Colour) - RegExMatch(Options, pattern_opts "Top|Up|Bottom|Down|vCentre|vCenter", vPos) - RegExMatch(Options, pattern_opts "NoWrap", NoWrap) - RegExMatch(Options, pattern_opts "R(\d)", Rendering) - RegExMatch(Options, pattern_opts "S(\d+)(p*)", Size) - - if Colour && IsInteger(Colour[2]) && !Gdip_DeleteBrush(Gdip_CloneBrush(Colour[2])) - PassBrush := 1, pBrush := Colour[2] - - if !(IWidth && IHeight) && ((xpos && xpos[2]) || (ypos && ypos[2]) || (Width && Width[2]) || (Height && Height[2]) || (Size && Size[2])) + + RegExMatch(Options, "i)X([\-\d\.]+)(p*)", xpos) + RegExMatch(Options, "i)Y([\-\d\.]+)(p*)", ypos) + RegExMatch(Options, "i)W([\-\d\.]+)(p*)", Width) + RegExMatch(Options, "i)H([\-\d\.]+)(p*)", Height) + RegExMatch(Options, "i)C(?!(entre|enter))([a-f\d]+)", Colour) + RegExMatch(Options, "i)Top|Up|Bottom|Down|vCentre|vCenter", vPos) + RegExMatch(Options, "i)NoWrap", NoWrap) + RegExMatch(Options, "i)R(\d)", Rendering) + RegExMatch(Options, "i)S(\d+)(p*)", Size) + + if !Gdip_DeleteBrush(Gdip_CloneBrush(Colour2)) + PassBrush := 1, pBrush := Colour2 + + if !(IWidth && IHeight) && (xpos2 || ypos2 || Width2 || Height2 || Size2) return -1 Style := 0, Styles := "Regular|Bold|Italic|BoldItalic|Underline|Strikeout" - For eachStyle, valStyle in StrSplit( Styles, "|" ) + Loop, Parse, Styles, | { - if RegExMatch(Options, "\b" valStyle) - Style |= (valStyle != "StrikeOut") ? (A_Index-1) : 8 + if RegExMatch(Options, "\b" A_loopField) + Style |= (A_LoopField != "StrikeOut") ? (A_Index-1) : 8 } - + Align := 0, Alignments := "Near|Left|Centre|Center|Far|Right" - For eachAlignment, valAlignment in StrSplit( Alignments, "|" ) + Loop, Parse, Alignments, | { - if RegExMatch(Options, "\b" valAlignment) - Align |= A_Index//2.1 ; 0|0|1|1|2|2 + if RegExMatch(Options, "\b" A_loopField) + Align |= A_Index//2.1 ; 0|0|1|1|2|2 } - xpos := (xpos && (xpos[1] != "")) ? xpos[2] ? IWidth*(xpos[1]/100) : xpos[1] : 0 - ypos := (ypos && (ypos[1] != "")) ? ypos[2] ? IHeight*(ypos[1]/100) : ypos[1] : 0 - Width := (Width && Width[1]) ? Width[2] ? IWidth*(Width[1]/100) : Width[1] : IWidth - Height := (Height && Height[1]) ? Height[2] ? IHeight*(Height[1]/100) : Height[1] : IHeight + xpos := (xpos1 != "") ? xpos2 ? IWidth*(xpos1/100) : xpos1 : 0 + ypos := (ypos1 != "") ? ypos2 ? IHeight*(ypos1/100) : ypos1 : 0 + Width := Width1 ? Width2 ? IWidth*(Width1/100) : Width1 : IWidth + Height := Height1 ? Height2 ? IHeight*(Height1/100) : Height1 : IHeight if !PassBrush - Colour := "0x" (Colour && Colour[2] ? Colour[2] : "ff000000") - Rendering := (Rendering && (Rendering[1] >= 0) && (Rendering[1] <= 5)) ? Rendering[1] : 4 - Size := (Size && (Size[1] > 0)) ? Size[2] ? IHeight*(Size[1]/100) : Size[1] : 12 + Colour := "0x" (Colour2 ? Colour2 : "ff000000") + Rendering := ((Rendering1 >= 0) && (Rendering1 <= 5)) ? Rendering1 : 4 + Size := (Size1 > 0) ? Size2 ? IHeight*(Size1/100) : Size1 : 12 hFamily := Gdip_FontFamilyCreate(Font) hFont := Gdip_FontCreate(hFamily, Size, Style) @@ -2277,7 +1924,7 @@ Gdip_TextToGraphics(pGraphics, Text, Options, Font:="Arial", Width:="", Height:= pBrush := PassBrush ? pBrush : Gdip_BrushCreateSolid(Colour) if !(hFamily && hFont && hFormat && pBrush && pGraphics) return !pGraphics ? -2 : !hFamily ? -3 : !hFont ? -4 : !hFormat ? -5 : !pBrush ? -6 : 0 - + CreateRectF(RC, xpos, ypos, Width, Height) Gdip_SetStringFormatAlign(hFormat, Align) Gdip_SetTextRenderingHint(pGraphics, Rendering) @@ -2285,80 +1932,67 @@ Gdip_TextToGraphics(pGraphics, Text, Options, Font:="Arial", Width:="", Height:= if vPos { - ReturnRC := StrSplit(ReturnRC, "|") - - if (vPos[0] = "vCentre") || (vPos[0] = "vCenter") - ypos += (Height-ReturnRC[4])//2 - else if (vPos[0] = "Top") || (vPos[0] = "Up") + StringSplit, ReturnRC, ReturnRC, | + + if (vPos = "vCentre") || (vPos = "vCenter") + ypos += (Height-ReturnRC4)//2 + else if (vPos = "Top") || (vPos = "Up") ypos := 0 - else if (vPos[0] = "Bottom") || (vPos[0] = "Down") - ypos := Height-ReturnRC[4] - - CreateRectF(RC, xpos, ypos, Width, ReturnRC[4]) + else if (vPos = "Bottom") || (vPos = "Down") + ypos := Height-ReturnRC4 + + CreateRectF(RC, xpos, ypos, Width, ReturnRC4) ReturnRC := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC) } if !Measure - _E := Gdip_DrawString(pGraphics, Text, hFont, hFormat, pBrush, RC) + E := Gdip_DrawString(pGraphics, Text, hFont, hFormat, pBrush, RC) if !PassBrush Gdip_DeleteBrush(pBrush) - Gdip_DeleteStringFormat(hFormat) + Gdip_DeleteStringFormat(hFormat) Gdip_DeleteFont(hFont) Gdip_DeleteFontFamily(hFamily) - return _E ? _E : ReturnRC + return E ? E : ReturnRC } ;##################################################################################### Gdip_DrawString(pGraphics, sString, hFont, hFormat, pBrush, ByRef RectF) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - if (!A_IsUnicode) + if !A_IsUnicode { - nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, 0, "int", 0) + nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &sString, "int", -1, "uint", 0, "int", 0) VarSetCapacity(wString, nSize*2) - DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, &wString, "int", nSize) + DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &sString, "int", -1, "uint", &wString, "int", nSize) + return DllCall("gdiplus\GdipDrawString", "uint", pGraphics + , "uint", &wString, "int", -1, "uint", hFont, "uint", &RectF, "uint", hFormat, "uint", pBrush) } - - return DllCall("gdiplus\GdipDrawString" - , Ptr, pGraphics - , Ptr, A_IsUnicode ? &sString : &wString - , "int", -1 - , Ptr, hFont - , Ptr, &RectF - , Ptr, hFormat - , Ptr, pBrush) + else + { + return DllCall("gdiplus\GdipDrawString", "uint", pGraphics + , "uint", &sString, "int", -1, "uint", hFont, "uint", &RectF, "uint", hFormat, "uint", pBrush) + } } ;##################################################################################### Gdip_MeasureString(pGraphics, sString, hFont, hFormat, ByRef RectF) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - VarSetCapacity(RC, 16) if !A_IsUnicode { - nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, "uint", 0, "int", 0) - VarSetCapacity(wString, nSize*2) - DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, &wString, "int", nSize) + nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &sString, "int", -1, "uint", 0, "int", 0) + VarSetCapacity(wString, nSize*2) + DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &sString, "int", -1, "uint", &wString, "int", nSize) + DllCall("gdiplus\GdipMeasureString", "uint", pGraphics + , "uint", &wString, "int", -1, "uint", hFont, "uint", &RectF, "uint", hFormat, "uint", &RC, "uint*", Chars, "uint*", Lines) + } + else + { + DllCall("gdiplus\GdipMeasureString", "uint", pGraphics + , "uint", &sString, "int", -1, "uint", hFont, "uint", &RectF, "uint", hFormat, "uint", &RC, "uint*", Chars, "uint*", Lines) } - - Chars := 0 - Lines := 0 - DllCall("gdiplus\GdipMeasureString" - , Ptr, pGraphics - , Ptr, A_IsUnicode ? &sString : &wString - , "int", -1 - , Ptr, hFont - , Ptr, &RectF - , Ptr, hFormat - , Ptr, &RC - , "uint*", Chars - , "uint*", Lines) - return &RC ? NumGet(RC, 0, "float") "|" NumGet(RC, 4, "float") "|" NumGet(RC, 8, "float") "|" NumGet(RC, 12, "float") "|" Chars "|" Lines : 0 } @@ -2367,7 +2001,7 @@ Gdip_MeasureString(pGraphics, sString, hFont, hFormat, ByRef RectF) ; Far = 2 Gdip_SetStringFormatAlign(hFormat, Align) { - return DllCall("gdiplus\GdipSetStringFormatAlign", A_PtrSize ? "UPtr" : "UInt", hFormat, "int", Align) + return DllCall("gdiplus\GdipSetStringFormatAlign", "uint", hFormat, "int", Align) } ; StringFormatFlagsDirectionRightToLeft = 0x00000001 @@ -2378,12 +2012,11 @@ Gdip_SetStringFormatAlign(hFormat, Align) ; StringFormatFlagsMeasureTrailingSpaces = 0x00000800 ; StringFormatFlagsNoWrap = 0x00001000 ; StringFormatFlagsLineLimit = 0x00002000 -; StringFormatFlagsNoClip = 0x00004000 -Gdip_StringFormatCreate(Format:=0, Lang:=0) +; StringFormatFlagsNoClip = 0x00004000 +Gdip_StringFormatCreate(Format=0, Lang=0) { - hFormat := 0 - DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, A_PtrSize ? "UPtr*" : "UInt*", hFormat) - return hFormat + DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, "uint*", hFormat) + return hFormat } ; Regular = 0 @@ -2392,30 +2025,23 @@ Gdip_StringFormatCreate(Format:=0, Lang:=0) ; BoldItalic = 3 ; Underline = 4 ; Strikeout = 8 -Gdip_FontCreate(hFamily, Size, Style:=0) +Gdip_FontCreate(hFamily, Size, Style=0) { - hFont := 0 - DllCall("gdiplus\GdipCreateFont", A_PtrSize ? "UPtr" : "UInt", hFamily, "float", Size, "int", Style, "int", 0, A_PtrSize ? "UPtr*" : "UInt*", hFont) - return hFont + DllCall("gdiplus\GdipCreateFont", "uint", hFamily, "float", Size, "int", Style, "int", 0, "uint*", hFont) + return hFont } Gdip_FontFamilyCreate(Font) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - if (!A_IsUnicode) + if !A_IsUnicode { - nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &Font, "int", -1, "uint", 0, "int", 0) + nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &Font, "int", -1, "uint", 0, "int", 0) VarSetCapacity(wFont, nSize*2) - DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &Font, "int", -1, Ptr, &wFont, "int", nSize) + DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &Font, "int", -1, "uint", &wFont, "int", nSize) + DllCall("gdiplus\GdipCreateFontFamilyFromName", "uint", &wFont, "uint", 0, "uint*", hFamily) } - - hFamily := 0 - DllCall("gdiplus\GdipCreateFontFamilyFromName" - , Ptr, A_IsUnicode ? &Font : &wFont - , "uint", 0 - , A_PtrSize ? "UPtr*" : "UInt*", hFamily) - + else + DllCall("gdiplus\GdipCreateFontFamilyFromName", "uint", &Font, "uint", 0, "uint*", hFamily) return hFamily } @@ -2425,16 +2051,14 @@ Gdip_FontFamilyCreate(Font) Gdip_CreateAffineMatrix(m11, m12, m21, m22, x, y) { - Matrix := 0 - DllCall("gdiplus\GdipCreateMatrix2", "float", m11, "float", m12, "float", m21, "float", m22, "float", x, "float", y, A_PtrSize ? "UPtr*" : "UInt*", Matrix) - return Matrix + DllCall("gdiplus\GdipCreateMatrix2", "float", m11, "float", m12, "float", m21, "float", m22, "float", x, "float", y, "uint*", Matrix) + return Matrix } Gdip_CreateMatrix() { - Matrix := 0 - DllCall("gdiplus\GdipCreateMatrix", A_PtrSize ? "UPtr*" : "UInt*", Matrix) - return Matrix + DllCall("gdiplus\GdipCreateMatrix", "uint*", Matrix) + return Matrix } ;##################################################################################### @@ -2443,37 +2067,33 @@ Gdip_CreateMatrix() ; Alternate = 0 ; Winding = 1 -Gdip_CreatePath(BrushMode:=0) +Gdip_CreatePath(BrushMode=0) { - pPath := 0 - DllCall("gdiplus\GdipCreatePath", "int", BrushMode, A_PtrSize ? "UPtr*" : "UInt*", pPath) - return pPath + DllCall("gdiplus\GdipCreatePath", "int", BrushMode, "uint*", Path) + return Path } -Gdip_AddPathEllipse(pPath, x, y, w, h) +Gdip_AddPathEllipse(Path, x, y, w, h) { - return DllCall("gdiplus\GdipAddPathEllipse", A_PtrSize ? "UPtr" : "UInt", pPath, "float", x, "float", y, "float", w, "float", h) + return DllCall("gdiplus\GdipAddPathEllipse", "uint", Path, "float", x, "float", y, "float", w, "float", h) } -Gdip_AddPathPolygon(pPath, Points) +Gdip_AddPathPolygon(Path, Points) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - Points := StrSplit(Points, "|") - PointsLength := (A_AhkVersion < "2") ? Points.Length() : Points.Length - VarSetCapacity(PointF, 8*PointsLength) - for eachPoint, Point in Points + StringSplit, Points, Points, | + VarSetCapacity(PointF, 8*Points0) + Loop, %Points0% { - Coord := StrSplit(Point, ",") - NumPut(Coord[1], PointF, 8*(A_Index-1), "float"), NumPut(Coord[2], PointF, (8*(A_Index-1))+4, "float") - } + StringSplit, Coord, Points%A_Index%, `, + NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float") + } - return DllCall("gdiplus\GdipAddPathPolygon", Ptr, pPath, Ptr, &PointF, "int", PointsLength) + return DllCall("gdiplus\GdipAddPathPolygon", "uint", Path, "uint", &PointF, "int", Points0) } -Gdip_DeletePath(pPath) +Gdip_DeletePath(Path) { - return DllCall("gdiplus\GdipDeletePath", A_PtrSize ? "UPtr" : "UInt", pPath) + return DllCall("gdiplus\GdipDeletePath", "uint", Path) } ;##################################################################################### @@ -2487,7 +2107,7 @@ Gdip_DeletePath(pPath) ; AntiAlias = 4 Gdip_SetTextRenderingHint(pGraphics, RenderingHint) { - return DllCall("gdiplus\GdipSetTextRenderingHint", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", RenderingHint) + return DllCall("gdiplus\GdipSetTextRenderingHint", "uint", pGraphics, "int", RenderingHint) } ; Default = 0 @@ -2500,7 +2120,7 @@ Gdip_SetTextRenderingHint(pGraphics, RenderingHint) ; HighQualityBicubic = 7 Gdip_SetInterpolationMode(pGraphics, InterpolationMode) { - return DllCall("gdiplus\GdipSetInterpolationMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", InterpolationMode) + return DllCall("gdiplus\GdipSetInterpolationMode", "uint", pGraphics, "int", InterpolationMode) } ; Default = 0 @@ -2510,14 +2130,14 @@ Gdip_SetInterpolationMode(pGraphics, InterpolationMode) ; AntiAlias = 4 Gdip_SetSmoothingMode(pGraphics, SmoothingMode) { - return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode) + return DllCall("gdiplus\GdipSetSmoothingMode", "uint", pGraphics, "int", SmoothingMode) } ; CompositingModeSourceOver = 0 (blended) ; CompositingModeSourceCopy = 1 (overwrite) -Gdip_SetCompositingMode(pGraphics, CompositingMode:=0) +Gdip_SetCompositingMode(pGraphics, CompositingMode=0) { - return DllCall("gdiplus\GdipSetCompositingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", CompositingMode) + return DllCall("gdiplus\GdipSetCompositingMode", "uint", pGraphics, "int", CompositingMode) } ;##################################################################################### @@ -2526,51 +2146,46 @@ Gdip_SetCompositingMode(pGraphics, CompositingMode:=0) Gdip_Startup() { - Ptr := A_PtrSize ? "UPtr" : "UInt" - pToken := 0 - - if !DllCall("GetModuleHandle", "str", "gdiplus", Ptr) + if !DllCall("GetModuleHandle", "str", "gdiplus") DllCall("LoadLibrary", "str", "gdiplus") - VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1) - DllCall("gdiplus\GdiplusStartup", A_PtrSize ? "UPtr*" : "uint*", pToken, Ptr, &si, Ptr, 0) + VarSetCapacity(si, 16, 0), si := Chr(1) + DllCall("gdiplus\GdiplusStartup", "uint*", pToken, "uint", &si, "uint", 0) return pToken } Gdip_Shutdown(pToken) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - DllCall("gdiplus\GdiplusShutdown", Ptr, pToken) - if hModule := DllCall("GetModuleHandle", "str", "gdiplus", Ptr) - DllCall("FreeLibrary", Ptr, hModule) + DllCall("gdiplus\GdiplusShutdown", "uint", pToken) + if hModule := DllCall("GetModuleHandle", "str", "gdiplus") + DllCall("FreeLibrary", "uint", hModule) return 0 } ; Prepend = 0; The new operation is applied before the old operation. ; Append = 1; The new operation is applied after the old operation. -Gdip_RotateWorldTransform(pGraphics, Angle, MatrixOrder:=0) +Gdip_RotateWorldTransform(pGraphics, Angle, MatrixOrder=0) { - return DllCall("gdiplus\GdipRotateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", Angle, "int", MatrixOrder) + return DllCall("gdiplus\GdipRotateWorldTransform", "uint", pGraphics, "float", Angle, "int", MatrixOrder) } -Gdip_ScaleWorldTransform(pGraphics, x, y, MatrixOrder:=0) +Gdip_ScaleWorldTransform(pGraphics, x, y, MatrixOrder=0) { - return DllCall("gdiplus\GdipScaleWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder) + return DllCall("gdiplus\GdipScaleWorldTransform", "uint", pGraphics, "float", x, "float", y, "int", MatrixOrder) } -Gdip_TranslateWorldTransform(pGraphics, x, y, MatrixOrder:=0) +Gdip_TranslateWorldTransform(pGraphics, x, y, MatrixOrder=0) { - return DllCall("gdiplus\GdipTranslateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder) + return DllCall("gdiplus\GdipTranslateWorldTransform", "uint", pGraphics, "float", x, "float", y, "int", MatrixOrder) } Gdip_ResetWorldTransform(pGraphics) { - return DllCall("gdiplus\GdipResetWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics) + return DllCall("gdiplus\GdipResetWorldTransform", "uint", pGraphics) } Gdip_GetRotatedTranslation(Width, Height, Angle, ByRef xTranslation, ByRef yTranslation) { - pi := 3.14159, TAngle := Angle*(pi/180) + pi := 3.14159, TAngle := Angle*(pi/180) Bound := (Angle >= 0) ? Mod(Angle, 360) : 360-Mod(-Angle, -360) if ((Bound >= 0) && (Bound <= 90)) @@ -2607,11 +2222,11 @@ Gdip_GetRotatedDimensions(Width, Height, Angle, ByRef RWidth, ByRef RHeight) ; RotateNoneFlipXY = Rotate180FlipNone ; Rotate90FlipXY = Rotate270FlipNone ; Rotate180FlipXY = RotateNoneFlipNone -; Rotate270FlipXY = Rotate90FlipNone +; Rotate270FlipXY = Rotate90FlipNone -Gdip_ImageRotateFlip(pBitmap, RotateFlipType:=1) +Gdip_ImageRotateFlip(pBitmap, RotateFlipType=1) { - return DllCall("gdiplus\GdipImageRotateFlip", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", RotateFlipType) + return DllCall("gdiplus\GdipImageRotateFlip", "uint", pBitmap, "int", RotateFlipType) } ; Replace = 0 @@ -2620,85 +2235,77 @@ Gdip_ImageRotateFlip(pBitmap, RotateFlipType:=1) ; Xor = 3 ; Exclude = 4 ; Complement = 5 -Gdip_SetClipRect(pGraphics, x, y, w, h, CombineMode:=0) +Gdip_SetClipRect(pGraphics, x, y, w, h, CombineMode=0) { - return DllCall("gdiplus\GdipSetClipRect", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "float", w, "float", h, "int", CombineMode) + return DllCall("gdiplus\GdipSetClipRect", "uint", pGraphics, "float", x, "float", y, "float", w, "float", h, "int", CombineMode) } -Gdip_SetClipPath(pGraphics, pPath, CombineMode:=0) +Gdip_SetClipPath(pGraphics, Path, CombineMode=0) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - return DllCall("gdiplus\GdipSetClipPath", Ptr, pGraphics, Ptr, pPath, "int", CombineMode) + return DllCall("gdiplus\GdipSetClipPath", "uint", pGraphics, "uint", Path, "int", CombineMode) } Gdip_ResetClip(pGraphics) { - return DllCall("gdiplus\GdipResetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics) + return DllCall("gdiplus\GdipResetClip", "uint", pGraphics) } Gdip_GetClipRegion(pGraphics) { Region := Gdip_CreateRegion() - DllCall("gdiplus\GdipGetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics, "UInt", Region) + DllCall("gdiplus\GdipGetClip", "uint" pGraphics, "uint*", Region) return Region } -Gdip_SetClipRegion(pGraphics, Region, CombineMode:=0) +Gdip_SetClipRegion(pGraphics, Region, CombineMode=0) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("gdiplus\GdipSetClipRegion", Ptr, pGraphics, Ptr, Region, "int", CombineMode) + return DllCall("gdiplus\GdipSetClipRegion", "uint", pGraphics, "uint", Region, "int", CombineMode) } Gdip_CreateRegion() { - Region := 0 - DllCall("gdiplus\GdipCreateRegion", "UInt*", Region) + DllCall("gdiplus\GdipCreateRegion", "uint*", Region) return Region } Gdip_DeleteRegion(Region) { - return DllCall("gdiplus\GdipDeleteRegion", A_PtrSize ? "UPtr" : "UInt", Region) + return DllCall("gdiplus\GdipDeleteRegion", "uint", Region) } ;##################################################################################### ; BitmapLockBits ;##################################################################################### -Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, ByRef BitmapData, LockMode := 3, PixelFormat := 0x26200a) -{ - Ptr := A_PtrSize ? "UPtr" : "UInt" - - CreateRect(_Rect, x, y, w, h) - VarSetCapacity(BitmapData, 16+2*(A_PtrSize ? A_PtrSize : 4), 0) - _E := DllCall("Gdiplus\GdipBitmapLockBits", Ptr, pBitmap, Ptr, &_Rect, "uint", LockMode, "int", PixelFormat, Ptr, &BitmapData) - Stride := NumGet(BitmapData, 8, "Int") - Scan0 := NumGet(BitmapData, 16, Ptr) - return _E +Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, ByRef BitmapData, LockMode = 3, PixelFormat = 0x26200a) +{ + CreateRect(Rect, x, y, w, h) + VarSetCapacity(BitmapData, 21, 0) + E := DllCall("Gdiplus\GdipBitmapLockBits", "uint", pBitmap, "uint", &Rect, "uint", LockMode, "int", PixelFormat, "uint", &BitmapData) + Stride := NumGet(BitmapData, 8) + Scan0 := NumGet(BitmapData, 16) + return E } ;##################################################################################### Gdip_UnlockBits(pBitmap, ByRef BitmapData) { - Ptr := A_PtrSize ? "UPtr" : "UInt" - - return DllCall("Gdiplus\GdipBitmapUnlockBits", Ptr, pBitmap, Ptr, &BitmapData) + return DllCall("Gdiplus\GdipBitmapUnlockBits", "uint", pBitmap, "uint", &BitmapData) } ;##################################################################################### Gdip_SetLockBitPixel(ARGB, Scan0, x, y, Stride) { - Numput(ARGB, Scan0+0, (x*4)+(y*Stride), "UInt") + Numput(ARGB, Scan0+0, (x*4)+(y*Stride)) } ;##################################################################################### Gdip_GetLockBitPixel(Scan0, x, y, Stride) { - return NumGet(Scan0+0, (x*4)+(y*Stride), "UInt") + return NumGet(Scan0+0, (x*4)+(y*Stride)) } ;##################################################################################### @@ -2706,74 +2313,42 @@ Gdip_GetLockBitPixel(Scan0, x, y, Stride) Gdip_PixelateBitmap(pBitmap, ByRef pBitmapOut, BlockSize) { static PixelateBitmap - - Ptr := A_PtrSize ? "UPtr" : "UInt" - - if (!PixelateBitmap) + if !PixelateBitmap { - if A_PtrSize != 8 ; x86 machine code - MCode_PixelateBitmap := " - (LTrim Join - 558BEC83EC3C8B4514538B5D1C99F7FB56578BC88955EC894DD885C90F8E830200008B451099F7FB8365DC008365E000894DC88955F08945E833FF897DD4 - 397DE80F8E160100008BCB0FAFCB894DCC33C08945F88945FC89451C8945143BD87E608B45088D50028BC82BCA8BF02BF2418945F48B45E02955F4894DC4 - 8D0CB80FAFCB03CA895DD08BD1895DE40FB64416030145140FB60201451C8B45C40FB604100145FC8B45F40FB604020145F883C204FF4DE475D6034D18FF - 4DD075C98B4DCC8B451499F7F98945148B451C99F7F989451C8B45FC99F7F98945FC8B45F899F7F98945F885DB7E648B450C8D50028BC82BCA83C103894D - C48BC82BCA41894DF48B4DD48945E48B45E02955E48D0C880FAFCB03CA895DD08BD18BF38A45148B7DC48804178A451C8B7DF488028A45FC8804178A45F8 - 8B7DE488043A83C2044E75DA034D18FF4DD075CE8B4DCC8B7DD447897DD43B7DE80F8CF2FEFFFF837DF0000F842C01000033C08945F88945FC89451C8945 - 148945E43BD87E65837DF0007E578B4DDC034DE48B75E80FAF4D180FAFF38B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945CC0F - B6440E030145140FB60101451C0FB6440F010145FC8B45F40FB604010145F883C104FF4DCC75D8FF45E4395DE47C9B8B4DF00FAFCB85C9740B8B451499F7 - F9894514EB048365140033F63BCE740B8B451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB - 038975F88975E43BDE7E5A837DF0007E4C8B4DDC034DE48B75E80FAF4D180FAFF38B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955CC8A55 - 1488540E038A551C88118A55FC88540F018A55F888140183C104FF4DCC75DFFF45E4395DE47CA68B45180145E0015DDCFF4DC80F8594FDFFFF8B451099F7 - FB8955F08945E885C00F8E450100008B45EC0FAFC38365DC008945D48B45E88945CC33C08945F88945FC89451C8945148945103945EC7E6085DB7E518B4D - D88B45080FAFCB034D108D50020FAF4D18034DDC8BF08BF88945F403CA2BF22BFA2955F4895DC80FB6440E030145140FB60101451C0FB6440F010145FC8B - 45F40FB604080145F883C104FF4DC875D8FF45108B45103B45EC7CA08B4DD485C9740B8B451499F7F9894514EB048365140033F63BCE740B8B451C99F7F9 - 89451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975103975EC7E5585DB7E468B4DD88B450C - 0FAFCB034D108D50020FAF4D18034DDC8BF08BF803CA2BF22BFA2BC2895DC88A551488540E038A551C88118A55FC88540F018A55F888140183C104FF4DC8 - 75DFFF45108B45103B45EC7CAB8BC3C1E0020145DCFF4DCC0F85CEFEFFFF8B4DEC33C08945F88945FC89451C8945148945103BC87E6C3945F07E5C8B4DD8 - 8B75E80FAFCB034D100FAFF30FAF4D188B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945C80FB6440E030145140FB60101451C0F - B6440F010145FC8B45F40FB604010145F883C104FF4DC875D833C0FF45108B4DEC394D107C940FAF4DF03BC874068B451499F7F933F68945143BCE740B8B - 451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975083975EC7E63EB0233F639 - 75F07E4F8B4DD88B75E80FAFCB034D080FAFF30FAF4D188B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955108A551488540E038A551C8811 - 8A55FC88540F018A55F888140883C104FF4D1075DFFF45088B45083B45EC7C9F5F5E33C05BC9C21800 - )" - else ; x64 machine code - MCode_PixelateBitmap := " - (LTrim Join - 4489442418488954241048894C24085355565741544155415641574883EC28418BC1448B8C24980000004C8BDA99488BD941F7F9448BD0448BFA8954240C - 448994248800000085C00F8E9D020000418BC04533E4458BF299448924244C8954241041F7F933C9898C24980000008BEA89542404448BE889442408EB05 - 4C8B5C24784585ED0F8E1A010000458BF1418BFD48897C2418450FAFF14533D233F633ED4533E44533ED4585C97E5B4C63BC2490000000418D040A410FAF - C148984C8D441802498BD9498BD04D8BD90FB642010FB64AFF4403E80FB60203E90FB64AFE4883C2044403E003F149FFCB75DE4D03C748FFCB75D0488B7C - 24188B8C24980000004C8B5C2478418BC59941F7FE448BE8418BC49941F7FE448BE08BC59941F7FE8BE88BC69941F7FE8BF04585C97E4048639C24900000 - 004103CA4D8BC1410FAFC94863C94A8D541902488BCA498BC144886901448821408869FF408871FE4883C10448FFC875E84803D349FFC875DA8B8C249800 - 0000488B5C24704C8B5C24784183C20448FFCF48897C24180F850AFFFFFF8B6C2404448B2424448B6C24084C8B74241085ED0F840A01000033FF33DB4533 - DB4533D24533C04585C97E53488B74247085ED7E42438D0C04418BC50FAF8C2490000000410FAFC18D04814863C8488D5431028BCD0FB642014403D00FB6 - 024883C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC17CB28BCD410FAFC985C9740A418BC299F7F98BF0EB0233F685C9740B418BC3 - 99F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585C97E4D4C8B74247885ED7E3841 - 8D0C14418BC50FAF8C2490000000410FAFC18D04814863C84A8D4431028BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2413BD17CBD - 4C8B7424108B8C2498000000038C2490000000488B5C24704503E149FFCE44892424898C24980000004C897424100F859EFDFFFF448B7C240C448B842480 - 000000418BC09941F7F98BE8448BEA89942498000000896C240C85C00F8E3B010000448BAC2488000000418BCF448BF5410FAFC9898C248000000033FF33 - ED33F64533DB4533D24533C04585FF7E524585C97E40418BC5410FAFC14103C00FAF84249000000003C74898488D541802498BD90FB642014403D00FB602 - 4883C2044403D80FB642FB03F00FB642FA03E848FFCB75DE488B5C247041FFC0453BC77CAE85C9740B418BC299F7F9448BE0EB034533E485C9740A418BC3 - 99F7F98BD8EB0233DB85C9740A8BC699F7F9448BD8EB034533DB85C9740A8BC599F7F9448BD0EB034533D24533C04585FF7E4E488B4C24784585C97E3541 - 8BC5410FAFC14103C00FAF84249000000003C74898488D540802498BC144886201881A44885AFF448852FE4883C20448FFC875E941FFC0453BC77CBE8B8C - 2480000000488B5C2470418BC1C1E00203F849FFCE0F85ECFEFFFF448BAC24980000008B6C240C448BA4248800000033FF33DB4533DB4533D24533C04585 - FF7E5A488B7424704585ED7E48418BCC8BC5410FAFC94103C80FAF8C2490000000410FAFC18D04814863C8488D543102418BCD0FB642014403D00FB60248 - 83C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC77CAB418BCF410FAFCD85C9740A418BC299F7F98BF0EB0233F685C9740B418BC399 - F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585FF7E4E4585ED7E42418BCC8BC541 - 0FAFC903CA0FAF8C2490000000410FAFC18D04814863C8488B442478488D440102418BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2 - 413BD77CB233C04883C428415F415E415D415C5F5E5D5BC3 - )" + MCode_PixelateBitmap := "83EC388B4424485355568B74245C99F7FE8B5C244C8B6C2448578BF88BCA894C241C897C243485FF0F8E2E0300008B44245" + . "499F7FE897C24448944242833C089542418894424308944242CEB038D490033FF397C2428897C24380F8E750100008BCE0FAFCE894C24408DA4240000" + . "000033C03BF08944241089442460894424580F8E8A0000008B5C242C8D4D028BD52BD183C203895424208D3CBB0FAFFE8BD52BD142895424248BD52BD" + . "103F9897C24148974243C8BCF8BFE8DA424000000008B5C24200FB61C0B03C30FB619015C24588B5C24240FB61C0B015C24600FB61C11015C241083C1" + . "0483EF0175D38B7C2414037C245C836C243C01897C241475B58B7C24388B6C244C8B5C24508B4C244099F7F9894424148B44245899F7F9894424588B4" + . "4246099F7F9894424608B44241099F7F98944241085F60F8E820000008D4B028BC32BC18D68038B44242C8D04B80FAFC68BD32BD142895424248BD32B" + . "D103C18944243C89742420EB038D49008BC88BFE0FB64424148B5C24248804290FB644245888010FB644246088040B0FB644241088040A83C10483EF0" + . "175D58B44243C0344245C836C2420018944243C75BE8B4C24408B5C24508B6C244C8B7C2438473B7C2428897C24380F8C9FFEFFFF8B4C241C33D23954" + . "24180F846401000033C03BF2895424108954246089542458895424148944243C0F8E82000000EB0233D2395424187E6F8B4C243003C80FAF4C245C8B4" + . "424280FAFC68D550203CA8D0C818BC52BC283C003894424208BC52BC2408BFD2BFA8B54241889442424895424408B4424200FB614080FB60101542414" + . "8B542424014424580FB6040A0FB61439014424600154241083C104836C24400175CF8B44243C403BC68944243C7C808B4C24188B4424140FAFCE99F7F" + . "9894424148B44245899F7F9894424588B44246099F7F9894424608B44241099F7F98944241033C08944243C85F60F8E7F000000837C2418007E6F8B4C" + . "243003C80FAF4C245C8B4424280FAFC68D530203CA8D0C818BC32BC283C003894424208BC32BC2408BFB2BFA8B54241889442424895424400FB644241" + . "48B5424208804110FB64424580FB654246088018B4424248814010FB654241088143983C104836C24400175CF8B44243C403BC68944243C7C818B4C24" + . "1C8B44245C0144242C01742430836C2444010F85F4FCFFFF8B44245499F7FE895424188944242885C00F8E890100008BF90FAFFE33D2897C243C89542" + . "45489442438EB0233D233C03BCA89542410895424608954245889542414894424400F8E840000003BF27E738B4C24340FAFCE03C80FAF4C245C034C24" + . "548D55028BC52BC283C003894424208BC52BC2408BFD03CA894424242BFA89742444908B5424200FB6040A0FB611014424148B442424015424580FB61" + . "4080FB6040F015424600144241083C104836C24440175CF8B4424408B7C243C8B4C241C33D2403BC1894424400F8C7CFFFFFF8B44241499F7FF894424" + . "148B44245899F7FF894424588B44246099F7FF894424608B44241099F7FF8944241033C08944244085C90F8E8000000085F67E738B4C24340FAFCE03C" + . "80FAF4C245C034C24548D53028BC32BC283C003894424208BC32BC2408BFB03CA894424242BFA897424448D49000FB65424148B4424208814010FB654" + . "24580FB644246088118B5424248804110FB644241088043983C104836C24440175CF8B4424408B7C243C8B4C241C403BC1894424407C808D04B500000" + . "00001442454836C2438010F858CFEFFFF33D233C03BCA89542410895424608954245889542414894424440F8E9A000000EB048BFF33D2395424180F8E" + . "7D0000008B4C24340FAFCE03C80FAF4C245C8B4424280FAFC68D550203CA8D0C818BC52BC283C003894424208BC52BC240894424248BC52BC28B54241" + . "8895424548DA424000000008B5424200FB6140A015424140FB611015424588B5424240FB6140A015424600FB614010154241083C104836C24540175CF" + . "8B4424448B4C241C403BC1894424440F8C6AFFFFFF0FAF4C24188B44241499F7F9894424148B44245899F7F9894424588B44246099F7F9894424608B4" + . "4241099F7F98944241033C03944241C894424540F8E7B0000008B7C241885FF7E688B4C24340FAFCE03C80FAF4C245C8B4424280FAFC68D530203CA8D" + . "0C818BC32BC283C003894424208BC32BC2408BEB894424242BEA0FB65424148B4424208814010FB65424580FB644246088118B5424248804110FB6442" + . "41088042983C10483EF0175D18B442454403B44241C894424547C855F5E5D33C05B83C438C3" VarSetCapacity(PixelateBitmap, StrLen(MCode_PixelateBitmap)//2) - nCount := StrLen(MCode_PixelateBitmap)//2 - N := (A_AhkVersion < 2) ? nCount : "nCount" - Loop %N% - NumPut("0x" SubStr(MCode_PixelateBitmap, (2*A_Index)-1, 2), PixelateBitmap, A_Index-1, "UChar") - DllCall("VirtualProtect", Ptr, &PixelateBitmap, Ptr, VarSetCapacity(PixelateBitmap), "uint", 0x40, A_PtrSize ? "UPtr*" : "UInt*", 0) + Loop % StrLen(MCode_PixelateBitmap)//2 ;% + NumPut("0x" SubStr(MCode_PixelateBitmap, (2*A_Index)-1, 2), PixelateBitmap, A_Index-1, "char") } Gdip_GetImageDimensions(pBitmap, Width, Height) - if (Width != Gdip_GetImageWidth(pBitmapOut) || Height != Gdip_GetImageHeight(pBitmapOut)) return -1 if (BlockSize > Width || BlockSize > Height) @@ -2784,9 +2359,7 @@ Gdip_PixelateBitmap(pBitmap, ByRef pBitmapOut, BlockSize) if (E1 || E2) return -3 - ; E := - unused exit code - DllCall(&PixelateBitmap, Ptr, Scan01, Ptr, Scan02, "int", Width, "int", Height, "int", Stride1, "int", BlockSize) - + E := DllCall(&PixelateBitmap, "uint", Scan01, "uint", Scan02, "int", Width, "int", Height, "int", Stride1, "int", BlockSize) Gdip_UnlockBits(pBitmap, BitmapData1), Gdip_UnlockBits(pBitmapOut, BitmapData2) return 0 } @@ -2835,211 +2408,3 @@ Gdip_BFromARGB(ARGB) { return 0x000000ff & ARGB } - -;##################################################################################### - -StrGetB(Address, Length:=-1, Encoding:=0) -{ - ; Flexible parameter handling: - if !IsInteger(Length) - Encoding := Length, Length := -1 - - ; Check for obvious errors. - if (Address+0 < 1024) - return - - ; Ensure 'Encoding' contains a numeric identifier. - if (Encoding = "UTF-16") - Encoding := 1200 - else if (Encoding = "UTF-8") - Encoding := 65001 - else if SubStr(Encoding,1,2)="CP" - Encoding := SubStr(Encoding,3) - - if !Encoding ; "" or 0 - { - ; No conversion necessary, but we might not want the whole string. - if (Length == -1) - Length := DllCall("lstrlen", "uint", Address) - VarSetCapacity(String, Length) - DllCall("lstrcpyn", "str", String, "uint", Address, "int", Length + 1) - } - else if (Encoding = 1200) ; UTF-16 - { - char_count := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "uint", 0, "uint", 0, "uint", 0, "uint", 0) - VarSetCapacity(String, char_count) - DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "str", String, "int", char_count, "uint", 0, "uint", 0) - } - else if IsInteger(Encoding) - { - ; Convert from target encoding to UTF-16 then to the active code page. - char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", 0, "int", 0) - VarSetCapacity(String, char_count * 2) - char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", &String, "int", char_count * 2) - String := StrGetB(&String, char_count, 1200) - } - - return String -} - - -;##################################################################################### -; in AHK v1: uses normal 'if var is' command -; in AHK v2: all if's are expression-if, so the Integer variable is dereferenced to the string -;##################################################################################### -IsInteger(Var) { - Static Integer := "Integer" - If Var Is Integer - Return True - Return False -} - -IsNumber(Var) { - Static number := "number" - If Var Is number - Return True - Return False -} - - - -; ====================================================================================================================== -; Multiple Display Monitors Functions -> msdn.microsoft.com/en-us/library/dd145072(v=vs.85).aspx -; by 'just me' -; https://autohotkey.com/boards/viewtopic.php?f=6&t=4606 -; ====================================================================================================================== -GetMonitorCount() -{ - Monitors := MDMF_Enum() - for k,v in Monitors - count := A_Index - return count -} - -GetMonitorInfo(MonitorNum) -{ - Monitors := MDMF_Enum() - for k,v in Monitors - if (v.Num = MonitorNum) - return v -} - -GetPrimaryMonitor() -{ - Monitors := MDMF_Enum() - for k,v in Monitors - If (v.Primary) - return v.Num -} -; ---------------------------------------------------------------------------------------------------------------------- -; Name ..........: MDMF - Multiple Display Monitor Functions -; Description ...: Various functions for multiple display monitor environments -; Tested with ...: AHK 1.1.32.00 (A32/U32/U64) and 2.0-a108-a2fa0498 (U32/U64) -; Original Author: just me (https://www.autohotkey.com/boards/viewtopic.php?f=6&t=4606) -; Mod Authors ...: iPhilip, guest3456 -; Changes .......: Modified to work with v2.0-a108 and changed 'Count' key to 'TotalCount' to avoid conflicts -; ................ Modified MDMF_Enum() so that it works under both AHK v1 and v2. -; ................ Modified MDMF_EnumProc() to provide Count and Primary keys to the Monitors array. -; ................ Modified MDMF_FromHWND() to allow flag values that determine the function's return value if the -; ................ window does not intersect any display monitor. -; ................ Modified MDMF_FromPoint() to allow the cursor position to be returned ByRef if not specified and -; ................ allow flag values that determine the function's return value if the point is not contained within -; ................ any display monitor. -; ................ Modified MDMF_FromRect() to allow flag values that determine the function's return value if the -; ................ rectangle does not intersect any display monitor. -;................. Modified MDMF_GetInfo() with minor changes. -; ---------------------------------------------------------------------------------------------------------------------- -; -; ====================================================================================================================== -; Multiple Display Monitors Functions -> msdn.microsoft.com/en-us/library/dd145072(v=vs.85).aspx ======================= -; ====================================================================================================================== -; Enumerates display monitors and returns an object containing the properties of all monitors or the specified monitor. -; ====================================================================================================================== -MDMF_Enum(HMON := "") { - Static CallbackFunc := Func(A_AhkVersion < "2" ? "RegisterCallback" : "CallbackCreate") - Static EnumProc := CallbackFunc.Call("MDMF_EnumProc") - Static Obj := (A_AhkVersion < "2") ? "Object" : "Map" - Static Monitors := {} - If (HMON = "") ; new enumeration - { - Monitors := %Obj%("TotalCount", 0) - If !DllCall("User32.dll\EnumDisplayMonitors", "Ptr", 0, "Ptr", 0, "Ptr", EnumProc, "Ptr", &Monitors, "Int") - Return False - } - Return (HMON = "") ? Monitors : Monitors.HasKey(HMON) ? Monitors[HMON] : False -} -; ====================================================================================================================== -; Callback function that is called by the MDMF_Enum function. -; ====================================================================================================================== -MDMF_EnumProc(HMON, HDC, PRECT, ObjectAddr) { - Monitors := Object(ObjectAddr) - Monitors[HMON] := MDMF_GetInfo(HMON) - Monitors["TotalCount"]++ - If (Monitors[HMON].Primary) - Monitors["Primary"] := HMON - Return True -} -; ====================================================================================================================== -; Retrieves the display monitor that has the largest area of intersection with a specified window. -; The following flag values determine the function's return value if the window does not intersect any display monitor: -; MONITOR_DEFAULTTONULL = 0 - Returns NULL. -; MONITOR_DEFAULTTOPRIMARY = 1 - Returns a handle to the primary display monitor. -; MONITOR_DEFAULTTONEAREST = 2 - Returns a handle to the display monitor that is nearest to the window. -; ====================================================================================================================== -MDMF_FromHWND(HWND, Flag := 0) { - Return DllCall("User32.dll\MonitorFromWindow", "Ptr", HWND, "UInt", Flag, "Ptr") -} -; ====================================================================================================================== -; Retrieves the display monitor that contains a specified point. -; If either X or Y is empty, the function will use the current cursor position for this value and return it ByRef. -; The following flag values determine the function's return value if the point is not contained within any -; display monitor: -; MONITOR_DEFAULTTONULL = 0 - Returns NULL. -; MONITOR_DEFAULTTOPRIMARY = 1 - Returns a handle to the primary display monitor. -; MONITOR_DEFAULTTONEAREST = 2 - Returns a handle to the display monitor that is nearest to the point. -; ====================================================================================================================== -MDMF_FromPoint(ByRef X := "", ByRef Y := "", Flag := 0) { - If (X = "") || (Y = "") { - VarSetCapacity(PT, 8, 0) - DllCall("User32.dll\GetCursorPos", "Ptr", &PT, "Int") - If (X = "") - X := NumGet(PT, 0, "Int") - If (Y = "") - Y := NumGet(PT, 4, "Int") - } - Return DllCall("User32.dll\MonitorFromPoint", "Int64", (X & 0xFFFFFFFF) | (Y << 32), "UInt", Flag, "Ptr") -} -; ====================================================================================================================== -; Retrieves the display monitor that has the largest area of intersection with a specified rectangle. -; Parameters are consistent with the common AHK definition of a rectangle, which is X, Y, W, H instead of -; Left, Top, Right, Bottom. -; The following flag values determine the function's return value if the rectangle does not intersect any -; display monitor: -; MONITOR_DEFAULTTONULL = 0 - Returns NULL. -; MONITOR_DEFAULTTOPRIMARY = 1 - Returns a handle to the primary display monitor. -; MONITOR_DEFAULTTONEAREST = 2 - Returns a handle to the display monitor that is nearest to the rectangle. -; ====================================================================================================================== -MDMF_FromRect(X, Y, W, H, Flag := 0) { - VarSetCapacity(RC, 16, 0) - NumPut(X, RC, 0, "Int"), NumPut(Y, RC, 4, "Int"), NumPut(X + W, RC, 8, "Int"), NumPut(Y + H, RC, 12, "Int") - Return DllCall("User32.dll\MonitorFromRect", "Ptr", &RC, "UInt", Flag, "Ptr") -} -; ====================================================================================================================== -; Retrieves information about a display monitor. -; ====================================================================================================================== -MDMF_GetInfo(HMON) { - NumPut(VarSetCapacity(MIEX, 40 + (32 << !!A_IsUnicode)), MIEX, 0, "UInt") - If DllCall("User32.dll\GetMonitorInfo", "Ptr", HMON, "Ptr", &MIEX, "Int") - Return {Name: (Name := StrGet(&MIEX + 40, 32)) ; CCHDEVICENAME = 32 - , Num: RegExReplace(Name, ".*(\d+)$", "$1") - , Left: NumGet(MIEX, 4, "Int") ; display rectangle - , Top: NumGet(MIEX, 8, "Int") ; " - , Right: NumGet(MIEX, 12, "Int") ; " - , Bottom: NumGet(MIEX, 16, "Int") ; " - , WALeft: NumGet(MIEX, 20, "Int") ; work area - , WATop: NumGet(MIEX, 24, "Int") ; " - , WARight: NumGet(MIEX, 28, "Int") ; " - , WABottom: NumGet(MIEX, 32, "Int") ; " - , Primary: NumGet(MIEX, 36, "UInt")} ; contains a non-zero value for the primary monitor. - Return False -} \ No newline at end of file diff --git a/Scripts/Sai/Gdip_ImageSearch.ahk b/Scripts/Libraries/Gdip_ImageSearch.ahk similarity index 99% rename from Scripts/Sai/Gdip_ImageSearch.ahk rename to Scripts/Libraries/Gdip_ImageSearch.ahk index 6c2a9b2..a2914ef 100644 --- a/Scripts/Sai/Gdip_ImageSearch.ahk +++ b/Scripts/Libraries/Gdip_ImageSearch.ahk @@ -583,4 +583,4 @@ Gdip_LockedBitsSearch(hStride,hScan,hWidth,hHeight,nStride,nScan,nWidth,nHeight , "int",hStride, "int",nStride, "int",sx1, "int",sy1, "int",sx2, "int",sy2, "int",Variation , "int",sd, "cdecl int") Return ( E == "" ? -3007 : E ) -} \ No newline at end of file +} diff --git a/Scripts/Libraries/ImageSearch.ahk b/Scripts/Libraries/ImageSearch.ahk new file mode 100644 index 0000000..12e8ef0 --- /dev/null +++ b/Scripts/Libraries/ImageSearch.ahk @@ -0,0 +1,46 @@ + +#Include %A_LineFile%\..\Gdip.ahk +#Include %A_LineFile%\..\Gdip_ImageSearch.ahk + +; https://github.com/Masonjar13/AHK-Library +; TODO figure out if I can put this into the standard library and still have it be accessable for others + +imageSearchc( byRef out1 , byRef out2 , options ){ + + from = options.from + to = options.to + + Ax = from[0] + Ay = from[1] + + Bx = to[0] + By = to[1] + + static ptok := gdip_startup() + + fileMap := gdip_createBitmapFromFile(options.image) + screenMap := gdip_bitmapfromscreen( Ax "|" Ay "|" Bx - Ax "|" By - Ay ) + + if(options.debug) + gdip_saveBitmapToFile(screenMap,a_now ".png") + + error := gdip_imageSearch( screenMap + , fileMap + , tempxy + , 0 , 0 , 0 , 0 + , options.vari || 0 + , options.trans || "" + , options.direction || 5 ) + + gdip_disposeImage(screenMap) + gdip_disposeImage(fileMap) + + if(error){ + out := strSplit( tempxy , "`," ) + out1 := out[1] + Ax + out2 := out[2] + Ay + return % error + } + + return 0 +} diff --git a/Scripts/Sai/SaiToolkit.ahk b/Scripts/Libraries/Sai.ahk similarity index 71% rename from Scripts/Sai/SaiToolkit.ahk rename to Scripts/Libraries/Sai.ahk index 955ca1c..50b018c 100644 --- a/Scripts/Sai/SaiToolkit.ahk +++ b/Scripts/Libraries/Sai.ahk @@ -3,8 +3,11 @@ #SingleInstance Force -CoordMode, Mouse, Screen -CoordMode, Pixel, Screen +#Include %A_LineFile%\..\Gdip.ahk +#Include %A_LineFile%\..\Gdip_ImageSearch.ahk + +CoordMode , Mouse , Screen +CoordMode , Pixel , Screen ; Define globals @@ -80,7 +83,7 @@ exportCurrent( fileName := "" ){ WinGetTitle , title , Confirm - if(title == "Confirm Save As"){ + if(title = "Confirm Save As"){ pressButton("Tab") @@ -181,44 +184,3 @@ pressButton( button ){ goUpLayer(){ pressButton(forwardLayerKey) } - - -; https://github.com/Masonjar13/AHK-Library -; TODO figure out if I can put this into the standard library and still have it be accessable for others - -imageSearchc( - byRef out1 , byRef out2 , - Ax , Ay , Bx , By , - image , - vari := 0 , - trans := "" , - direction := 5 , - debug := 0 -){ - - static ptok := gdip_startup() - - fileMap := gdip_createBitmapFromFile(image) - screenMap := gdip_bitmapfromscreen( Ax "|" Ay "|" Bx - Ax "|" By - Ay ) - - if(debug) - gdip_saveBitmapToFile(screenMap,a_now ".png") - - error := gdip_imageSearch( - screenMap , fileMap , tempxy , - 0 , 0 , 0 , 0 , vari , trans , - direction - ) - - gdip_disposeImage(screenMap) - gdip_disposeImage(fileMap) - - if(error){ - out := strSplit(tempxy,"`,") - out1 := out[1] + Ax - out2 := out[2] + Ay - return % error - } - - return 0 -} diff --git a/Scripts/Sai/Animate Playback.ahk b/Scripts/Sai/Animate Playback.ahk index d78ef9c..22bec5f 100644 --- a/Scripts/Sai/Animate Playback.ahk +++ b/Scripts/Sai/Animate Playback.ahk @@ -91,7 +91,7 @@ resetToBottom(numberOfFrames){ ;Send, { Numpad5 Up } } - Send , {Numpad5 Up} + Send , { Numpad5 Up } ShowOnlyCurrentLayer() } @@ -119,12 +119,21 @@ shiftUp(){ } RandSleep( x , y ){ - Random , rand , %x% , %y% + + Random + , rand + , %x% + , %y% + Sleep %rand% } GetFrameNumber(){ - InputBox , numberOfFrames, Number of Frames, Enter number of frames., , 150, 150 + InputBox + , numberOfFrames + , Number of Frames + , Enter number of frames. , + , 150, 150 } Esc:: @@ -139,11 +148,11 @@ Esc:: `:: if(!isPlaying){ BreakLoop := 0 - DoLoop(numberOfFrames,FPSsleepTime) + DoLoop( numberOfFrames , FPSsleepTime ) } else { BreakLoop := 1 } - isPlaying := !isPlaying + isPlaying := ! isPlaying return diff --git a/Scripts/Sai/Do Gray Tone.ahk b/Scripts/Sai/Do Gray Tone.ahk index 3e73f8f..6d2e3e4 100644 --- a/Scripts/Sai/Do Gray Tone.ahk +++ b/Scripts/Sai/Do Gray Tone.ahk @@ -1,4 +1,5 @@ +; ; Pre-select areas to NOT shade ; Invert selection ; Contract @@ -8,12 +9,13 @@ ; Change opacity to like 25% ; Add blush layer ; Add hilight layer +; -#Include ./SaiToolkit.ahk -#Include ./Gdip.ahk -#Include ./Gdip_ImageSearch.ahk +#Include ..\Libraries\Sai.ahk +#Include ..\Libraries\ImageSearch.ahk -coordMode , pixel +coordMode + , pixel focusSai() @@ -27,13 +29,16 @@ newLayer() renameLayer("Gray") fillLayer() -imageSearchc( - fx , fy , 0 , 0 , - a_screenWidth , a_screenHeight , - "..\..\Resources\OpacitySlider.png" -) +options := { image : "../../Resources/OpacitySlider.png" + , from : [ 0 , 0 ] + , to : [ a_screenWidth , a_screenHeight ] } -MouseClick , left , fx + 110 , fy + 20 +imageSearchc( fx , fy , options ) + +MouseClick + , left + , fx + 110 + , fy + 20 newLayer() renameLayer("Blush") diff --git a/Scripts/Sai/Layer Chain Renamer.ahk b/Scripts/Sai/Layer Chain Renamer.ahk index a42e7f6..1a09576 100644 --- a/Scripts/Sai/Layer Chain Renamer.ahk +++ b/Scripts/Sai/Layer Chain Renamer.ahk @@ -7,7 +7,8 @@ ; -#Include ./SaiToolkit.ahk +#Include ..\Libraries\Sai.ahk + previousLayerName := "" baseLayerName := "Frame" @@ -16,7 +17,11 @@ newLayerName := "" topLayerHit := false counter := 1 -InputBox , baseLayerName , Enter Name , Enter layer base name (result will be "Basename-#"): , , 300 , 150 +InputBox + , baseLayerName + , Enter Name + , Enter layer base name (result will be "Basename-#"): , + , 300 , 150 focusSai() diff --git a/Scripts/Sai/Layer Exporter.ahk b/Scripts/Sai/Layer Exporter.ahk index c1053e5..91879c9 100644 --- a/Scripts/Sai/Layer Exporter.ahk +++ b/Scripts/Sai/Layer Exporter.ahk @@ -9,7 +9,8 @@ ; -#Include ./SaiToolkit.ahk +#Include ..\Libraries\Sai.ahk + previousLayerName := "" baseLayerName := "Frame-" diff --git a/Scripts/Steam/Remove All Markets.ahk b/Scripts/Steam/Remove All Markets.ahk index 25ed7ed..a9d942a 100644 --- a/Scripts/Steam/Remove All Markets.ahk +++ b/Scripts/Steam/Remove All Markets.ahk @@ -4,7 +4,8 @@ ; -#Include .\RunescapeToolkit.ahk +#Include ..\Libraries\Runescape.ahk + Loop { Loop { From fc7afaf74ac7d4fb68664c9c545fe242cd4dbb70 Mon Sep 17 00:00:00 2001 From: ElectronicsArchiver <85485984+ElectronicsArchiver@users.noreply.github.com> Date: Sun, 11 Sep 2022 23:01:13 -0400 Subject: [PATCH 13/13] Added README --- README.md | 81 ++++++++++++++++++++++++++++++++++++ Scripts/Sai/Do Gray Tone.ahk | 2 +- 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..de9ad21 --- /dev/null +++ b/README.md @@ -0,0 +1,81 @@ + +
+ +
+ +# AutoHotKey
Scripts + +*My personal AHK scripts.* + +
+ +
+
+ +## Sai + +
+ +- [`Animate Playback.ahk`][Animate Playback] + + *Loops layer by layer as if it was animated.* + +
+ +- [`Layer Chain Renamer.ahk`][Layer Chain Renamer] + + *Rename multiple layers going up from the current layer.* + +
+ +- [`Layer Exporter.ahk`][Layer Exporter] + + *Exports multiple layers going up from the current layer.* + +
+ +- [`Do Gray Tone.ahk`][Do Gray Tone] + + 1. *Pre-select areas to NOT shade* + 2. *Invert selection* + 3. *Contract* + 4. *Add folder* + 5. *Add shade layer* + 6. *Fill with black* + 7. *Change opacity to like 25%* + 8. *Add blush layer* + 9. *Add highlight layer* + +
+
+ +## Discord + +
+ +- [`Message Purger.ahk`][Message Purger] + + *Removes all message from a user without banning them.* + +
+
+ +## Steam + +
+ +- [`Remove All Markets.ahk`][Remove All Markets] + + *Removes all market listings.* + +
+ + + + +[Layer Chain Renamer]: Scripts/Sai/Layer%20Chain%20Renamer.ahk +[Remove All Markets]: Scripts/Discord/Remove%20All%20Markets.ahk +[Animate Playback]: Scripts/Sai/Animate%20Playback.ahk +[Message Purger]: Scripts/Discord/Message%20Purger.ahk +[Layer Exporter]: Scripts/Sai/Layer%20Exporter.ahk +[Do Gray Tone]: Scripts/Sai/Do%20Gray%20Tone.ahk diff --git a/Scripts/Sai/Do Gray Tone.ahk b/Scripts/Sai/Do Gray Tone.ahk index 6d2e3e4..6afcfb2 100644 --- a/Scripts/Sai/Do Gray Tone.ahk +++ b/Scripts/Sai/Do Gray Tone.ahk @@ -8,7 +8,7 @@ ; Fill with black ; Change opacity to like 25% ; Add blush layer -; Add hilight layer +; Add highlight layer ; #Include ..\Libraries\Sai.ahk