Jump to content
Sign in to follow this  
grimmlock

Array pipe character used for next line

Recommended Posts

grimmlock

I am making an app that will allow the migration of users from one server to another (while changing permissions) easier for anyone and everyone. Below is my code, what I can't seem to figure out is what I am missing in my code so that the _uArray() reads the folder names in the destination folder and then uses them to set some of the permissions settings.

Right now the array pulls the data just fine, but either puts a "|" between the names (which I understand is "normal") or it removes the "|" and puts the folder names together in one long string, which is why I used StringSplit() only now it does not display anything at all.

If anyone has time, would it be possible for someone to look at this and help me solve this issue. I think it would a great app that anyone can use that, like me, needs to migrate users across domains or servers. Thank you in advance.

 
#include <GUIConstantsEx.au3>
#include <AutoItConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <MsgBoxConstants.au3>
#include <Constants.au3>
#include <FileConstants.au3>
#include <ButtonConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <StringConstants.au3>

Global $set = 3

;==========================Main GUI===========================
$hGUI = GUICreate("Complex-Permissions", 250, 350)
;=============================================================

;==========================Inputs=============================
$hOld = GUICtrlCreateInput("", 95, 25, 130)
$hNew = GUICtrlCreateInput("", 95, 50, 130)
$hOldSvr1 = GUICtrlCreateInput("", 95, 75, 25)
GUICtrlSetLimit(-1, $set)
$hOldSvr2 = GUICtrlCreateInput("", 130, 75, 25)
GUICtrlSetLimit(-1, $set)
$hOldSvr3 = GUICtrlCreateInput("", 165, 75, 25)
GUICtrlSetLimit(-1, $set)
$hOldSvr4 = GUICtrlCreateInput("", 200, 75, 25)
GUICtrlSetLimit(-1, $set)
$hNewSvr1 = GUICtrlCreateInput("", 95, 100, 25)
GUICtrlSetLimit(-1, $set)
$hNewSvr2 = GUICtrlCreateInput("", 130, 100, 25)
GUICtrlSetLimit(-1, $set)
$hNewSvr3 = GUICtrlCreateInput("", 165, 100, 25)
GUICtrlSetLimit(-1, $set)
$hNewSvr4 = GUICtrlCreateInput("", 200, 100, 25)
GUICtrlSetLimit(-1, $set)
$hLetter = GUICtrlCreateInput("", 95, 125, 130)
$hShare = GUICtrlCreateInput("", 95, 150, 130)
$hLocal = GUICtrlCreateInput("", 95, 175, 130)
$hFolder = GUICtrlCreateInput("", 95, 200, 130)
$hUID = GUICtrlCreateInput("", 95, 225, 130)
$hExclude = GUICtrlCreateInput("", 95, 250, 130)
;=============================================================

;==========================Buttons============================
$hButton1 = GUICtrlCreateButton("Test", 25, 285, 50)
;~ GUICtrlSetState(-1, $GUI_HIDE)
$hButton2 = GUICtrlCreateButton("Migrate Data / " & @CRLF & "Change Permissions", 100, 285, 120, 50, $BS_MULTILINE)
;=============================================================

;==========================Labels=============================
$hLabel1 = GUICtrlCreateLabel("Old Domain", 10, 28)
$hLabel2 = GUICtrlCreateLabel("New Domain", 10, 53)
$hLabel3 = GUICtrlCreateLabel("Old Server (IP)", 10, 78)
$hLabel4 = GUICtrlCreateLabel("New Server (IP)", 10, 103)
$hLabel5 = GUICtrlCreateLabel("Drive Letter", 10, 128)
$hLabel5 = GUICtrlCreateLabel("Share Folder", 10, 153)
$hLabel6 = GUICtrlCreateLabel("Local Folder", 10, 178)
$hLabel7 = GUICtrlCreateLabel("Folder Name", 10, 203)
$hLabel8 = GUICtrlCreateLabel("User Name", 10, 228)
$hLabel9 = GUICtrlCreateLabel("Exclusions", 10, 253)
;=============================================================

GUISetState(@SW_SHOW, $hGUI)

