Jump to content

Code not working on locked machine


Recommended Posts

Hi

I am on IE8, winXp SP3. the below mentioned code doesn't work when the mahcine is locked. It does work though when it is unlocked.

WinWait("File Download")
WinActivate("File Download")
sleep(500)
ControlClick("File Download","","Button2") ; this clicks the default "save" button on the first dialog

WinWait("Save As") ; Wait for the "Save As" box to pop up
WinActivate("Save As")
sleep(500)

$filename=ControlGetText("Save As","Save &in:","Edit1") ;Get the file name before we erase it
ControlSetText("Save As","Save &in:","Edit1","") ; erase the file name to make room for the $dest string
sleep(1000)

ControlSetText("Save As","Save &in:","Edit1", $oDest) ; set the Edit1 text to the $dest and hit the button to swithc directories.
ControlClick("Save As","","Button2")
sleep(1000)

ControlSetText("Save As","Save &in:","Edit1", $sFileName) ; reset the name of the file to the original value.
sleep(1000)
ControlClick("Save As","","Button2")

Can some one please look and instruct?

regards

Link to comment
Share on other sites

A simple search of the forum would have given you the answer to this question because it gets asked about once a week.

http://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3F

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Why do you need such a script to be active all the time?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Hi BrewManNH,

tx for the response. I modified code but still when system is locked, it waits for SAVE button to be clicked. I have altered my script but still no good-

WinWait("File Download")
;WinActivate("File Download")

ControlSend ("File Download", "", "", "{Button2}")

sleep(500)
ControlClick("File Download","","Button2") ; this clicks the default "save" button on the first dialog

WinWait("Save As") ; Wait for the "Save As" box to pop up
ControlSend ("Save As", "", "", "{Button2}")
;WinActivate("Save As")
sleep(500)

$filename=ControlGetText("Save As","Save &in:","Edit1") ;Get the file name before we erase it
ControlSetText("Save As","Save &in:","Edit1","") ; erase the file name to make room for the $dest string
sleep(1000)

ControlSetText("Save As","Save &in:","Edit1", $oDest) ; set the Edit1 text to the $dest and hit the button to switch directories.
ControlClick("Save As","","Button2")
sleep(1000)

ControlSetText("Save As","Save &in:","Edit1", $sFileName) ; reset the name of the file to the original value.
sleep(1000)
ControlClick("Save As","","Button2")

Can u please check the code and guide me

regards

Link to comment
Share on other sites

Where exactly is it failing?

I see that you switched from using ControlClick to ControlSend, you shouldn't have changed that part of the script, that wasn't your problem. Your problem is that you can't use WinWaitActive/WinActivate on a locked machine.

I don't have any way to test this though as I don't have a Win XP machine around here, I haven't installed XP on any of my personal computers in years. I might be able to test something on one of the computers where I work, as they're still on XP for now.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hi,

I hv commented the winActivate line and replaced them with ControlSend.

It stops on this line -

ControlSend ("Save As", "", "", "{Button2}")

then it expects you to click th SAVE button.

Please try on XP and let me kow where the issue could be

tx again for ur time

Edited by adarsh12in
Link to comment
Share on other sites

I already told you, don't use ControlSend, use ControlClick. 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hi,

Doesn't work still. I have only controlclick now like you suggested. i am trying to debug by writing after every line to a separate txt file. that shows execution till the last line. but the handle waits on SAVE dialog box.  

Local $tDir ="C:"
Local $OLO = FileOpen($tDir& "test.txt", 2)

WinWait("File Download")
FileWrite($OLO, "test 63")
sleep(500)
ControlClick("File Download","","Button2") ; this clicks the default "save" button on the first dialog
FileWrite($OLO, "test 68")
sleep(500)
FileWrite($OLO, "test 73")
$filename=ControlGetText("Save As","Save &in:","Edit1") ;Get the file name before we erase it
ControlSetText("Save As","Save &in:","Edit1","") ; erase the file name to make room for the $dest string
sleep(1000)
FileWrite($OLO, "test 77")
ControlSetText("Save As","Save &in:","Edit1", $oDest) ; set the Edit1 text to the $dest and hit the button to switch directories.
ControlClick("Save As","","Button2")
sleep(1000)
FileWrite($OLO, "test 81")
ControlSetText("Save As","Save &in:","Edit1", $sFileName) ; reset the name of the file to the original value.
sleep(1000)
ControlClick("Save As","","Button2")
FileWrite($OLO, "test 85")
FileClose($OLO)

_IEQuit($oIE)

Link to comment
Share on other sites

What site are you downloading from? As I asked before, why do you need this to run when the system is locked.

Also, please use AutoIt tags (blue icon) when posting AutoIt code.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Moderators

adarsh12in,

I share guinness' concern over your requirement to download files when the machine is locked. So with my Mod hat firmly in place I am now asking you to explain why you need to do this. :huh:

Everyone else,

No more help please until we find out what is going on. :)

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

Here is the reason-

there needs to be automation as much as possible on producing reports. There is a GUI (.NET based within the org) where you have to manually log in and fill couple of options. Then, it generates report in excel based on the options selected. now, if the machine is on and such task is undertaken, it takes a long time and restricts the current user's ability. so, this report, which is needed every friday can be produced by AutoIT script in the absence of the user. I woul duse a windows scheduler to run the autoIT exe.

let me know if any further explanation is required. If there is better means to write the code in the background if the machine is not locked, i am happy with that as well.

Now if you are satisfied, can someone please correct my code!

Edited by adarsh12in
Link to comment
Share on other sites

  • Moderators

adarsh12in,

So you want be able to log in to an app on a locked machine and run it. :huh2:

Although I am not accusing you of any malicious intent, I hope that you can see that any such code could very easily be used by others who were less honest. So I am afraid that I am not at all satisifed that this thread should continue - with the obvious result. :(

I suggest that you speak to your IT department and they work out some way of producing this report without adversely affecting the "current user's ability" - whatever that means. After all, if the company wants the report, it is up to them to get it produced in a suitable manner. :)

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

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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