Jump to content

_PathSplit without the backslashes II


 Share

Recommended Posts

As a sequel to my previous thread "_PathSplit without the backslashes" My link

When I run this

Send("(" & $sNewDir_1 & ", " & $szFName & ", \1, '")

in a While loop, sending the characters to Notepad++'s Replace "Find what" box

the first round comes out OK--with any file--and I get sth like:

(40, 9, 1, '
(40, 9, 2, '
(40, 9, 3, '

which is as desired.

However, with the next file/tab (for I have about a dozen txt files open),

the values/characters ($szFName) sent, are obviously supposed to change, say

(40, 8, 1, '

but, the same '9' comes again. Same thing with the rest. So, even where it's supposed to be

(40, 7, 1, '

(40, 6, 1, '

(40, 5, 1, '

only

(40, 9, 1, '

which is the first string used in the operation, gets sent.

The only solution I can think of is inserting Sleep() here and there!

Link to comment
Share on other sites

  • Moderators

bahtea,

Well the error is obvious - it is in Line 45623498537! My crystal ball says so! ;)

M23

P.S. If you do not post any code - how are we supposed to help. :)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

If you horrible guys insist on looking at a mendicant's patchwork, here we go ;)

...Dims...
WinActivate("[CLASS:Notepad++]", "")
$fPath = WinGetTitle("[CLASS:Notepad++]", "")
_PathSplit($fPath, $szDrive, $szDir, $szFName, $szExt)
$sNewDir_1 = StringtrimRight(StringTrimLeft($szDir, 14), 1)

While WinActive($WindowTitle)
    Send("^{HOME}")
    ;launch Replace Dialog
    Send("^h")
    ;Set RegEx
    Send("!g")
    ;Activate "Find" box
    Send("!f")
    Send("{DEL}")
    Sleep(500)
    ;Search for this regex
    Send("{^}(\d{+}) ")
    Sleep(500)
    ;Now, the "Replace with" field
    Send("!l")
    Sleep(500)
    ;Give Windows GUI a chance
    Send("{DEL}")   
    ;A! Windows is a slowpoke, eh?
    Sleep(500)
    ;Here's the replacement:
    Send("(" & $sNewDir_1 & ", " & $szFName & ", \1, '") ;<--THE PROBLEMATIC LINE
    Sleep(500)
    ;Replace All
    Send("!a")
    Sleep(500)
    ;Close the OK Dialog box
    Send("{ESC}")
    ;Sleep(500)
    ;Close the Replace dialog box
    Send("{ESC}")
    ;Sleep(500)
    Send("!x")
    Sleep(500)
    Send("!n") ;'cause I'm experimenting
    Sleep(500)
WEnd

Exit

And...that was the story of The Sleeps!

Edited by bahtea
Link to comment
Share on other sites

  • Moderators

bahtea,

the values/characters ($szFName) sent, are obviously supposed to change, say

So where in that bit of script you posted do you change the value of $szFName? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I do not change the value of $szFName myself;

it is supposed to change eventually when the script acts on the next file.

But that changed value does not get reflected on that next run of this line

Send("(" & $sNewDir_1 & ", " & $szFName & ", \1, '")
Edited by bahtea
Link to comment
Share on other sites

  • Moderators

bahtea,

I presume you use this:

$fPath = WinGetTitle("[CLASS:Notepad++]", "")
_PathSplit($fPath, $szDrive, $szDir, $szFName, $szExt)

to get the title of the currently active file from the window title. :)

How is the script supposed to run through the various tabs that you have open so that it knows what the other files are? Somewhere in your script you have to change the active tab in your editor so that the new file name is in the title - then you can use that to reset the path variables by using WinGetTitle & _PathSplit again. You currently only do this once. ;)

Either you have more code than that to show or you are expecting AutoIt to read your mind as to what you want it to do rather than do what you tell it to do. Guess what AutoIt actually does! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

M23! Very good advice given that was. I re-ordered the lines thus:

While WinActive($WindowTitle)
    $fPath = WinGetTitle("[CLASS:Notepad++]", "")
    _PathSplit($fPath, $szDrive, $szDir, $szFName, $szExt)
    $sNewDir_1 = StringtrimRight(StringTrimLeft($szDir, 14), 1)
    ;Place cursor at the beginning of the page
    Send("^{HOME}")
Now the code runs smooth. You're a charm!

Big thanks all the way!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...