damian25 Posted September 21, 2018 Share Posted September 21, 2018 Hello, im looking for script which would change pixel per cm to inch. the most common ones files are prepared pix/inch but sometimes they are pix/cm. I have shortcut for f11 which open for me "image size window" >>> https://imgur.com/a/jk2cjft ,and i want while i press f11 or window image size is opening script change pix cm to cal if it's required. Is that possible? I know that after i change pixel cm to cal size of image will change but it should be done(i mean work of script) before i drop there required dpi. I only work with dpi, so i want to be sure before i enter dpi that there is pixel per inch. Script could be open himself by switching on photoshop, and should refresh after windows size has been opened few times if pixel is per inch. I will grateful if u could help me, this will help me a lot of in my work. Thanks and have a nice day Link to comment Share on other sites More sharing options...
Subz Posted September 21, 2018 Share Posted September 21, 2018 You should be able to modify the following to suit your needs, it works for me with Photoshop CC latest release. HotKeySet("{ESC}", "Close") HotKeySet("{F11}", "ImageSize") While 1 Sleep(100) WEnd Func ImageSize() WinActivate("[CLASS:Photoshop]", "") Send("!^i") WinWaitActive("Image Size") ControlSend("Image Size", "", "[CLASS:ComboBox; INSTANCE:4]", "{UP}") ControlClick("Image Size", "", "[CLASS:Button; INSTANCE:2]") EndFunc Func Close() Exit EndFunc Link to comment Share on other sites More sharing options...
damian25 Posted September 24, 2018 Author Share Posted September 24, 2018 Hello Subz, i tried script, and something dont work. I mean if im in PS and i press f11 nothing happen(even image size window doesnt open) . if i manualy open image size still nothing change Link to comment Share on other sites More sharing options...
Subz Posted September 24, 2018 Share Posted September 24, 2018 Using the AutoIt3 Window Info tool, included with the AutoIt installation, check the class names, window names are correct, looking at the image you posted it appears to be in Polish, so you will need to update the code with translated text, but as mentioned use the AutoIt3 Window Tool to get the correct information. Link to comment Share on other sites More sharing options...
damian25 Posted September 24, 2018 Author Share Posted September 24, 2018 (edited) i had set f11 on hotkey in photoshop to open image size windows, is it possible to be reason? I change image size name to polish ofc, i tried change hotkeyset but doesnt work too. I work with full adobe set , and have to log before use photoshop, maybe there is reason. what exactly do: Send("!^i") maybe u have idea how change code to work ? i tried windwaitactive class but too didnt work #edit error: Rozmiar obrazu(): undefined function. it appear now Edited September 24, 2018 by damian25 Link to comment Share on other sites More sharing options...
damian25 Posted September 24, 2018 Author Share Posted September 24, 2018 OK, i change some row and work , i have to hold image size windows open after pixel change to cal and set my own dpi set, but if i set in script hotkeyset to f11 and i have in photoshop f11 doesnt open imagesize windows. How change it if i want open by f11 image size and then should automaticly change cm to cal like now Link to comment Share on other sites More sharing options...
damian25 Posted September 24, 2018 Author Share Posted September 24, 2018 Spoiler HotKeySet("{ESC}", "Close") HotKeySet("{F2}", "Rozmiarobrazu") While 1 Sleep(10) WEnd Func Rozmiarobrazu() WinActivate("[CLASS:Photoshop]", "") Send("!^i") WinWaitActive("Rozmiar obrazu") ControlSend("Rozmiar obrazu", "", "[CLASS:ComboBox; INSTANCE:4]", "{UP}") EndFunc Func Close() Exit EndFunc Now if i open manually imagesize and before press f2 it change cm to cal, but if not nothing happen, also if i set hotkeyset f11 and clear shortcut in Photoshop work same, if i press f11 before open imagesize work, but i want it works like i press f11 then open imagesize and if pixel per cm change cal Link to comment Share on other sites More sharing options...
Subz Posted September 24, 2018 Share Posted September 24, 2018 Please post screenshot of Autoit Window Info: a. Photoshop Window (without Image Size open) b. Photoshop Window (with Image Size open) Link to comment Share on other sites More sharing options...
damian25 Posted September 24, 2018 Author Share Posted September 24, 2018 https://paste.ofcode.org/36YsQSxnahNbUxAc7kSSySc IF i write like that script change even when i reopen imagesize but only when i manually open that, I want it like . I press f11(hotkey set in photoshop) then image size is opened then pixel per cm if exhist> cal https://imgur.com/a/yPdZqkL Link to comment Share on other sites More sharing options...
Subz Posted September 24, 2018 Share Posted September 24, 2018 You didn't post the AutoIt Window Info Tool information See example below, first Window is for Photoshop without Image Size Window Open the second screenshot is using the "Finder Tool" to select the "Pixels/Inch" (in my version of Photoshop. Please post your screenshots, please select the Window tab for the first screenshot and the "Control" tab for the second screenshot. Xandy 1 Link to comment Share on other sites More sharing options...
damian25 Posted September 24, 2018 Author Share Posted September 24, 2018 (edited) https://imgur.com/a/8GlReQF i ADD WHILE IN FUNC like above i linked and everytime i open manually imagesize it changes setting but if i press f11 image size windows doesnt open(https://imgur.com/a/uxy5wBS <<< i have hot in photoshop f11 to open image size) Edited September 24, 2018 by damian25 Link to comment Share on other sites More sharing options...
Subz Posted September 24, 2018 Share Posted September 24, 2018 Everything looks correct, what is the shortcut for Image Size... you'll notice that mine is Alt + Ctrl + i (see screenshot below), maybe your shortcut is different? I'm not sure if you were using F11 from within Photoshop or from the AutoIt script. If you set it to F11 within Photoshop you will need to change the send key to Send("{F11}"). Link to comment Share on other sites More sharing options...
damian25 Posted September 24, 2018 Author Share Posted September 24, 2018 (edited) YE I HAVE different shorcut. I want check ur script that should automaticly change pixel per cm to cal just if image size windows is opened AND THEN my shortcut by photoshop will not conflict with scirpt f11 Edited September 24, 2018 by damian25 Link to comment Share on other sites More sharing options...
damian25 Posted September 24, 2018 Author Share Posted September 24, 2018 (edited) I mean i just want set with system startup script and it should works IN LOOP until system is shuted down. And what Send("!^i") call Edited September 24, 2018 by damian25 Link to comment Share on other sites More sharing options...
Subz Posted September 24, 2018 Share Posted September 24, 2018 You can use something like the following, if you open Image Size it will change the setting once only and then wait for the Window to close, if you open another image and Image Size window it will modify that once, you only want to do it once otherwise it uses up a lot of resources and would stop you from modifying other settings. HotKeySet("{ESC}", "Close") While 1 If WinActive("Image Size", "") Then ImageSize() WinWaitClose("Image Size", "") EndIf Sleep(250) WEnd Func ImageSize() WinActivate("Image Size", "") WinWaitActive("Image Size", "") ControlSend("Image Size", "", "[CLASS:ComboBox; INSTANCE:4]", "{UP}") EndFunc Func Close() Exit EndFunc Link to comment Share on other sites More sharing options...
damian25 Posted September 24, 2018 Author Share Posted September 24, 2018 U are awesome bro. It work. Should i add winactive class for photoshop? IS possible script launch always if photoshop start work? And how can i choose from combobox (few options, last , i mean if i change picture to cmyk and i have to save to .tiff ,he is always last) Link to comment Share on other sites More sharing options...
damian25 Posted September 25, 2018 Author Share Posted September 25, 2018 (edited) Quote expandcollapse popup#include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #NoTrayIcon HotKeySet("{esc}", "_Pause") $hGui = GUICreate("macro", 300, 80) $hPause = GUICtrlCreateButton("wlaczone", 120, 24, 60) GUISetState() Global $Counter = 0 ; Not needed, just for demonstration purpose. While 3 ;Your code starts in this main loop ; Note that the below is just to show script is running, and might look odd due to nature of msg loop. $Counter += 1 If $Counter >= 300 Then ConsoleWrite("Running" & @LF) $Counter = 0 EndIf Switch GUIGetMsg() Case -3 ; $GUI_EVENT_CLOSE Exit Case $hPause ; Pause button ConsoleWrite("!Pause" & @LF) _Pause() EndSwitch If WinActive("Rozmiar obrazu", "") Then ImageSize() WinWaitClose("Rozmiar obrazu", "") Sleep(250) EndIf If WinActivate("Zapisywanie jako", "") Then zapis() WinWaitClose("Zapisywanie jako", "") sleep(500) EndIf WEnd Func ImageSize() WinActivate("Rozmiar obrazu", "") WinWaitActive("Rozmiar obrazu", "") ControlSend("Rozmiar obrazu", "", "[CLASS:ComboBox; INSTANCE:4]", "{UP}") EndFunc Func zapis() WinActivate("Zapisywanie jako", "") ControlClick("Zapisywanie jako", "","[CLASS:ComboBox; INSTANCE:2]") ControlSend("Zapisywanie jako", "", "[CLASS:ComboBox; INSTANCE:2]", "{DOWN 12}") ControlSend("Zapisywanie jako", "", "[CLASS:ComboBox; INSTANCE:2]", "{ENTER}") EndFunc Func _Pause() GUICtrlSetData($hPause, "wylaczone") While 3 Switch GUIGetMsg() Case -3 ; $GUI_EVENT_CLOSE need to be able to exit while paused. Exit Case $hPause ; Pause button ExitLoop EndSwitch WEnd GUICtrlSetData($hPause, "wlaczone") ConsoleWrite("+wylaczone" & @LF) EndFunc ;==>_Pause I add to script button which turn on/off script but i problem is cuz i can only turn off by esc script, and if i want reuse esc i want script resume but have no idea how. Also i would like send program to tray and keep it since he starts(i will put to startup folder it because i want it works for all time pc works). But if i would like back from tray "for second" should it back and after minimalize again gone to tray. Edited September 25, 2018 by damian25 Link to comment Share on other sites More sharing options...
Subz Posted September 25, 2018 Share Posted September 25, 2018 You can change HotKeySet to anything it doesn't have to be {ESC} look at Send in the helpfile for different keys. Here is an example using System Tray Icon or F4 to Toggle the Script On and Off. expandcollapse popup#NoTrayIcon Opt("TrayMenuMode", 3) Opt("TrayOnEventMode", 1) HotKeySet("{F4}", "ToggleScript") Global $idToggle, $idExit Global $bUpdated = False, $bToggle = "Na" Example() Func Example() $idToggle = TrayCreateItem("Toggle - " & $bToggle) TrayItemSetOnEvent($idToggle, "ToggleScript") TrayCreateItem("") $idExit = TrayCreateItem("Exit") TrayItemSetOnEvent($idExit, "CloseScript") TraySetState() While 1 If $bToggle = "Na" Then If WinActive("Rozmiar obrazu", "") Then ImageSize() WinWaitClose("Rozmiar obrazu", "") ElseIf WinActivate("Zapisywanie jako", "") Then zapis() WinWaitClose("Zapisywanie jako", "") EndIf EndIf Sleep(100) WEnd EndFunc Func ToggleScript() If $bToggle = "Na" And TrayItemGetText($idToggle) = "Toggle - Na" Then $bToggle = "wlaczone" TrayItemSetText($idToggle, "Toggle - " & $bToggle) TrayTip("Photoshop Script", $bToggle, 1) ElseIf $bToggle = "wlaczone" And TrayItemGetText($idToggle) = "Toggle - wlaczone" Then $bToggle = "Na" TrayItemSetText($idToggle, "Toggle - " & $bToggle) TrayTip("Photoshop Script", $bToggle, 2) EndIf EndFunc Func CloseScript() Exit EndFunc Func ImageSize() WinActivate("Rozmiar obrazu", "") WinWaitActive("Rozmiar obrazu", "") ControlSend("Rozmiar obrazu", "", "[CLASS:ComboBox; INSTANCE:4]", "{UP}") EndFunc Func zapis() WinActivate("Zapisywanie jako", "") ControlClick("Zapisywanie jako", "","[CLASS:ComboBox; INSTANCE:2]") ControlSend("Zapisywanie jako", "", "[CLASS:ComboBox; INSTANCE:2]", "{DOWN 12}") ControlSend("Zapisywanie jako", "", "[CLASS:ComboBox; INSTANCE:2]", "{ENTER}") EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now