Jump to content

Lemmens Peter

Active Members
  • Posts

    36
  • Joined

  • Last visited

Lemmens Peter's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. The progressbar starts counting down when the autoit-window has NO focus. (The autoit-window is not active, another window is active) When the autoit-window get the focus (Window is activated) the progressbar start all over (Starts from 100% again) The progressbar changes color when : higher than 66% : green between 33% and 66% : yellow lower than 33% : red The window flashes 3 times when passing 66% and 33% The autoit-window closes when it reaches 0 % #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.4.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; #include <GUIConstantsEx.au3> Global Const $GUI_HIDE = 32 Global Const $GUI_SHOW = 16 Global Const $GUI_EVENT_CLOSE = -3 ; #include <ProgressConstants.au3> Global Const $PBS_VERTICAL = 0x04 Global Const $PBM_SETSTATE = 0x0410 ; #Include <WinAPI.au3> Global Const $tagFLASHWINFO = "uint Size;hwnd hWnd;dword Flags;uint Count;dword TimeOut" Global Const $__WINAPICONSTANT_FLASHW_CAPTION = 0x00000001 Global Const $__WINAPICONSTANT_FLASHW_TRAY = 0x00000002 Global Const $__WINAPICONSTANT_FLASHW_TIMER = 0x00000004 Global Const $__WINAPICONSTANT_FLASHW_TIMERNOFG = 0x0000000C Dim $o_Percentage $Form1 = GUICreate("Progress Bar Exemple", 150, 450, -1, -1) $Progress1 = GUICtrlCreateProgress(10, 10, 10, 400, $PBS_VERTICAL) $Label1 = GUICtrlCreateLabel ( "---------------", 50, 225) GUICtrlSetFont ($Label1, 12, 600) GUISetState(@SW_SHOW) GUICtrlSetState($Progress1, $GUI_HIDE) $Start_Time = TimerInit() $Time_To_Wait = 30000 ; miliseconden GUICtrlSetData($Progress1, 100) Sleep(500) GUICtrlSetState($Progress1, $GUI_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch Sleep(10) If WinActive($Form1) Then $Start_Time = TimerInit() EndIf $Current_Time_Difference = TimerDiff($Start_Time) If $Current_Time_Difference > $Time_To_Wait Then ;ProgressSet(100, "Done!") Sleep(750) ;ProgressOff() Exit Else $Percentage = 100 - Round((100/$Time_To_Wait) * $Current_Time_Difference) GuiCtrlSetData($Label1, String($Percentage) & " %") GUICtrlSetData($Progress1, $Percentage) If $o_Percentage >= 100 Then _SendMessage(GUICtrlGetHandle($Progress1), $PBM_SETSTATE, 1) ; green EndIf If $o_Percentage >= 66 and $Percentage < 66 Then _SendMessage(GUICtrlGetHandle($Progress1), $PBM_SETSTATE, 3) ; yellow _WinAPI_FlashWindowEx($Form1, 3, 3, 200) EndIf If $o_Percentage >= 33 and $Percentage < 33 Then _SendMessage(GUICtrlGetHandle($Progress1), $PBM_SETSTATE, 2) ; red _WinAPI_FlashWindowEx($Form1, 3, 3, 100) EndIf $o_Percentage = $Percentage EndIf WEnd Func _SendMessage($hWnd, $iMsg, $wParam = 0, $lParam = 0, $iReturn = 0, $wParamType = "wparam", $lParamType = "lparam", $sReturnType = "lresult") Local $aResult = DllCall("user32.dll", $sReturnType, "SendMessageW", "hwnd", $hWnd, "uint", $iMsg, $wParamType, $wParam, $lParamType, $lParam) If @error Then Return SetError(@error, @extended, "") If $iReturn >= 0 And $iReturn <= 4 Then Return $aResult[$iReturn] Return $aResult EndFunc ;==>_SendMessage ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_FlashWindowEx ; Description ...: Flashes the specified window ; Syntax.........: _WinAPI_FlashWindowEx($hWnd[, $iFlags = 3[, $iCount = 3[, $iTimeout = 0]]]) ; Parameters ....: $hWnd - Handle to the window to be flashed. The window can be either open or minimized. ; $iFlags - The flash status. Can be one or more of the following values: ; |0 - Stop flashing. The system restores the window to its original state. ; |1 - Flash the window caption ; |2 - Flash the taskbar button ; |4 - Flash continuously until stopped ; |8 - Flash continuously until the window comes to the foreground ; $iCount - The number of times to flash the window ; $iTimeout - The rate at which the window is to be flashed, in milliseconds. If 0, the function uses the ; +default cursor blink rate. ; Return values .: Success - True ; Failure - False ; Author ........: Yoan Roblet (arcker) ; Modified.......: ; Remarks .......: Typically, you flash a window to inform the user that the window requires attention but does not currently ; have the keyboard focus. When a window flashes, it appears to change from inactive to active status. An ; inactive caption bar changes to an active caption bar; an active caption bar changes to an inactive caption ; bar. ; Related .......: _WinAPI_FlashWindow ; Link ..........: @@MsdnLink@@ FlashWindowEx ; Example .......: Yes ; =============================================================================================================================== Func _WinAPI_FlashWindowEx($hWnd, $iFlags = 3, $iCount = 3, $iTimeout = 0) Local $tFlash = DllStructCreate($tagFLASHWINFO) Local $pFlash = DllStructGetPtr($tFlash) Local $iFlash = DllStructGetSize($tFlash) Local $iMode = 0 If BitAND($iFlags, 1) <> 0 Then $iMode = BitOR($iMode, $__WINAPICONSTANT_FLASHW_CAPTION) If BitAND($iFlags, 2) <> 0 Then $iMode = BitOR($iMode, $__WINAPICONSTANT_FLASHW_TRAY) If BitAND($iFlags, 4) <> 0 Then $iMode = BitOR($iMode, $__WINAPICONSTANT_FLASHW_TIMER) If BitAND($iFlags, 8) <> 0 Then $iMode = BitOR($iMode, $__WINAPICONSTANT_FLASHW_TIMERNOFG) DllStructSetData($tFlash, "Size", $iFlash) DllStructSetData($tFlash, "hWnd", $hWnd) DllStructSetData($tFlash, "Flags", $iMode) DllStructSetData($tFlash, "Count", $iCount) DllStructSetData($tFlash, "Timeout", $iTimeout) Local $aResult = DllCall("user32.dll", "bool", "FlashWindowEx", "ptr", $pFlash) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc ;==>_WinAPI_FlashWindowEx I use indeed Windows 7 and the progressbar changes color ! @fett8802 and wakillon : Which OS do you use ?
  2. You could take a look at the following snippet : ... $Total_Size = InetGetSize($File_To_Download) InetGet($File_To_Download, $File_To_Save, 1, 1) While @InetGetActive sleep(250) $Mes_3 = "Downloading " & $File_name & " " & int((@InetGetBytesRead / $Total_Size) * 100) & " % completed..." TrayTip("Downloading ", $Mes_3, 10, 16) Wend ...
  3. Hi, I had the same problem and solved it by executing a script that 1. Disable the firewall-service (so it won't start again when rebooting the computer) 2. Stop the firewall-service The following script does the trick #NoTrayIcon Opt("TrayMenuMode",1) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess", "Start", "REG_DWORD", "4") RunWait(@ComSpec & " /c " & 'net stop "Windows Firewall/Internet Connection Sharing (ICS)"', "", @SW_HIDE) But you need to run it as an administrator on the computer itself (bummer...) So You create a script (exe) of the code above. Lets call it 'Disable_And_Stop_Firewall.exe' And need to create a new script (exe) that unpacks this 'Disable_And_Stop_Firewall.exe' and launch it as the administrator. The following script does this. #NoTrayIcon Opt("TrayMenuMode",1) FileInstall(".\Disable_And_Stop_Firewall.exe", ".\Disable_And_Stop_FW.exe", 1) Sleep(100) If RunAsWait("administrator", @computername, "administratorpasswordofthecomputer", 0, ".\Disable_And_Stop_FW.exe") = 0 and @error <> 0 Then Sleep(100) Run(@ComSpec & " /c " & $Command, @ScriptDir & "\", @SW_HIDE) EndIf Sleep(100) FileDelete(".\Disable_And_Stop_FW.exe") Sleep(100) I hope this will help, Best regards, Peter
  4. Hi everybody, I need your help. I need to create an AutoIt-script that has an embedded Internet Explorer. (I got this - see code) Problem 1 : But without the possibility to close it (no cross on the upper right corner of the application) Problem 2 : If the hidden text contains a specific text the application should close. Can anybody help me ? Thank you, Peter #NoTrayIcon Dim $objExplorer Dim $Win_Title $Site_URL = "http://Test:8080" $Site_Titel = "Test - Windows Internet Explorer" $objExplorer = ObjCreate("InternetExplorer.Application") $objExplorer.ToolBar = 0 $objExplorer.StatusBar = 0 $objExplorer.Width = @DesktopWidth $objExplorer.Height = @DesktopHeight $objExplorer.Left = 0 $objExplorer.Top = 0 $objExplorer.Visible = 1 $objExplorer.Navigate($Site_URL) While $objExplorer.busy Sleep(100) WEnd Sleep(5000) Local $HWND = WinGetHandle($Site_Titel) Local $sHWND = String($HWND) If WinGetState(HWnd($sHWND)) <> @SW_MAXIMIZE Then WinSetState(HWnd($sHWND), "", @SW_MAXIMIZE) EndIf While WinExists(HWnd($sHWND)) ; If hiddentext contains "Logout" exit while loop Sleep(500) WEnd
  5. Some time ago I had the same behavour. A "tab" was put in a notepad. I selected the tab (at time I didn't knew it was a tab) and pasted it in the "find" (of the notepad) I also got a little square. You might find out what it is by using asc() and chr()... Best regards, Peter
  6. Hi AutoIt-lovers, First of all: I'm also using the latest official version 3.3.0.0 and the help states there is a "16" 0 = Logoff 1 = Shutdown 2 = Reboot 4 = Force 8 = Power down 16= Force if hung 32= Standby 64= Hibernate Secondly : The script runs (with sheduled tasks using a user and password, etc) even when no user is logged on. The command "shutdown" return a 1 (Success). A line is added in the log-file saying "success" but the computer does NOT restart. So I think it's a bug. How can I report this as a bug ? I hope this helps to improve AutoIt because AutoIt IS a great scripting-tool Best regards, Peter
  7. Thank you very much for your answer. I will certainly try it. Best regards, Peter
  8. Yes, the script is fast enough to write to a log-file. Is there anyone wo knows why it does not shutdown when nobody is logged-on ? Am I doing something wrong ? Thanks and best regards, Peter
  9. wosteen, I got the same problem here : (shutdown does not work when not logged on) http://www.autoitscript.com/forum/index.php?showtopic=87572 I see you got a solution, but I don't get it. Would you be so kind to post the 'working' script please ? Thanx, Peter
  10. Hi, I wanted to create a script that shuts-down a computer everyday at 19:00. (End of workday) So I created a script and added it in the "scheduled tasks" to run. My script works correctly when the user is logged in (even when the computer is locked by a user) But my script DOES NOT work when nobody is logged in. To check what the script did, I add a comment-line to a log-file each time the script is executed. My script always says the shutdown was a success even when it did NOT shut-down (when nobody is logged on) Can it be a bug of am I missing something ? Best regards and thank you, Peter $Data_Title = StringLeft(@ScriptName, StringInStr(@ScriptName, "." ,0,-1)-1) $Log_File = @ScriptDir & "\" & $Data_Title & ".csv" Sleep(1000) If Shutdown(1 + 4 + 8 +16) = 1 Then ; 0 = Logoff; 1 = Shutdown; 2 = Reboot; 4 = Force; 8 = Power down; 16= Force if hung; 32= Standby; 64= Hibernate FileWriteLog($Log_File, @YEAR & "/" & @MON & "/" & @MDAY & ";" & @HOUR & ":" & @MIN & ";Shutdown;Success") ; If Shutdown is a success a line will be added to the log_File. Exemple of such a line : ; 2009/01/11;21:53;Shutdown;Success Else FileWriteLog($Log_File, @YEAR & "/" & @MON & "/" & @MDAY & ";" & @HOUR & ":" & @MIN & ";Shutdown;Failure") ; If Shutdown is NOT a success a line will be added to the log_File. Exemple of such a line : ; 2009/01/11;21:53;Shutdown;Failure EndIf Sleep(1000) Exit Func FileWriteLog($sLogPath, $sLogMsg) Local $hOpenFile Local $hWriteFile $hOpenFile = FileOpen($sLogPath, 1) If $hOpenFile = -1 Then SetError(1) Return 0 EndIf $hWriteFile = FileWriteLine($hOpenFile, $sLogMsg) If $hWriteFile = -1 Then SetError(2) Return 0 EndIf FileClose($hOpenFile) Return 1 EndFunc
  11. The answer is simple, just try I added $UDS_ARROWKEYS so it will also react on the buttons "up" and "down" GUICtrlCreateUpdown($Up_down_button,BitOr($UDS_ARROWKEYS,$UDS_NOTHOUSANDS)) Good luck, Peter
  12. Nice code ! Can anyone tell me how to detect when an item is selected (simply clicked or selected by using the arrows on the keyboard) - not doubleclicked ? This would be great ! Thanks, Peter
  13. You're right. The website is no longer correct. Strange... Try using : https://pronet.aspex.be/pronetEE/ * Using Internet explorer 7.0 and having installed the certificate. I got the correct website. (It's a website asking for a user and password) * Using the AutoIt 3.2.8.0 I got the message "navigation to the webpage was cancelled.What you can try : refresh the page" When I refresh the page I got the message "The page requires a client certificate..." (see exact message at the bottom) It's like not all functionalities are available when using the autoIt-Gui ... Regards, Peter <H1 style="FONT: 13pt/15pt verdana; COLOR: #000000">The page requires a client certificate</H1>The page you are trying to view requires the use of a client certificate.Please try the following: Click the Refresh button to try again, if you have installed your client certificate.If you believe you should be able to view this directory or page, please contact the Web site administrator by using the e-mail address or phone number listed on the pronet.aspex.be home page.<H2 style="FONT: 8pt/11pt verdana; COLOR: #000000">HTTP 403.7 - Forbidden: Client certificate requiredInternet Information Services</H2>Technical Information (for support personnel) Background: This error occurs when the resource you are attempting to access requires your browser to have a Secure Sockets Layer (SSL) client certificate that the server recognizes. More information: Microsoft Support
  14. Hi, Take a look at "GUICtrlSetResizing". It might be helpfull. Peter
  15. Hi everybody, I tried to make a GUI with an embedded IE site... It works fine for http://www.google.be (link 1) But it fails for https://pronet.aspex.be/pronetEE/ (link 2) because the website needs a certificate. I installed the certificate in Internet Explorer and link 2 works fine if tried in Internet Explorer but again does not work any more in the AutoIt-GUI. I think it has something to to with the line ObjCreate("Shell.Explorer.2") in the _IECreateEmbedded() function (IE.au3-file) I tried to replace it with ObjCreate("InternetExplorer.Application") but it fails also... Can anybody help please. Thanx, Peter #include <GUIConstants.au3> #include <IE.au3> _IEErrorHandlerRegister () $oIE = _IECreateEmbedded () $Gui = GUICreate("Pronet_NOK", @DesktopWidth/2, @DesktopHeight/2, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUIActiveX = GUICtrlCreateObj($oIE, -1, -1, @DesktopWidth/2, @DesktopHeight/2) GUISetState() GUICtrlSetResizing($GUIActiveX,1) _IENavigate ($oIE, "[url="https://pronet.aspex.be/pronetEE/"]https://pronet.aspex.be</SPAN>/pronetEE/[/url]") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() Exit
×
×
  • Create New...