While 1
    Switch GUIGetMSG()
        Case $GUI_EVENT_CLOSE
            ExitLoop


        Case $hButton1
            _uArray()

        Case $hButton2
;~             _NetUse()
;~             _RoboCopy()
            _Perm()

    EndSwitch

WEnd



;=============================================================
;~                     Functions
;=============================================================

Func _NetUse()
    RunWait(@ComSpec & " /c " & "net use \\" & GUICtrlRead($hOldSvr1) & "." & GUICtrlRead($hOldSvr2) & "." & GUICtrlRead($hOldSvr3) & "." & GUICtrlRead($hOldSvr4) & "\c$ /user:" & GUICtrlRead($hOld) & "\axeontech", "", @SW_HIDE)
    RunWait(@ComSpec & " /c " & "net use \\" & GUICtrlRead($hOldSvr1) & "." & GUICtrlRead($hOldSvr2) & "." & GUICtrlRead($hOldSvr3) & "." & GUICtrlRead($hOldSvr4) & "\Admin$ /user:" & GUICtrlRead($hOld) & "\axeontech", "", @SW_HIDE)
    Sleep(2000)
EndFunc    ;= _NetUse


Func _RoboCopy()
    If GUICtrlRead($hExclude) <> "" then
        RunWait(@ComSpec & " /k " & "robocopy /B \\" & GUICtrlRead($hOldSvr1) & "." & GUICtrlRead($hOldSvr2) & "." & GUICtrlRead($hOldSvr3) & "." & GUICtrlRead($hOldSvr4) & "\" & GUICtrlRead($hShare) & "\" & GUICtrlRead($hFolder) & " \\" & GUICtrlRead($hNewSvr1) & "." & GUICtrlRead($hNewSvr2) & "." & GUICtrlRead($hNewSvr3) & "." & GUICtrlRead($hNewSvr4) & "\" & GUICtrlRead($hShare) & "\" & GUICtrlRead($hFolder) & " /E /mir /XD " & GUICtrlRead($hFolder) & "\" & GUICtrlRead($hExclude) & "/w:0 /r:0 /log:c:\users\" & @UserName & "\desktop\migrate_profiles.txt", "", @SW_SHOW)
        MsgBox(0, "", "RoboCopy w/ Exceptions: Complete")
    Else
        RunWait(@ComSpec & " /k " & "robocopy /B \\" & GUICtrlRead($hOldSvr1) & "." & GUICtrlRead($hOldSvr2) & "." & GUICtrlRead($hOldSvr3) & "." & GUICtrlRead($hOldSvr4) & "\" & GUICtrlRead($hShare) & "\" & GUICtrlRead($hFolder) & " \\" & GUICtrlRead($hNewSvr1) & "." & GUICtrlRead($hNewSvr2) & "." & GUICtrlRead($hNewSvr3) & "." & GUICtrlRead($hNewSvr4) & "\" & GUICtrlRead($hShare) & "\" & GUICtrlRead($hFolder) & " /E /mir /w:0 /r:0 /log:c:\users\" & @UserName & "\desktop\migrate_profiles.txt", "", @SW_SHOW)
        MsgBox(0, "", "RoboCopy w/o Exceptions: Complete")
    EndIf

;~     Sleep(2000)
EndFunc    ;= _RoboCopy


Func _Perm()
;~     If GUICtrlRead($hLocal) = "" then
;~         GUICtrlSetData($hLocal, GUICtrlRead($hShare))
;~     EndIf

    Local $hFileOpen = FileOpen("c:\users\" & @UserName & "\desktop\log.txt", $FO_APPEND)

        Local $iPID = Run(@ComSpec & " /c " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hLocal) & "&&TAKEOWN /f " & GUICtrlRead($hFolder) & " /r /d y", "", @SW_HIDE, $STDERR_MERGED)
            ProcessWaitClose($iPID)
            Local $sOutput = StdoutRead($iPID)
            FileWrite($hFileOpen, $sOutput)
;~         Sleep(1000)
        Local $iPID1 = Run(@ComSpec & " /c " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hLocal) & "&&icacls " & GUICtrlRead($hFolder) & " /reset /T", "", @SW_HIDE, $STDERR_MERGED)
            ProcessWaitClose($iPID1)
            Local $sOutput = StdoutRead($iPID1)
            FileWrite($hFileOpen, $sOutput)
        Local $iPID2 = Run(@ComSpec & " /c " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hLocal) & "&&icacls " & GUICtrlRead($hFolder) & "\*.* /inheritance:d /c /t", "", @SW_HIDE, $STDERR_MERGED)
            ProcessWaitClose($iPID2)
            Local $sOutput = StdoutRead($iPID2)
            FileWrite($hFileOpen, $sOutput)
        Local $iPID3 = Run(@ComSpec & " /c " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hLocal) & "&&icacls " & GUICtrlRead($hFolder) & " /grant " & '"' & 'system":(OI)(CI)F /c /t', "", @SW_HIDE, $STDERR_MERGED)
            ProcessWaitClose($iPID3)
            Local $sOutput = StdoutRead($iPID3)
            FileWrite($hFileOpen, $sOutput)
        Local $iPID4 = Run(@ComSpec & " /c " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hLocal) & "&&icacls " & GUICtrlRead($hFolder) & " /grant " & '"' &  @ComputerName & '\administrator":(OI)(CI)F /c /t', "", @SW_HIDE, $STDERR_MERGED)
            ProcessWaitClose($iPID4)
            Local $sOutput = StdoutRead($iPID4)
            FileWrite($hFileOpen, $sOutput)
        Local $iPID5 = Run(@ComSpec & " /c " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hLocal) & "&&icacls " & GUICtrlRead($hFolder) & " /grant " & '"' &  @ComputerName & '\administrators":(OI)(CI)F /c /t', "", @SW_HIDE, $STDERR_MERGED)
            ProcessWaitClose($iPID5)
            Local $sOutput = StdoutRead($iPID5)
            FileWrite($hFileOpen, $sOutput)
        Local $iPID6 = Run(@ComSpec & " /c " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hLocal) & "&&icacls " & GUICtrlRead($hFolder) & " /grant " & '"' & GUICtrlRead($hNew) & '\domain admins":(OI)(CI)F /c /t', "", @SW_HIDE, $STDERR_MERGED)
            ProcessWaitClose($iPID6)
            Local $sOutput = StdoutRead($iPID6)
            FileWrite($hFileOpen, $sOutput)
        Local $iPID7 = Run(@ComSpec & " /c " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hLocal) & "&&icacls " & GUICtrlRead($hFolder) & " /grant " & '"' & GUICtrlRead($hNew) & '\' & GUICtrlRead($hUID) & '":(OI)(CI)F /c /t', "", @SW_HIDE, $STDERR_MERGED)
            ProcessWaitClose($iPID7)
            Local $sOutput = StdoutRead($iPID7)
            FileWrite($hFileOpen, $sOutput)
        Local $iPID8 = Run(@ComSpec & " /c " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hLocal) & "&&icacls " & GUICtrlRead($hFolder) & " /setowner " & '"' & GUICtrlRead($hNew) & '\' & GUICtrlRead($hUID) & '" /c /t', "", @SW_HIDE, $STDERR_MERGED)
            ProcessWaitClose($iPID8)
            Local $sOutput = StdoutRead($iPID8)
            FileWrite($hFileOpen, $sOutput)
        Local $iPID9 = Run(@ComSpec & " /c " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hLocal) & "&&icacls " & GUICtrlRead($hFolder) & "\*.* /remove:g " & '"' & 'everyone" /c /t', "", @SW_HIDE, $STDERR_MERGED)
            ProcessWaitClose($iPID9)
            Local $sOutput = StdoutRead($iPID9)
            FileWrite($hFileOpen, $sOutput)
        Local $iPID10 = Run(@ComSpec & " /c " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hLocal) & "&&icacls " & GUICtrlRead($hFolder) & "\*.* /remove:g " & '"' & GUICtrlRead($hNew) & '\axeontech" /c /t', "", @SW_HIDE, $STDERR_MERGED) ;
            ProcessWaitClose($iPID10)
            Local $sOutput = StdoutRead($iPID10)
            FileWrite($hFileOpen, $sOutput)

    FileClose($hFileOpen)
    MsgBox(0, "", "Permissions Change: Complete")

