
z0iid
Active Members-
Posts
29 -
Joined
-
Last visited
z0iid's Achievements

Seeker (1/7)
0
Reputation
-
I like the script, and I've found a good use for it. One enhancement I'm struggling to add, is the ability to either autocomplete based on any matching (e.g., word in dictionary: dictionary -- typing starts out with "ary", I would want it to match) OR if there are two words, that it would also match based on the second word. I imagine with the two words, I would be doing a string split based on a space as the delimiter, and edit the _checkinputtext function accordingly to check both parts of the string split. Any thoughts on the best way to approach this?
-
hopefully Yashied is still following this thread. I may be using this pop-up in a way it wasn't intended, but I'm occasionally getting the "subscript used with non-array variable" error message. (for line 412 - If $ppData[$i][9 ] Then ) I'm calling a function, and in that function is where I set the popup_register and popup_show - then i stick it in a while loop for 5 seconds waiting for user activity, and if none, then i dispose of the popup and go back to my main loop. i get the error sometimes (but not everytime, probably only once every 20 times) within those 5 seconds. here is the simple do loop code: Do $vIdleTime = _Timer_GetIdleTime() sleep(1) Until $vidletime >= $verify_timeout or WinExists("_fOverlay") <> 1 Here is my full messy code: #AutoIt3Wrapper_icon=.\logoff.ico #include <GuiRichEdit.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <timers.au3> #include <ad.au3> #include <WinAPI.au3> #include <array.au3> #include <file.au3> #Include <GDIPlus.au3> #Include <Pop-ups.au3> ;~ #include <GuiListBox.au3> ;~ #include <GuiListView.au3> ;~ #include <ProgressConstants.au3> #include <ButtonConstants.au3> #include <guiedit.au3> AutoItSetOption("TrayIconHide", 1) OnAutoItExitRegister("_FontCleanUp") Global $ahFontEx[1] = [0] Global $array_limit, $port, $time_lbl, $hWnd, $idletime, $dispname, $hGUI_OV, $lapse, $EditM, $EditV, $logdataF, $vn_idle, $iidletime, $begin_Fade, $lapse_timout, $vidletime Global $mmoveflag = 42 Global $gui_up = 0 $VirtualDesktopWidth = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 78);sm_virtualwidth $VirtualDesktopWidth = $VirtualDesktopWidth[0] $VirtualDesktopHeight = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 79);sm_virtualheight $VirtualDesktopHeight = $VirtualDesktopHeight[0] $VirtualDesktopX = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 76);sm_xvirtualscreen $VirtualDesktopX = $VirtualDesktopX[0] $VirtualDesktopY = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 77);sm_yvirtualscreen $VirtualDesktopY = $VirtualDesktopY[0] HotKeySet("{ESC}", "_hide") HotKeySet("!{F9}", "_quit") HotKeySet("!{F2}", "_fade") $textfont = "Bell MT Regular" $clientfile = "c:\post\client.txt" $picfile = "c:\post\fadeout\images\userpic.png" Global $max_trans = 255 ; How transparent do you want the window, 0 = hidden, 255 = fully shown Global $GUIFADE_MAXTRANS = 255 ; the current max transparency level Dim $hGUI, $maxtime = 0 $rev = 0 $seconds = 1000 ; ===Settings that can be changed based on Informatics or Leadership decision=== ; ; $inittime + $free_out is the total time a user has to interact with the computer without being bothered with verification/question prompt ; $inittime =60 * $seconds ;time before fade begins after inactivity $first_delay = 5 * $seconds ;time fade screen pauses at first fade step down $second_delay = 10 * $seconds ;time fade screen pauses at second fade step down $free_out = 30 * $seconds ; should NEVER be less than $first_delay + $second_delay - this is the time that a user can interact with the computer after the fade begins before being forced to verify by photo $verify_timeout = 5 * $seconds ;time photo verify stays up (without user interaction) before going back to screensaver ; ~~~~~~~~~~~ END CONF ~~~~~~~~~~~ Func _main() While 1 $iIdleTime = _Timer_GetIdleTime() If FileExists($clientfile) And $mmoveflag <> 1 Then $mpos = MouseGetPos() MouseMove($mpos[0] + 1, $mpos[1] + 1,2) $mmoveflag = 1 Sleep(2) EndIf $iIdleTime = _Timer_GetIdleTime() If $iIdleTime >= $inittime And WinExists("_fadeout") <> 1 And FileExists($clientfile) = 1 Then $begin_Fade = TimerInit() _Fade() While FileExists($clientfile) = 1 or $iidletime >= $inittime If $iidletime < $vn_idle Then $vn_idle = 0 ExitLoop EndIf $iIdleTime = _Timer_GetIdleTime() If $iIdleTime < $inittime Then Select Case TimerDiff($begin_Fade) <= $free_out or FileExists($picfile) = 0 _FadeGUIOut($hGUI) ContinueLoop 2 Case TimerDiff($begin_Fade) > $free_out; and TimerDiff($lapse_timout) > 1000 $iIdleTime = $iIdleTime + $inittime _VerifyUser() EndSelect If $lapse = 5 Then ContinueLoop Else Return 99 EndIf ExitLoop EndIf If $iIdleTime < $inittime and WinExists("_fadeout") = 1 or FileExists($clientfile) = 0 Then EndIf ;~ Sleep(100) If GUICtrlRead($time_lbl) <> @HOUR & ":" & @MIN Then GUICtrlSetData($time_lbl, @HOUR & ":" & @MIN) EndIf sleep(100) WEnd EndIf sleep(100) WEnd EndFunc Func _Fade() ;Creates blank black screen gui with full transparency, fades in to non-transparent (by calling _FadeGuiIn) , adds Display Name, time, and text $hGUI = GuiCreate("_fadeout", $VirtualDesktopWidth + 10, $VirtualDesktopHeight + 100, -10,-10, $WS_POPUP + $WS_DLGFRAME, $WS_EX_APPWINDOW + $WS_EX_TOPMOST) GUISetBkColor(0) _FadeGUIIn($hGUI,$max_trans) $dispname = FileReadLine("c:\post\client.txt") If StringLen($dispname) < 20 Then $fontsize = 60 $offset = 250 ElseIf StringLen($dispname) > 30 Then $fontsize = 40 $offset = 230 Else $fontsize = 50 $offset = 240 EndIf $Label3 = GUICtrlCreateLabel("____________________________________________", 150 , (@DesktopHeight / 2) - 50, 850, 20) GUICtrlSetColor($Label3, 0xFFFFFF) GUICtrlSetFont($Label3, 12, 400, 0, $textfont, 4) $label2 = GUICtrlCreateLabel("Not you? Tap your badge to login.", 150 , (@DesktopHeight / 2) - 20, 450, 80) GUICtrlSetColor($Label2, 0xFFFFFF) GUICtrlSetFont($Label2, 20, 500, 0, $textfont, 4) $verticalline = GUICtrlCreateLabel("______________________________________________", @DesktopWidth - 480, (@DesktopHeight /2) - 55 , 400, 400, 0x001) GUICtrlSetColor($verticalline, 0xFF7738) _GuiCtrlSetFont($verticalline, 12, 400, 0, -90, $textfont, 4) $time_lbl = GUICtrlCreateLabel(@HOUR & ":" & @MIN, @DesktopWidth - 360, (@DesktopHeight /2) - 40, 300, 100) GUICtrlSetColor($time_lbl, 0xFF7738) GUICtrlSetFont($time_lbl, 70, 600, 0, $textfont, 4) $Label1 = GUICtrlCreateLabel($dispname, 150 , (@DesktopHeight / 2) - $offset, 950, 105, $SS_LEFTNOWORDWRAP) GUICtrlSetColor($Label1, 0xFFFFFF) GUICtrlSetFont($Label1, $fontsize, 600, 0, $textfont, 4) $Label4 = GUICtrlCreateLabel("is logged in", 250 , (@DesktopHeight / 2) - 150, 850, 20) GUICtrlSetColor($Label4, 0xFFFFFF) GUICtrlSetFont($Label4, 12, 400, 0, $textfont, 4) EndFunc Func _FadeGUIIn($hWnd,$iMax=255) ;called from _Fade function $GUIFADE_MAXTRANS = $iMax WinSetTrans($hWnd, "", 0) GUISetState(@SW_SHOW) For $i = 1 To 85 Step 2 WinSetTrans($hWnd, "", $i) Next _CheckIdle($first_delay, 1) For $i = 86 To 170 Step 2 WinSetTrans($hWnd, "", $i) Next _CheckIdle($first_delay + $second_delay, 2) For $i = 171 To 255 Step 2 WinSetTrans($hWnd, "", $i) Next EndFunc ;==>_FadeGUIIn Func _FadeGUIOut($hWnd) GuiSetState($hWnd, @SW_HIDE) GUIDelete($hWnd) $gui_up = 0 $maxtime = 0 EndFunc ;==>_FadeGUIOut Func _quit() Exit EndFunc Func _CheckIdle($maxtime, $rev) $iIdleTime = _Timer_GetIdleTime() While $iIdleTime < $inittime + $maxtime If $iIdleTime < $inittime Then _FadeGUIOut($hGUI) Return 1 EndIf Sleep(100) $iIdleTime = _Timer_GetIdleTime() WEnd If $iIdleTime < $inittime Then _FadeGUIOut($hGUI) Return 1 Else EndIf $maxtime = 0 EndFunc Func _FontCleanUp() For $i = 1 To $ahFontEx[0] _WinAPI_DeleteObject($ahFontEx[$i]) Next EndFunc Func _GuiCtrlSetFont($controlID, $size, $weight = 400, $attribute = 0, $rotation = 0, $fontname= "", $quality = 2) Local $fdwItalic = BitAND($attribute, 1) Local $fdwUnderline = BitAND($attribute, 2) Local $fdwStrikeOut = BitAND($attribute, 4) ReDim $ahFontEx[UBound($ahFontEx) + 1] $ahFontEx[0] += 1 $ahFontEx[$ahFontEx[0]] = _WinAPI_CreateFont($size, 0, $rotation * 10, $rotation, $weight, _ $fdwItalic, $fdwUnderline, $fdwStrikeOut, -1, 0, 0, $quality, 0, $fontname) GUICtrlSendMsg($controlID, 48, $ahFontEx[$ahFontEx[0]], 1) EndFunc Func _Hide() GUIDelete($hWnd) EndFunc Func _VerifyUser() $vIdleTime = _Timer_GetIdleTime() If $vidletime > $verify_timeout Then Return 1 EndIf Opt("Guioneventmode", 1) Global $hPopup2 = _Popup_Register() Global $hPopup1 = _Popup_Register() ;~ $image = @ScriptDir & "\dummyimage.png" ;~ $image = @ScriptDir & "\NOimage.png" $xrand = Random(25, @DesktopWidth - 545) _GDIPlus_Startup() $hGUI_OV = GuiCreate("_fOverlay", $VirtualDesktopWidth + 10, $VirtualDesktopHeight + 100, -10,-10, $WS_POPUP + $WS_DLGFRAME, $WS_EX_APPWINDOW + $WS_EX_TOPMOST) $greybar = GUICtrlCreateLabel("", 0, $VirtualDesktopHeight - (($VirtualDesktopHeight/3) - 20), @DesktopWidth - 1, ($VirtualDesktopHeight/3) + 20) GUICtrlSetState($greybar, $GUI_DISABLE) $youq = GUICtrlCreateLabel("YOU?", $xrand, @DesktopHeight - 630 , 270, 105) GUICtrlSetColor($youq, 0xFFFFFF) GUICtrlSetFont($youq, 72, 800, 0, $textfont, 4) GUICtrlSetBkColor($greybar, 0x3F3F3F) $Label_smname = GUICtrlCreateLabel($dispname, $xrand, @DesktopHeight - 140,545, 40, $SS_LEFTNOWORDWRAP) GUICtrlSetColor($Label_smname, 0xFFFFFF) GUICtrlSetFont($Label_smname, 26, 400, 0, $textfont, 4) GUICtrlSetBkColor($Label_smname, 0x3F3F3F) GUISetBkColor(0) GUISetState() $Button1 = GUICtrlCreateButton("NO", @DesktopWidth - 280, @DesktopHeight - 70,260,70, BitOR($BS_FLAT,$BS_BITMAP), $WS_EX_STATICEDGE) GUICtrlSetImage($Button1, @ScriptDir & "\nobtn.bmp", -1) GUICtrlSetOnEvent($Button1, "_NoBtnClick") $Button2 = GUICtrlCreateButton("YES", $xrand + 5, @DesktopHeight - 70 , 260, 70, BitOR($BS_FLAT,$BS_BITMAP), $WS_EX_STATICEDGE) GUICtrlSetImage($Button2, @ScriptDir & "\yesbtn.bmp", -1) GUICtrlSetOnEvent($Button2, "_YesBtnClick") $hImage1 = _GDIPlus_ImageLoadFromFile($picfile) _Popup_Show($hPopup1, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1), 1, $xrand + 130, @DesktopHeight - 350, -1, 0) $vIdleTime = _Timer_GetIdleTime() Do $vIdleTime = _Timer_GetIdleTime() sleep(1) Until $vidletime >= $verify_timeout or WinExists("_fOverlay") <> 1 $maxtime = 0 $lapse = 5 If $hPopup1 <> "" Then _popup_hide($hPopup1) GUISetState(@SW_Hide) if $hPopup1 <> "" Then _Popup_Unregister($hPopup1) _GDIPlus_Shutdown() GUIDelete($hGUI_OV) EndFunc Func _NoBtnClick() GUISetState($hGUI, @SW_HIDE) GUIDelete($hGUI) _popup_hide($hPopup1) _Popup_Unregister($hPopup1) _GDIPlus_Shutdown() GUISetState("hGui_OV", @sw_hide) GUIDelete($hGUI_OV) Send("{F6}") Exit EndFunc Func _YesBtnClick() _popup_hide($hPopup1) _Popup_Unregister($hPopup1) _GDIPlus_Shutdown() GUISetState("hGui_OV", @sw_hide) GUIDelete($hGUI_OV) GUIDelete($hGUI) $maxtime = 0 _FadeGUIOut($hGUI) $vn_idle = $iidletime + $inittime EndFunc Func _LogToEdit($ctrl_ID, $data) GUICtrlSetData($ctrl_ID, $data) EndFunc _main()
-
forcing it to skip . and .. solved the problem. Down to less than 20 minutes for a full scan of the file share. I should know better by know that M23 code is top shelf and that problems i experience are user related. thanks again.
-
my bad. i've been so inundated at work, i completely forgot I had a similar issue last year. The version of the UDF I had did not have that line. I added it to the latest version, and I'll get back to testing.
-
This may not be very helpful (or solicited) - but... I used this udf to create a commandline tool for some of my fellow employees. It allows them to provide a path, file type, and location for csv file - then it spits out size, date created/modified. It works as designed - thanks. BUT... when searching very large file shares, with some folder paths that are very deep/long...more than 256 characters (that also happen to be cifs shares mounted on a novell server), I see that it chews up memory fairly rapidly, depending on file mask, while barely using any CPU. normally this wouldn't be a problem, but it doesn't end up paging to disk after memory runs out - so it will quit with a memory error before completing. Any thoughts on chunking out when results hit a user defined limit, that way it can have a sort of garbage collection feature? Also, I can't see a programmatic way to increase performance - but it seems like it could use more CPU. I would expect bad code in a nasty loop to use up 12.5% of my cpu (8 cores) (like some code i've written... :/ ) - and/or something working really hard to use that much as well. This never breaks 2% cpu on my box, and takes hours to search the same share I could search using a dir /s command in 20 minutes or less.
-
Or - save this as UDF: $service = "" ConsoleWrite(_SetServiceState(@ComputerName, $service, "Stop") & @LF) Sleep ( 5000 ) ConsoleWrite(_SetServiceState(@ComputerName, $service, "Start") & @LF) Func _SetServiceState($s_pc, $service, $State) Local Const $wbemFlagReturnImmediately = 0x10 Local Const $wbemFlagForwardOnly = 0x20 Local $colItems = "", $objItem, $ret_status = -1 Local $a_status[25] = ["Success", "Not supported", "Access denied", "Dependent services running", _ "Invalid service control", "Service cannot accept control", "Service not active", "Service request timeout", _ "Unknown failure", "Path not found", "Service already stopped", "Service database locked", "Service dependency deleted", _ "Service dependency failure", "Service disabled", "Service logon failed", "Service marked for deletion", "Service no thread", _ "Status circular dependency", "Status duplicate name", "Status - invalid name", "Status - invalid parameter", _ "Status - invalid service account", "Status - service exists", "Service already paused"] If Ping($s_pc) Then Local $objWMIService = ObjGet("winmgmts:" & $s_pc & "rootCIMV2") If @error Then MsgBox(16, "_SetServiceState", "ObjGet Error: winmgmts") Return EndIf $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Service", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If @error Then MsgBox(16, "_SetServiceState", "ExecQuery Error: SELECT * FROM Win32_Service") Return EndIf If IsObj($colItems) Then For $objItem In $colItems If $objItem.Name = $service Then Select Case $State = "Boot" Or $State = "System" Or $State = "Automatic" Or $State = "Manual" Or $State = "Disabled" $ret_status = $objItem.ChangeStartMode ($State) Case $State = "Stop" $ret_status = $objItem.StopService () Case $State = "Start" $ret_status = $objItem.StartService () Case $State = "Pause" $ret_status = $objItem.PauseService () Case $State = "Resume" $ret_status = $objItem.ResumeService () Case $State = "Delete" $ret_status = $objItem.Delete () EndSelect ExitLoop EndIf Next EndIf EndIf If $ret_status <> -1 Then Return $a_status[$ret_status] Else SetError(1) Return $ret_status EndIf EndFunc ;==>_SetServiceState Then in your script, for example: _setservicestate("computer-name", "spooler", "stop") MsgBox(0,"", "Complete") The MsgBox will not pop-up until the function completes, signifying that the service has completely stopped.
-
File usage monitor - not sure where to start.....
z0iid replied to shornw's topic in AutoIt General Help and Support
I completely forgot about those functions. Yes, _Net_Share_FileEnum() should get you exactly what you are looking for. You still need to build a for loop to iterate through each machine you want the stats, and then you might want to use _FileWriteFromArray for logging. **edit** based on your comments, it appears you don't already know the names/ip's - so you either need to iterate through each ip, ie 10.1.1.2 to 10.1.1.254, then 10.1.2.2 to 10.1.2.254, etc. BUT... you can use the AD udf to connect and get computer names for all of AD and iterate that way... but we aren't big enough for forrests or mulitple domains (save our test AD)..(only 1,600~ devices)....it can definitely be done, but it is still reliant on DNS being accurate. As you know, if you try to connect to a specific pc to get the report, but the DNS record is stale, you will likely be pulling a report from a different computer. Gotta clean up DNS before you can trust any report data. -
File usage monitor - not sure where to start.....
z0iid replied to shornw's topic in AutoIt General Help and Support
built in windows command: net file then for instance if there are 5 items listed, and one has and id of 55, run: net file 55 and that would give you the information you might be looking for. if you don't care about the detailed information, then what you want would be relatively easy. download psexec, put it on whatever machine will be running this code. If you already have a list of computers - save the list to a txt file (you can also pull from Active Directory on the fly if you wanted). Read the file to an array, then for each item in the array run: psexec computername net file > c:workingdircomputername_connections.log psexec actually supports running commands based on a text file, so you could skip using autoit altogether ....although it would be a bit more difficult to create individual log files, or append to an existing log. If you want the detailed information for each ID listed per computer, you would need to create an inner For loop that parses the data to only look for the lines that contain id's, then run the 'net file id' command, and save that information to a log file. -
When I saw the implementation using negative/positive parameters, it was an "AhHA!" moment for me. Like "why didn't I think of that..."
-
lol - no, the comparison was with regards to the "Some people are never satisifed!" comment. (She was never satisfied - now her lack of satisfaction is someone elses problem) I certainly don't want to be known as a demanding/trouble forum user.... let other users (the community) decide how to implement the feature. (although, Global is certainly acceptable for me, and how I will use the feature.) btw - your UDF's are great training resources for me since i don't know standards....I hope to learn by example. **edit** looked at the changes, and example - fantastic, love it. I may spend some time integrating this into a systemwide app (similar to growl) that can accept "feeds" from other apps, event logs, etc - what ever the user wants to subscribe to for notifications. *shrug*.... but with the existence of growl, it probably wouldn't be used many places except for the organization i work for.
-
definition of my ex! yeah, no worries melba - I understand the udf well enough to be able to make those changes as I see fit - just throwing out suggestions in case you hadn't thought of those use case scenarios. i could attempt to toss in the parameter/function adjustments.... but I've never taken any formal programming classes, so I don't really know *standards* per say. While I could get it to "work", it probably wouldn't be the way a real programmer (you) would implement something.
-
Melba - Thank you! Already implemented the _Notify_Hide function, and it works perfectly (of course). Another suggestion (not a big deal, since I just modified the udf to fit my needs/wants) - but maybe another option in _Notify_Set that allows for defining show and hide/delete behavior (slide vs fade/blend) 0x00080000 for fade in, 0x00090000 for fade out - but you already knew that, and an option for slide in time/delay slide out (fade out) time/delay. (Since the AnimateWindow function is synchronous, there are times a faster slide/blend would be preferred). I ended up having to speed up the slide out time, since I'm using this on virtual desktops that use the RDP protocol (and we use high compression), the default slide out time was a bit "glitchy/stuttered". I'm using slide in @ 350 - fade (blend) out @ 1000 - and it is beautiful. Thanks again for this wonderful UDF - it will be implemented in as many user facing scripts as possible.
-
my interim solution for the notification retraction was more of a "hard coded/static" solution for this specific case - but yes, for multiple notifications it would not work. (and I chose to use the fade value instead of slide) $bPatient = _Notify_Show(64, $cmdline[2] & " loading...", "", 0, 0) ; progressbar GUICtrlCreateProgress(50, 25, 100, 10, $PBS_MARQUEE) GUICtrlSendMsg(-1, $PBM_SETMARQUEE, True, 50) $begin = TimerInit() ; initialize timer While WinExists($windowname) = 0 and TimerDiff($begin) < 21000 Sleep(225) If WinExists($windowname) = 1 or WinExists("Citrix online plug-in") = 1 Then ExitLoop ; once window exists, quit WEnd Sleep(500) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $aNotify_Data[1][0], "int", 1000, "long", 0x00090000) ; $AW_BLEND + $AW_HIDE also, for the text wrapping issue, I ended up changing the weight of the font for the title lable (you had it at 800 for bold, which I prefer (had to change to 400)... but a long label ends up wrapping the title - even with max width set to 600) I tried a few different fonts, but to get a "bolded" look, it ends up occasionally wrapping if my cmd parameter is too long. - 24 characters appears to be the limit before wrapping - using _Notify_Set(Default) . Maybe different with a monospaced font.
-
another question Melba.... (just tell me to go away if i'm too bothersome) I'm using the $PBS_MARQUEE with notify... no problem there, works great. But I'm creating the notification before my while loop (in an if loop) - not clickable, and doesn't time out. BUT...i want it to gracefully slide back out off the screen once progress is actually "done". Snippet: $bPatient = _Notify_Show(64, $cmdline[2] & " loading...", "", 0, 0) GUICtrlCreateProgress(50, 25, 100, 10, $PBS_MARQUEE) GUICtrlSendMsg(-1, $PBM_SETMARQUEE, True, 50) $begin = TimerInit() ; initialize timer While WinExists($windowname) = 0 and TimerDiff($begin) < 21000 Sleep(225) If WinExists($windowname) = 1 or WinExists("Citrix online plug-in") = 1 Then ExitLoop ; once window exists, quit WEnd I see the _Notify_Delete function is internal only, but at least in this case, there is a need to have an "external" version of that function. Thoughts? *edit* I guess if i could get the hwnd returned for use, it would be easy enough.... any hints? I know I'm missing something simple. *edit2* - k, figured those out.... now... need to figure out how to prevent text wrapping if using $PBS_MARQUEE (since any text wrapped will be hidden by the progress bar...)
-
yup - i love the toast udf, and already use it - i just liked the notify mechanism better for the specific use case. i may try to make the toast work in this case. thanks for all your work - your stuff is great.