• Login
Community
  • Login

Increase/Decrease All Highlighted x or y Coordinates

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 3 Posters 2.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    MusoCity
    last edited by Mar 27, 2018, 1:08 AM

    I need to shift a lot of buttons at a the same time without having to increase/decrease the x or y coordinates manually one at a time.
    I can use Alt to select a column, just need some way to +/- the value.
    Like pressing + or - key, x=x+1 x=x-1

    Gui, Add, Button, x22 y150 w90 h20 , Button 1
    Gui, Add, Button, x22 y170 w90 h20 , Button 2
    Gui, Add, Button, x22 y190 w90 h20 , Button 3
    Gui, Add, Button, x22 y210 w90 h20 , Button 4
    Gui, Add, Button, x22 y230 w90 h20 , Button 5
    Gui, Add, Button, x22 y250 w90 h20 , Button 6
    Gui, Add, Button, x22 y270 w90 h20 , Button 7
    Gui, Add, Button, x22 y290 w90 h20 , Button 8
    Gui, Add, Button, x22 y310 w90 h20 , Button 9
    Gui, Add, Button, x22 y330 w90 h20 , Button 10
    Gui, Add, Button, x22 y350 w90 h20 , Button 11
    Gui, Add, Button, x22 y370 w90 h20 , Button 12
    Gui, Add, Button, x22 y390 w90 h20 , Button 13
    Gui, Add, Button, x22 y410 w90 h20 , Button 14
    Gui, Add, Button, x22 y430 w90 h20 , Button 15
    Gui, Add, Button, x22 y450 w90 h20 , Button

    1 Reply Last reply Reply Quote 0
    • P
      PeterJones
      last edited by Mar 27, 2018, 1:21 PM

      If that were my task, and it was going to be a one-time thing, I would column-select (click on upper left of the box, alt+drag to lower right), copy, and paste into a spreadsheet; add +n using spreadsheet; copy the column from spreadsheet. Unfortunately, when you copy a column from Excel, it includes the EOL characters, so if you try to column-paste back into NPP, it doesn’t do what you want. Instead, open a new tab in NPP, paste, column-select that new data, and column-paste (column-highlight the same column you originally copied, and paste over it).

      If it were something I was going to do a lot, the back-and-forth from Notepad++ to spreadsheet would start annoying me, so I’d figure out how to do it in a scripting language. I would use code based on this pseudo-code outline:

      prompt user: "which column (x, y, w, h)?" => col
      prompt user: "+1 or -1" => delta
      for each line of FILE
          search the line for "{col}###"
          var = value(###) + delta
          replace "{col}###" with "{col}{var}"
      next line
      

      In general, I would use a convenient standalone language (probably Perl). But if I was also going to be doing other edits/experiments, so I wanted to keep the file “live” in NPP, I would fire up my PythonScript plugin and hack the script there (making copious use of Python help sites for looking up the syntax, since I’m not fluent in Python). If I had more time this morning, I’d probably provide you with the script-writing service. Maybe @Claudia-Frank has more time today than I do (hmm, maybe not… she hasn’t logged on in almost a week! If I find time later, and no one else has stepped up, maybe I’ll give it a go.

      C 1 Reply Last reply Mar 27, 2018, 1:35 PM Reply Quote 2
      • C
        Claudia Frank @PeterJones
        last edited by Mar 27, 2018, 1:35 PM

        @PeterJones

        sorry, currently not - still working on the python script x64 port
        and want to get this finished first ;-)

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 0
        • P
          PeterJones
          last edited by Mar 30, 2018, 3:15 PM

          Sorry, it took me a while to find the time to work on this

          You need PythonScript and 32bit Notepad++ for this to work. You can download PythonScript here

          # https://notepad-plus-plus.org/community/topic/15485/increase-decrease-all-highlighted-x-or-y-coordinates
          # Will prompt for which column (allows x, y, w, h) and how much to add or subtract (requires a number)
          # Will then do the search/replace over the whole file
          DEBUG = False
          
          def delt_1(m):
              global addend
              this = m.group(1)
          
              if DEBUG:
                  console.write("matched '")
                  console.write(this)
                  console.write("'\t")
          
              r = str(addend + int(this))
          
              if DEBUG:
                  console.write("return: '" + r + "'")
                  console.write("\n")
          
              return r
          
          ####################################################
          
          if DEBUG: console.show()
          if DEBUG: console.clear()
          column = None
          while column != "x" and column != "y" and column != "w" and column != "h":
              column = notepad.prompt("Which column [x y w h]?", "Choose column", "y")
          
          addend = None
          while addend == None:
              direction = notepad.prompt("Number to add (negative for subtraction)", "Choose delta", "1")
              try:
                  addend = int( direction )
              except:
                  addend = None
          
          if DEBUG:
              console.write("column: " + column + "\n")
              console.write("addend: " + str(addend) + "\n")
          
          pattern = "((?<=\s{0})\\d+)".format( column )
          if DEBUG: console.writeError(pattern + "\n")
          editor.beginUndoAction()
          editor.rereplace(pattern , delt_1)
          editor.endUndoAction()
          
          1 Reply Last reply Reply Quote 1
          3 out of 4
          • First post
            3/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors