Jump to content

Mucho

Active Members
  • Posts

    51
  • Joined

  • Last visited

Mucho's Achievements

Wayfarer

Wayfarer (2/7)

1

Reputation

  1. Thanks to the two gentlemen @SmOke_N and @Andreik for helping.
  2. I just need to do this simple work but it gave the error $CMD = "ipconfig /flushdns" Runas(@ComSpec & " /c " & $CMD, @SystemDir, @SW_HIDE)
  3. @Jfish, I found that the following countdown timer code is more suitable for me as it allows for the input of hours, unlike the previous one. #NoTrayIcon #include <TrayConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Date.au3> #include <Sound.au3> Opt("MustDeclareVars", 1) ; removes the chance for misspelled variables causing bugs. Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode. Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode. Opt("GUIOnEventMode", 1) ; OnEvent functions notifications Global $seconds = 0, $g_sec, $g_min, $g_hr, $EndTime, $projectedFinish, $seconds, $T, $InitialT, $started = False, $sec = 99, $aTimeHold[3], $g_IsAlarm = 0, $iAppTitle, $sAppTitle = timerTitle() $iAppTitle = @extended #Region ### START Koda GUI section ### Form=\\WDMYCLOUDEX4100\Public\[FMIS]\au3_Shared_projects\timerThing.kxf Global $Form1 = GUICreate($sAppTitle, 245, 120, @DesktopWidth - 275 - (40 * $iAppTitle), 20 + (40 * $iAppTitle), -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)) Global $idHour = GUICtrlCreateInput("00", 5, 4, 49, 32, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) Global $idMin = GUICtrlCreateInput("00", 58, 4, 49, 32, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) Global $idSec = GUICtrlCreateInput("00", 110, 4, 49, 32, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) Global $idStart = GUICtrlCreateButton("Start Timer", 163, 6, 75, 61, $BS_MULTILINE) Global $idTitle = GUICtrlCreateInput("", 4, 40, 129, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_WANTRETURN)) Global $idAlarm = GUICtrlCreateCheckbox("", 137, 53, 17, 19, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_RIGHTBUTTON)) Global $idInsist = GUICtrlCreateCheckbox("", 137, 37, 17, 19, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_RIGHTBUTTON)) Global $idEndTime = GUICtrlCreateLabel("End Time :", 5, 90, 125, 30) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetFont($idHour, 14, 800) GUICtrlSetFont($idMin, 14, 800) GUICtrlSetFont($idSec, 14, 800) GUICtrlSetFont($idStart, 12, 800) GUICtrlSetFont($idTitle, 12, 800) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUICtrlSetOnEvent($idStart, "idStartClick") GUICtrlSetOnEvent($idTitle, "idTitleChange") GUICtrlSetOnEvent($idAlarm, "idAlarmEvent") TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "OnTray_PRIMARYDOUBLE") GUICtrlSetTip($idStart, 'press ENTER or click' & @CR & @CR & 'once started, on close,' & @CR & 'will move to the tray area.') GUICtrlSetTip($idHour, 'Hours' & @CR & @CR & 'enter the hours' & @CR & 'and press ENTER') GUICtrlSetTip($idMin, 'Minutes' & @CR & @CR & 'enter the minutes' & @CR & 'and press ENTER') GUICtrlSetTip($idSec, 'Seconds' & @CR & @CR & 'enter the seconds' & @CR & 'and press ENTER') GUICtrlSetTip($idTitle, 'Type a title for this' & @CR & 'timer and press ENTER') GUICtrlSetTip($idAlarm, 'Swap between' & @CR & 'Timer and Alarm' & @CR & 'functionality') GUICtrlSetTip($idInsist, 'Replay the alert' & @CR & 'every 10 sec.' & @CR & 'for 10 min.') ;~ If Not FileGetSize("timerThing.wav") Then FileInstall("timerThing.wav", "timerThing.wav") ; if you wanna include your WAV file Global $hForm1 = WinGetHandle($Form1) Global $idDummy = GUICtrlCreateDummy() Global $aAccelKeys[1][2] = [["{Enter}", $idDummy]] GUISetAccelerators($aAccelKeys) GUICtrlSetOnEvent($idDummy, "On_idDummy") While 1 Sleep(50) If Not $started Then ContinueLoop If $sec = @SEC Then ContinueLoop $sec = @SEC Countdown() WEnd Func Form1Close() If $started Then TraySetState(1) WinSetState($hForm1, "", @SW_HIDE) Else GUIDelete() Exit EndIf EndFunc ;==>Form1Close Func Countdown() ; mod. from https://www.autoitscript.com/forum/topic/135227-simple-counter/?do=findComment&comment=950305 If $g_IsAlarm Then If Int(GUICtrlRead($idHour)) = Int(@HOUR) And Int(GUICtrlRead($idMin)) = Int(@MIN) And Int(GUICtrlRead($idSec)) = Int(@SEC) Then $seconds = -1 Else Return EndIf EndIf $g_sec = Mod($seconds, 60) $g_min = Mod($seconds / 60, 60) $g_hr = Floor($seconds / 60 ^ 2) If $seconds < -3 Then Return TrayToolTip() $seconds -= 1 If $seconds = -2 Then GUICtrlSetState($idInsist, $GUI_DISABLE) If GUICtrlRead($idInsist) = 1 Then $seconds = -5 InsistPlayTheWAV() AdlibRegister("InsistPlayTheWAV", 10000) Else playTheWAV() EndIf Return EndIf If $seconds < -1 Then Return GUICtrlSetData($idHour, StringFormat("%02i", $g_hr)) GUICtrlSetData($idMin, StringFormat("%02i", $g_min)) GUICtrlSetData($idSec, StringFormat("%02i", $g_sec)) EndFunc ;==>Countdown Func playTheWAV() OnTray_PRIMARYDOUBLE() WinActivate($hForm1) If Not FileGetSize(@ScriptDir & "\timerThing.wav") Then SoundSetWaveVolume(25) SoundPlay(@WindowsDir & "\media\tada.wav") Else SoundSetWaveVolume(5) SoundPlay(@ScriptDir & "\timerThing.wav") EndIf EndFunc ;==>playTheWAV Func InsistPlayTheWAV() Local Static $t = 0 If $t = 0 Then $t = TimerInit() playTheWAV() If TimerDiff($t) > 600000 Then AdlibUnRegister("InsistPlayTheWAV") $t = 0 EndIf EndFunc ;==>InsistPlayTheWAV Func TrayToolTip() Local $title = $sAppTitle If GUICtrlRead($idTitle) Then $title = GUICtrlRead($idTitle) TraySetToolTip('' & _ $title & @CR & _ GUICtrlRead($idHour) & ":" & GUICtrlRead($idMin) & ":" & GUICtrlRead($idSec) & @CR & @CR & _ 'Double' & @CR & _ 'Click to' & @CR & _ 'restore' & @CR & @CR & ' ') EndFunc ;==>TrayToolTip Func idStartClick() Local $title = $sAppTitle If GUICtrlRead($idTitle) Then $title = GUICtrlRead($idTitle) WinSetTitle($hForm1, "", $title) $sec = 99 $started = Not $started Switch $started Case True GUICtrlSetData($idStart, StringReplace(GUICtrlRead($idStart), "Start", "STOP")) $seconds = (Int(GUICtrlRead($idHour)) * 60 * 60) + (Int(GUICtrlRead($idMin)) * 60) + Int(GUICtrlRead($idSec)) $aTimeHold[0] = StringFormat("%02i", GUICtrlRead($idHour)) $aTimeHold[1] = StringFormat("%02i", GUICtrlRead($idMin)) $aTimeHold[2] = StringFormat("%02i", GUICtrlRead($idSec)) ; $InitialT = TimerInit() AdlibRegister("Timer") ;THIS IS THE PART THAT SHOWS THE PROJECTED FINISH $projectedFinish= round(($seconds + TimerDiff($InitialT)),0) GUICtrlSetData($idEndTime,"End Time : "& _DateAdd ( 's', $projectedFinish,_NowCalc())) GUICtrlSetState($idStart, $GUI_FOCUS) GUICtrlSetState($idHour, $GUI_DISABLE) GUICtrlSetState($idMin, $GUI_DISABLE) GUICtrlSetState($idSec, $GUI_DISABLE) GUICtrlSetState($idAlarm, $GUI_DISABLE) Case Else GUICtrlSetData($idStart, StringReplace(GUICtrlRead($idStart), "STOP", "Start")) GUICtrlSetData($idHour, $aTimeHold[0]) GUICtrlSetData($idMin, $aTimeHold[1]) GUICtrlSetData($idSec, $aTimeHold[2]) GUICtrlSetState($idHour, $GUI_ENABLE) GUICtrlSetState($idMin, $GUI_ENABLE) GUICtrlSetState($idSec, $GUI_ENABLE) GUICtrlSetState($idAlarm, $GUI_ENABLE) GUICtrlSetState($idInsist, $GUI_ENABLE) GUICtrlSetState($idStart, $GUI_FOCUS) GUICtrlSetData($idEndTime, $GUI_ENABLE) EndSwitch AdlibUnRegister("Timer") EndFunc ;==>idStartClick Func On_idDummy() Local $i, $s = ControlGetFocus($hForm1) $i = Int(StringRight($s, 1)) If $s = "Button1" Then Return ControlClick($hForm1, "", "Button1") If StringInStr($s, "Edit") Then Switch $i Case 1, 2, 3 Send("{Tab}") EndSwitch EndIf EndFunc ;==>On_idDummy Func idTitleChange() Local $title = $sAppTitle If GUICtrlRead($idTitle) Then $title = GUICtrlRead($idTitle) WinSetTitle($hForm1, "", $title) EndFunc ;==>idTitleChange Func timerTitle() Local $n, $i = 0 For $n = 1 To 1000 If Not WinExists(" Timer thing [" & $n & "]") Then AutoItWinSetTitle(" Timer thing [" & $n & "]") $i = $n - 1 If 40 * $n > @DesktopHeight - 150 Then $i = 1 Return SetError(0, $i, " Timer " & $n) EndIf Next Return SetError(1, $i, " Timer ???") EndFunc ;==>timerTitle Func OnTray_PRIMARYDOUBLE() TraySetState(2) WinSetState($hForm1, "", @SW_SHOW) EndFunc ;==>OnTray_PRIMARYDOUBLE Func idAlarmEvent() ConsoleWrite('+ Func idAlarmEvent() : ' & GUICtrlRead($idAlarm) & @CRLF) If GUICtrlRead($idAlarm) = 1 Then $g_IsAlarm = 1 GUICtrlSetData($idStart, StringReplace(GUICtrlRead($idStart), "Timer", "Alarm")) $sAppTitle = StringReplace($sAppTitle, "Timer", "Alarm") Else $g_IsAlarm = 0 GUICtrlSetData($idStart, StringReplace(GUICtrlRead($idStart), "Alarm", "Timer")) $sAppTitle = StringReplace($sAppTitle, "Alarm", "Timer") EndIf idTitleChange() EndFunc ;==>idAlarmEvent However, if I clicked on 'Stop Timer', the 'End Time' is strangely replaced with '64'. How to correct the error?
  4. That solves my problem. Thank you.
  5. I got this countdown timer script and I am trying to improve on it by adding the minutes and seconds entries to show the expected time when the countdown reaches 0. #include <GUIConstants.au3> #include <Date.au3> Global $Secs, $Mins, $Hour, $Time, $InitialT, $TargetT GUICreate("Timer", 200, 150) $MinIn = GUICtrlCreateInput("000", 70, 10, 30, 20, $ES_NUMBER) $label = GUICtrlCreateLabel(":", 101, 12) $SecIn = GUICtrlCreateInput("00", 105, 10, 30, 20, $ES_NUMBER) $start = GUICtrlCreateButton("Start", 75, 50, 50, 30) $timeLabel = GUICtrlCreateLabel("00:00:00", 80, 20) $EndTime = GUICtrlCreateLabel("End Time :", 35, 100, 70, 30) GUICtrlSetState($timeLabel, $GUI_HIDE) GUISetState(@SW_SHOW) $started = 0 While 1 ;After every loop check if the user clicked something in the GUI window $msg = GUIGetMsg() Select ;Check if user clicked on the close button Case $msg = $GUI_EVENT_CLOSE ;Destroy the GUI including the controls GUIDelete() ExitLoop Case $msg = $start If GUICtrlRead($start) == "Start" Then StartTimer() Else StopTimer() EndIf EndSelect WEnd Exit Func StartTimer() GUICtrlSetData($start, "Stop") GUICtrlSetState($MinIn, $GUI_HIDE) GUICtrlSetState($label, $GUI_HIDE) GUICtrlSetState($SecIn, $GUI_HIDE) GUICtrlSetState($timeLabel, $GUI_SHOW) $InitialT = TimerInit() $TargetT = (GUICtrlRead($MinIn) * 60 + GUICtrlRead($SecIn)) *1000 AdlibRegister("Timer") EndFunc ;==>StartTimer Func StopTimer() GUICtrlSetData($start, "Start") GUICtrlSetState($MinIn, $GUI_SHOW) GUICtrlSetState($label, $GUI_SHOW) GUICtrlSetState($SecIn, $GUI_SHOW) GUICtrlSetState($timeLabel, $GUI_HIDE) AdlibUnregister() EndFunc ;==>StartTimer Func Timer() $TimeLeft = $TargetT - TimerDiff($InitialT) If $TimeLeft > 0 Then _TicksToTime(Int($TimeLeft), $Hour, $Mins, $Secs) ; save current time to be able to test and avoid flicker.. Local $sTime = $Time $Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTime <> $Time Then GUICtrlSetData($timeLabel, $Time) Else ; Do something here StopTimer() EndIf EndFunc ;==>Timer I am not code savvy, but I need this function to work for me after I could not find any app on Googleplay that could fulfil my need. So I appreciate any help.
  6. UEZ, It does not even test either of the two conditions. BitAND(WinGetState($Chartlist[1][1]), 16) does not seem to work; it does not see that the chart is minimized, although BitAND(WinGetState($Chartlist[1][1]), 2) is ok. I do not have this problem in my office computer.
  7. So I tried Kovacic's suggestion as follows: The array variable error is still there if there is no detached chart, that is to say no chart in the array. If there is a minimized detached chart, then the error disappears, the script works fine.
  8. I know it is caused by an empty array, but can someone help me with the correct coding?
  9. The script works on a charting program. Basically, if a chart is Detached but Not minimized, maximize and process it; else, Process another attached chart which is attached to the main layout. Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",2) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",1) Opt("TrayIconHide", 0) Opt("TrayIconDebug", 1) #include <Date.au3> #include <File.au3> #include <Array.au3> #include <Misc.au3> Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "On_Exit") Dim $ChartList If WinExists("Advisor Professional v","") = False then Exit $ChartList = WinList ("", "Processing data") If $Chartlist[1][0] <> "" And BitAND(WinGetState($ChartList[1][1]), 16) then ;IsMinimized($Chartlist[1][0]) Then MsgBox($MB_SYSTEMMODAL, "Wait", "A chart is either minimized or not detached. Process Attached Chart", 1) _WinWaitActivate("Advisor Professional v","") Else ;( Detached Chart ) MsgBox($MB_SYSTEMMODAL, "Wait", "Process Detached Chart that is not minimized", 1) WinSetState ($ChartList[1][0], "", @SW_MAXIMIZE) MouseClick("left", 130, 40, 1,0) EndIf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func On_Exit() Exit 0 EndFunc Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc The executions of their respective conditions are being simplified here. I run the script off the quicklaunch. The problem is that it recognizes the detached chart only once, which is the first time. The first time, it recognizes that there is a detached chart that is minimized and so ignores it and processes the attached chart, which is correct, as in the office computer. On the second run, it fails to recognize that the detached charts are minimized and goes to the second condition, displaying the message, " "Process Detached Chart that is not minimized"but without maximizing it, when my script clearly winsetstates it to maximum. On the third run, it comes back to recognizing the detached chart, so processes the attached chart correctly. On the fourth, it fails again, and so on with subsequent runnings, alternating between the two conditions. And to get the script back to working normally, I have to switch to another program's window like my browser and back to my charting program again. But it works only once, again. I do not have this strange problem with the same script on my office computer. I hope I have explained my problem with clarity. If not, please query. I need all help.
  10. Universalist, Thank you!
  11. Been using the program for some years and today tried to compile after some changes to program but got the following error. So I installed the latest version of Autoit today but still got the same error. I'm stumped. Pls help.
  12. Mbalzeshari, Using the examples you supplied and substituting my company's intranet address (of the window opened by the IELinkClickbyText at the second level) at the _IECreate function, I got "0" forms from both Msgboxes. There are actually 58 or more links on the page. Here are some of the Window Info for what it is worth.
  13. When I use _IEGetLink, I got zero link. I made the following modification, setting the address of the new window to $oIE and then try to _IELinkClickByText. It did not work, apparently that is not how it is done. ; Third Level _WinWaitActivate("Report - ABC - Windows Internet Explorer","") $var = ControlGetText("[CLASS:IEFrame]", "", "Edit1") $oIE = _IEAttach($var,"url") _IELinkClickByText ($oIE, "eReport") I know _IELinkClickByText works with _IECreate. Is there a way to use the address of the new window that is opened with a click to work with something like _IECreate? By the way, my company is using IE10, with Mcafee.
  14. Hi, I cannot find any good example on this forum and the web to follow, so I hope someone can help. I'm trying to navigate down my company's website. I successfully use _IELinkClickByText to open the first link ("Today's Events") which opens a page with a different address. Then I need to click on another link ("Meetings") on this new page to get to my destination but I cannot get it right, probably due to wrong function. I cannot use _IENavigate as the address link of "Meetings" can change. #include <IE.au3> ;Main Page $oIE =_IECreate ("http://abc/xyz/", 0, 1, 1, 1) WinSetState("Report - ABC - Windows Internet Explorer","",@SW_MAXIMIZE) Send("{Enter}") ;Login ; Second Level _WinWaitActivate("ABC Intranet Systems - Windows Internet Explorer","") _IELinkClickByText ($oIE, "Today's Events") ;Click on this link after logging in. ; Third Level _WinWaitActivate("Report - ABC - Windows Internet Explorer","") $oIE = _IEAttach ("Report - ABC - Windows Internet Explorer","", "url") ; I want to click on "Meetings", the addess of which is not constant. _IELinkClickByText ($oIE, "Meetings") #region --- Internal functions Au3Recorder Start --- Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc
×
×
  • Create New...