Search the Community
Showing results for tags '@scriptdir'.
-
Hi everyone.I need did my script is portable.I use @ScriptDir and trying use one command Example: RunWait(@ComSpec & '/ c copy /y ' & @ScriptDir & ' "\LOGUS\Logus.HMS.Desktop.lnk" "\\' & $rHostName & '\C$"') but it doesn't work for me.Please need for help.Thanks for your experience.Sorry for my English,I'm Russian... #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <String.au3> #include <Crypt.au3> #include <WinAPISysWin.au3> #RequireAdmin #NoTrayIcon Opt("GUIOnEventMode", 1) Global $Assets = @ScriptDir & "\Assets\" Global $cUI_BK = 0x02101B Global $cContent_BK = 0x091926 Global $cText = 0xDEDEDE Global $cTextA = 0x56CBDD Global $cCardBk = 0x0C1C29 Global $lastMenu = Default Global $isOnTop = False Global $ui_w = 800 Global $ui_h = 520 Global $topPanel_h = CalcPercent(12, $ui_h) Global $bottomPanel_h = CalcPercent(8, $ui_h) Global $bottomPanel_y = $ui_h - $bottomPanel_h Global $leftPanel_w = CalcPercent(25, $ui_w) Global $contentPanel_x = $leftPanel_w Global $contentPanel_y = $topPanel_h Global $contentPanel_w = $ui_w - $leftPanel_w Global $contentPanel_h = $ui_h - ($topPanel_h + $bottomPanel_h) Global $UI = GUICreate("Experience UI", $ui_w, $ui_h) ; $WS_POPUP, $WS_EX_CONTROLPARENT WinSetTrans($UI, "", 0); GUISetState(@SW_SHOW, $UI) For $i = 0 To 243 Step 2 WinSetTrans($UI, "", $i);Прозрачность 0-255 Next GUISetOnEvent(-3, "Terminate", $UI) GUISetBkColor($cUI_BK, $UI) Global $topPanel = GUICtrlCreateLabel("", 0, 0, $ui_w, $topPanel_h) ; height = 12% from UI | (ps. $GUI_WS_EX_PARENTDRAG) GUICtrlSetState($topPanel, 128) ; $GUI_DISABLE GUICtrlSetBkColor($topPanel, $cUI_BK) Global $bottomPanel = GUICtrlCreateLabel("", 0, $bottomPanel_y, $ui_w, $bottomPanel_h) GUICtrlSetState($bottomPanel, 128) ; $GUI_DISABLE GUICtrlSetBkColor($bottomPanel, $cUI_BK) Global $leftPanel = GUICtrlCreateLabel("", 0, $topPanel_h, $leftPanel_w, $ui_h - ($topPanel_h + $bottomPanel_h)) GUICtrlSetState($leftPanel, 128) ; $GUI_DISABLE GUICtrlSetBkColor($leftPanel, $cUI_BK) Global $contentPanel = GUICtrlCreateLabel("", $contentPanel_x, $contentPanel_y, $contentPanel_w, $contentPanel_h) GUICtrlSetState($contentPanel, 128) ; $GUI_DISABLE GUICtrlSetBkColor($contentPanel, $cContent_BK) $y = $bottomPanel_y + (($bottomPanel_h / 2) - (28 / 2)) GUICtrlCreateLabel("© 2020 by DiJo.", 10, $y, $leftPanel_w - 38, 28, 0x0200) GUICtrlSetFont(-1, 8, Default, Default, "Segoe UI", 5) ; 5 = Clear Type GUICtrlSetColor(-1, $cText) Global $y = $topPanel_h GUICtrlCreateLabel(" FNKC Pack", 52, $y, $leftPanel_w - 52, 32, 0x0200) GUICtrlSetFont(-1, 12, 600, Default, "Segoe UI", 5) ; 5 = Clear Type GUICtrlSetColor(-1, $cText) $y += 50 Global $vDashboard = GUICtrlCreateLabel("Mode 1", 38, $y, $leftPanel_w - 38, 32, 0x0200) GUICtrlSetOnEvent(-1, "DashboardEvent") GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type GUICtrlSetColor(-1, $cTextA) GUICtrlSetCursor(-1, 0) $lastMenu = $vDashboard $y += 32 Global $vWallet = GUICtrlCreateLabel("Mode 2", 38, $y, $leftPanel_w - 38, 32, 0x0200) GUICtrlSetOnEvent(-1, "WalletEvent") GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type GUICtrlSetColor(-1, $cText) GUICtrlSetCursor(-1, 0) $y += 32 Global $vMessages = GUICtrlCreateLabel("Mode 3", 38, $y, $leftPanel_w - 38, 32, 0x0200) GUICtrlSetOnEvent(-1, "MessagesEvent") GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type GUICtrlSetColor(-1, $cText) GUICtrlSetCursor(-1, 0) $y = ($topPanel_h + 50) Global $vIndicator = GUICtrlCreateLabel("", 0, $y, 4, 32) GUICtrlSetBkColor(-1, $cTextA) $x = $contentPanel_x + 10 $y = $contentPanel_y + 15 Global $iHostName = GUICtrlCreateInput("", $x + 200, $y + 10, 180, 21) Global $Button1 = GUICtrlCreateButton("Ping", $x, $y + 80, 267, 43) GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x0E0C2E) GUICtrlSetOnEvent(-1, "_Didshit1") Global $Button2 = GUICtrlCreateButton("Logus", $x + 310, $y + 80, 267, 43) GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x0E0C2E) GUICtrlSetOnEvent(-1, "_Didshit2") Global $Button3 = GUICtrlCreateButton("Start", $x, $y + 140, 267, 43) ;создаем кнопку подключения GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x0E0C2E) Global $Checkbox1 = GUICtrlCreateCheckbox("", $x + 273, $y + 95, 12, 12) Global $Checkbox2 = GUICtrlCreateCheckbox("", $x + 293, $y + 95, 12, 12) GUISetState() ; Show GUI Global $rHostName While True Sleep(10) WEnd Func DashboardEvent() If $lastMenu <> $vDashboard Then Local $CGP = ControlGetPos($UI, '', $vDashboard) GUICtrlSetPos($vIndicator, 0, $CGP[1]) GUICtrlSetColor($vDashboard, $cTextA) GUICtrlSetColor($lastMenu, $cText) $lastMenu = $vDashboard GUICtrlSetState($Button1, $GUI_SHOW) GUICtrlSetState($Button2, $GUI_SHOW) GUICtrlSetState($Checkbox1, $GUI_SHOW) GUICtrlSetState($Checkbox2, $GUI_SHOW) ConsoleWrite(1) EndIf EndFunc ;==>DashboardEvent Func WalletEvent() If $lastMenu <> $vWallet Then Local $CGP = ControlGetPos($UI, '', $vWallet) GUICtrlSetPos($vIndicator, 0, $CGP[1]) GUICtrlSetColor($vWallet, $cTextA) GUICtrlSetColor($lastMenu, $cText) $lastMenu = $vWallet GUICtrlSetState($Button1, $GUI_HIDE) GUICtrlSetState($Button2, $GUI_HIDE) GUICtrlSetState($Checkbox1, $GUI_HIDE) GUICtrlSetState($Checkbox2, $GUI_HIDE) ConsoleWrite(1) EndIf EndFunc ;==>WalletEvent Func MessagesEvent() If $lastMenu <> $vMessages Then Local $CGP = ControlGetPos($UI, '', $vMessages) GUICtrlSetPos($vIndicator, 0, $CGP[1]) GUICtrlSetColor($vMessages, $cTextA) GUICtrlSetColor($lastMenu, $cText) $lastMenu = $vMessages GUICtrlSetState($Button1, $GUI_HIDE) GUICtrlSetState($Button2, $GUI_HIDE) GUICtrlSetState($Checkbox1, $GUI_HIDE) GUICtrlSetState($Checkbox2, $GUI_HIDE) ConsoleWrite(1) EndIf EndFunc ;==>MessagesEvent Func _Didshit1() $rHostName = GUICtrlRead($iHostName) Run(@ComSpec & ' /c C:\Windows\System32\Ping.exe ' & $rHostName & ' -t') EndFunc ;==>_Didshit1 Func _Didshit2() $rHostName = GUICtrlRead($iHostName) RunWait(@ComSpec & ' /c PsPasswd \\' & $rHostName & ' Администратор Mik35') RunWait(@ComSpec & ' /c copy /y "C:\Progra~2\DiJo\LOGUS\Logus.bat" "\\' & $rHostName & '\C$"') RunWait(@ComSpec & ' /c copy /y "C:\Progra~2\DiJo\LOGUS\Logus.HMS.Desktop.lnk" "\\' & $rHostName & '\C$"') RunWait(@ComSpec & ' /c psexec \\' & $rHostName & ' -u Администратор -p Mik35 cmd.exe /c "C:\Logus.bat"') EndFunc ;==>_Didshit2 Func Terminate() GUIDelete($UI) Exit EndFunc ;==>Terminate Func Minimize() GUISetState(@SW_MINIMIZE, $UI) EndFunc ;==>Minimize Func Topmost() If $isOnTop = False Then WinSetOnTop($UI, Default, 1) $isOnTop = True Else WinSetOnTop($UI, Default, 0) $isOnTop = False EndIf EndFunc ;==>Topmost Func CalcPercent($vPercent, $vInt) ; Calculate percent % :) Return $vPercent * $vInt / 100 EndFunc ;==>CalcPercent
-
How do i add a path to a file in Include. I want my script to get the udf in the same folder as the script/exe: Include "@ScriptDir/udf.au3" can this be done?
-
Hi guys, I'm either going crazy or AutoIT is.. Basically I need to get to the parent folder of @scriptdir, to do that, I used: $parentFolder=StringLeft(@ScriptDir, StringInStr(@ScriptDir, "\", 0, -1)) So far, all good. When I use MsgBox to show $parentfolder, I'm indeed able to see the folder above @scriptdir. Now, I've added a subfolderfile to the string with: $PPID_Bulk_Big_printers_csv_path=$parentFolder&'Printers\printers_PPID_Big.csv' And also here, all fine, MsgBox shows me the file location correctly. Now, for some weird reason, $PPID_Bulk_Big_printers_csv_path changes again! See the complete part of the script below: ; CSV to 2D array $parentFolder=StringLeft(@ScriptDir, StringInStr(@ScriptDir, "\", 0, -1)) ;Goes one folder up MsgBox(0,'',@ScriptDir&'----'&$parentFolder&'Printers\printers_PPID_Big.csv') $PPID_Bulk_Big_printers_csv_path=$parentFolder&'Printers\printers_PPID_Big.csv' ;CSV location Dim $PPID_Bulk_Big_printers $PPID_Bulk_Big_filereadtoarray_result = _FileReadToArray($PPID_Bulk_Big_printers_csv_path, $PPID_Bulk_Big_printers) ;$PPID_Bulk_Big_filereadtoarray_result will contain any error (if there's any) - $printers is an array which contains the list of printers MsgBox(0,'',$PPID_Bulk_Big_printers_csv_path) ; Still shows correct path ;Check if there was any error with the _FileReadToArray If $PPID_Bulk_Big_filereadtoarray_result <> 0 Then ;If no error reading the file ;Do Something Else ;If there was an error reading the CSV file MsgBox(0,'hhh',"msg="&$PPID_Bulk_Big_printers_csv_path) MsgBox(48,'Problem detected!','The file "'&$PPID_Bulk_Big_printers_csv_path&'" was not found. Software will exit!') Sleep (50) Exit EndIf So what's happening here is, I'm getting into the ELSE part of the script, so there was an error with reading the file and I'm getting indeed the message box with "Problem detected!" but NOT the message box above?? Why? Cheers