EndFunc    ;= _Perm


Func _uArray()

    $fFileList = _FileListToArray(GUICtrlRead($hLetter) & ":\" & GUICtrlRead($hLocal), "*", 2)
;~     _ArrayDisplay($fFileList, "$fFileList")
    $fFolder = _ArrayToString($fFileList, "|")
    $fSplit = StringSplit($fFolder, "|", $STR_ENTIRESPLIT)
    Run("Notepad")
    Sleep(1000)

For    $i = 1 To $fSplit[0]
    Send($fSplit[$i])

Next

EndFunc
 

Thanks

Grimm

Share this post


Link to post
Share on other sites
Melba23

grimmlock,

As you do not specify precisely, I presume it is this section that is causing you problems:

$fFileList = _FileListToArray(GUICtrlRead($hLetter) & ":\" & GUICtrlRead($hLocal), "*", 2)
;~     _ArrayDisplay($fFileList, "$fFileList")
    $fFolder = _ArrayToString($fFileList, "|")
    $fSplit = StringSplit($fFolder, "|", $STR_ENTIRESPLIT)
    Run("Notepad")
    Sleep(1000)

For    $i = 1 To $fSplit[0]
    Send($fSplit[$i])

Next
Firstly, the code is working exactly as the Help file describes. If you want to Send the result to Notepad as separate lines then you need to add a line delimiter like this: :)

Send($fSplit[$i] & @CR)
But better still would be to convert the array directly into a string containing the line delimiter and then send it in one: ;)

$fFolder = _ArrayToString($fFileList, @CR)
Run("Notepad")
Sleep(1000)
Send($fFolder)
All clear? :)

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 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

 

Share this post


Link to post
Share on other sites
grimmlock

Very clear thank you for the help and explination, as always I am humbled :bye:

But now the hard part for me, I need to somehow take the data from the array and use it set some of the variables :sweating:.


Thanks

Grimm

Share this post


Link to post
Share on other sites
Melba23

grimmlock,

As always, glad I could help. :)

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 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

 

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • lattey
      By lattey
      hi,
      i have checkboxes and each checkbox that checked, i put in array. 
      now, im stuck on how to loop the checked array and store in in one variable. what i can do now, is only write the result into a text file. 
      below is the code:
      #include <GUIConstantsEx.au3> ;~ #include <MsgBoxConstants.au3> #include <ButtonConstants.au3> #include <Array.au3> Global $Count = 3 Global $CheckBoxP[$Count] Global $step[$Count] global $array1[1] Global $ExitResult $hGUI = GUICreate("Summary Steps", 500, 400) GUISetFont(12, 400, "Tahoma") GUICtrlCreateLabel( "Please Select the Summary Steps for Script Check", 70, 20) GUISetFont(10, 400, "Tahoma") Global $array_Pstep[3] = ["fix2","fix1","fix3"] global $step[3] = ["2","3","4"] $Spacing = 50 For $i = 0 To UBound($array_Pstep) - 1 $CheckBoxP[$i] = GUICtrlCreateCheckbox($array_Pstep[$i], 80, $Spacing + (20 * $i), 65, 17) Next $submit = GUICtrlCreateButton("Submit",180, 280, 80, 30) $exit = GUICtrlCreateButton("Exit",180, 320, 80, 30) GUISetState() While 1 $Msg = GUIGetMsg() Select case $Msg=$submit For $i = 0 To $Count - 1 If GUICtrlRead($CheckBoxP[$i]) = $GUI_CHECKED Then _ArrayAdd($array1, $step[$i]) EndIf Next Global $logfilerray = @WorkingDir & "\checkedlist.txt" FileDelete ($logfilerray) Global $readlogfile = FileOpen($logfilerray,1) for $a = 1 to UBound($array1) - 1 ;~ $var=$array1[$a] FileWriteLine($readlogfile,$array1[$a]) Next FileClose($readlogfile) Exit case $Msg=$exit $ExitResult = MsgBox(1,"Summary Step", "Continue to Exit ?") if $ExitResult = 1 Then ;ok Exit EndIf Exit EndSelect WEnd  
    • omicron
      By omicron
      How do you perform a nested loop function with a multidimensional array from 2 lists.
      for i in list1
      (open file) extract variable
          while open for i in list 2
          (open file2) extract variable
       
      var1 + var2 = (search term)

      The list sizes will more than likely consist of different lengths.
       
      What is the best approach to accomplishing this method?
             
    • UEZ
      By UEZ
      Following script shows a parent GUI with a child GUI initialized as MDICHILD.
      #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GuiReBar.au3> #include <GuiScrollBars.au3> #include <GuiToolbar.au3> #include <ScreenCapture.au3> #include <ScrollBarConstants.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global Enum $idNew = 1000, $idOpen, $idSave, $idHelper Global Const $iImageW = @DesktopWidth, $iImageH = @DesktopHeight Global Const $hBMP_ScreenCapture = _ScreenCapture_Capture("", 0, 0, $iImageW, $iImageH, False) Global Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP_ScreenCapture) Sleep(50) Global Const $iW = 1500, $iH = 700, $SC_DRAGMOVE = 0xF012 Global Const $hGUI = GUICreate("Move child GUI within GUI", $iW, $iH) Global Const $hToolbar = _GUICtrlToolbar_Create($hGUI) Global Const $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS)) Global Const $height_delta = 37 Global Const $idPic = GUICtrlCreatePic("", 0, $height_delta + 2, $iW, $iH) Global $hBitmap_tmp, $hHBitmap_tmp $hBitmap_tmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Global $hGfx_Context = _GDIPlus_ImageGetGraphicsContext($hBitmap_tmp) _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR) _GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN) _GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE) _GUICtrlToolbar_AddButtonSep($hToolbar) _GUICtrlToolbar_AddButton($hToolbar, $idHelper, $STD_HELP) _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0) Global Const $iVSscroll = _WinAPI_GetSystemMetrics(2) Global Const $iHSscroll = _WinAPI_GetSystemMetrics(3) Global Const $iYCaption = _WinAPI_GetSystemMetrics(4) Global Const $iYFixedFrame = _WinAPI_GetSystemMetrics(8) Global Const $iXFixedFrame = _WinAPI_GetSystemMetrics(7) Global Const $iMetricsSumX = $iVSscroll + $iXFixedFrame * 2 Global Const $iMetricsSumY = $iHSscroll + $iYCaption + $iYFixedFrame _GUIScrollBars_Init($hGUI) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, $iImageW - $iW + 61 + $iMetricsSumX) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_VERT, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $iImageH - $iH + $iMetricsSumY + $height_delta - 1) GUISetState(@SW_SHOW, $hGUI) Global Const $STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBMP_ScreenCapture)) Global $IE_offset_x = 0, $IE_offset_y = 0 DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL_IE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL_IE") Global $iPosX_Crop = 0, $iPosY_Crop = 0, $iW_crop = 200, $iH_crop = 200, $bMove_Crop = True Global $hGUI_IE_Crop = GUICreate("", $iW_crop, $iH_crop, $iPosX_Crop, $iPosY_Crop) GUISetStyle(BitOR($WS_BORDER, $WS_POPUP), $WS_EX_MDICHILD) _WinAPI_SetParent($hGUI_IE_Crop, $hGUI) WinSetTrans($hGUI_IE_Crop, "", 0xA0) Global $iLable_CropMove = GUICtrlCreateLabel("", 0, 0, $iW_crop, $iH_crop, -1, $GUI_WS_EX_PARENTDRAG) GUISetState(@SW_SHOW, $hGUI_IE_Crop) GUIRegisterMsg($WM_MOVE, "WM_MOVE_IE_GUI_Crop") ;~ GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Until False GUIRegisterMsg($WM_HSCROLL, "") GUIRegisterMsg($WM_VSCROLL, "") GUIRegisterMsg($WM_MOVE, "") GUIRegisterMsg($WM_LBUTTONDOWN, "") _WinAPI_DeleteObject($hBMP_ScreenCapture) _GDIPlus_BitmapDispose($hBitmap_tmp) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGfx_Context) _GDIPlus_Shutdown() Exit Func WM_HSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ; Get all the horizontal scroll bar information Local $tSCROLLINFO_X = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Min = DllStructGetData($tSCROLLINFO_X, "nMin") $Max = DllStructGetData($tSCROLLINFO_X, "nMax") $Page = DllStructGetData($tSCROLLINFO_X, "nPage") ; Save the position for comparison later on $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_X, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_X, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO_X) $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_HSCROLL_IE Func WM_VSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ;~ ; Get all the horizontal scroll bar information Local $tSCROLLINFO_Y = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO_Y, "nMin") $Max = DllStructGetData($tSCROLLINFO_Y, "nMax") $Page = DllStructGetData($tSCROLLINFO_Y, "nPage") ; Save the position for comparison later on $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_Y, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_Y, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO_Y) $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_VSCROLL_IE Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI_IE_Crop, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Func WM_MOVE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam If $hWnd = $hGUI_IE_Crop And $bMove_Crop Then $iPosX_Crop = _WinAPI_LoWord($lParam) $iPosY_Crop = _WinAPI_HiWord($lParam) EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>WM_MOVE_IE_GUI_Crop Func WM_SIZE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE_IE_GUI_Crop Func DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) _GDIPlus_GraphicsDrawImageRectRect($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH, 0, 0, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) EndFunc  
      My problem: if you move the child window at left upper corner to another place and move either H or V scrollbar the child GUI will be moved properly. BUT if you have scrolled the scrollbars to the right bottom of the image and move the child GUI to that corner, too then the child GUI jumps if you click on one of the scrollbars.
      Is there something that I didn't consider?
    • omicron
      By omicron
      Hello!

      I am working on a function that I am just getting lost on. The goal is a multiple nested loop.

      Here are the steps:
      Contents of file1.txt::
      [topic] var1=Name var2=OtherName var3=SomeotheName Contents of file2.txt::
      [subTopic] top=sub1 top2=sub2 top3=sub3 The Shell I am working from::
      #include <file.au3> $file = "c:\yourfile.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) msgbox(0,'','the line ' & $i & ' is ' & $line) Next FileClose($file) Understanding however that the "msgbox" needs to then become a variable. in example the following::
      $file = "c:\yourfile.txt" FileOpen($file, 0) While true( prog.exe is running && "WinName" is open) do For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) ;Open File to log "current location of file 1" FileWriteLine ("filename", $i & ' is ' & $line) var = $line Next $file2 = "c:\yourfile.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) ; OpenFile to log "Current location of file 2" FileWriteLine ("filename", $i & ' is ' & $line) Next FileClose($file2) FileClose($file) The goal in written form is the following ::

      While in "OpenWindow"
          read from file 1 starting at line 1 until end of file.
         file 1 is a list of names to be searched.
         With $line selected, add this element to the element in file 2.
       
      The search of a variables in list 1 and list 2 differ on the amount of posts that day. (This is not a web based platform, it is a game) I need to search 2 names and take a screenshot of the out put. The sizes of the names list depend on the activity of names at the time of search.
      This loop continues until all the names from both lists have been searched. Mostly in the format of::
      File1= item
      File2= Vendor
       
      Item + Vendor  ( Capture screen, scroll) -- Not sure how to detect if I need to scroll)
       
      Thank you for your help and support!
    • nooneclose
      By nooneclose
      I need help turning this string "20180913221626" into a formatted time string.
      I need to go from this: 20180913221626
      to this: 09/13/2018 10:16 PM
      I do not always know what the date will be so I can not just use a variable I need to actually convert/format. 
      I did see an older post in the forms that was basically the same question only the other guy did not post the working code and I can not figure out how to use _AD_GetObjectProperties properly to get what I want. 
      As always any help would be appreciated. 
      Here is the code I use to find the date, but it always gives me the unformatted version. 
      ;retrieve the items object $oItem = $oOutlook.Session.GetItemFromID($aItems[1][0], Default) $oItem.GetInspector $eSentOn = $oItem.SentOn ; When was the email sent? MsgBox("", "Sent On of the email", $eSentOn) ;******************************************************************************* ; Formats the date and time from the email ;******************************************************************************* ;Local $fDatenTime = _DateTimeFormat($eSentOn, 1) ;MsgBox("", "Formatted email time", $fDatenTime) $aProperties = _AD_GetObjectProperties($eSentOn) _ArrayDisplay($aProperties, "Did the conversion work?")  
×