
GrahamT
Active Members-
Posts
25 -
Joined
-
Last visited
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by GrahamT
-
Problems with _DateAdd and _DateSplit
GrahamT replied to GrahamT's topic in AutoIt General Help and Support
Brilliant - thanks very much! Graham -
I want to do the following: $NowTime = _NowCalc() $NewTime = _DateAdd( 'n',90, $nowTime) which works fine. But, then I want to extract from the $NewTime string, the time in hh:mm format. I'm sure I can do it with _DateSplit. but I can't figure out how. Any help appreciated. Thanks, Graham
-
I just dug out a program I wrote two years ago (using some ideas I found online), which used to work fine, to make some modifications to it. Its for controlling workstations in the computer lab at my school. I've recompiled it, with no changes, in the latest version of AutoIt. It used to work fine - now I get an error 1063 when I run it. What does this mean? I've tried running it normally, from the command line, as a service - same every time. Also, after the error message, I get the confirmation dialog, that the workstation is listening on port 31313, but when I try to ping the workstation it says the port is not open. I realise the dialog is not actually checking - its just reporting what is supposed to happen! Any ideas why it isn't working? Thanks. #include <service.au3> _Service_Init("LRCstudent_Service") TCPStartup(); Start up the TCP functions #NoTrayIcon; Hide the tray icon... so students don't know its running! $ipAddress = @IPAddress1 $portAddress = 31313 $MainSocket = TCPListen($ipAddress, $portAddress) MsgBox(4096, "Lab Remote Control", "Listening on IP: " & $ipAddress & " and PORT: " & $portAddress, 5) Func Main() While 1 Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket > 0 $err = 0 Do $msg = TCPRecv($ConnectedSocket, 512) $err = @error If StringLen($msg) Then ; go through the various messages to process them accordingly... If StringInStr($msg, "WINDOWSHAKE:") Then windowShake() ElseIf StringInStr($msg, "SCREENFLICKER:") Then screenFlicker() ElseIf StringInStr($msg, "SCREENBLANK:") Then screenToggle(1, 2) ElseIf StringInStr($msg, "SCREENRESTORE:") Then screenToggle(0, -1) ElseIf StringInStr($msg, "ALERTBOX:") Then Send("{SPACE}") $alertBoxText = StringReplace($msg, "ALERTBOX:", "") MsgBox(48, "", $alertBoxText, 10) ElseIf StringInStr($msg, "SHUTDOWN:") Then Shutdown(5) ElseIf StringInStr($msg, "REBOOT:") Then Shutdown(6) ElseIf StringInStr($msg, "LOGOFF:") Then Shutdown(4) ElseIf StringInStr($msg, "EXIT:") Then goAway() EndIf EndIf Until $err TCPCloseSocket($ConnectedSocket) WEnd EndFunc ; End of the main loop ; ---------------------------------------------------------------------- Func goAway() TCPShutdown() Exit EndFunc;==>goAway ; ---------------------------------------------------------------------- Func windowShake() ; Script to shake the current window... $windowArray = WinList() ; Set up some of the shake parameters $numShakes = 30 $shakeIntensity = 10 $shakeDelay = 20 For $i = 1 To $windowArray[0][0] ; Loop through to find the active window... and shake it... If $windowArray[$i][0] <> "" And isVisible($windowArray[$i][1]) And WinActive($windowArray[$i][0]) Then $posArray = WinGetPos($windowArray[$i][0]) ; Shake it! For $x = 1 To $numShakes If Random(0, 1) = 1 Then $shakeIntensity = $shakeIntensity * - 1 WinMove($windowArray[$i][0], "", $posArray[0] + $shakeIntensity, $posArray[1] + $shakeIntensity) Sleep(10) WinMove($windowArray[$i][0], "", $posArray[0], $posArray[1]) Next EndIf Next EndFunc;==>windowShake ; ---------------------------------------------------------------------- Func screenFlicker() Opt("WinTitleMatchMode", 4) $WM_SYSCommand = 274 $SC_MonitorPower = 61808 $Power_On = -1 $Power_Off = 2 ;$X = 1 $HWND = WinGetHandle("classname=Progman") DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, "int", $SC_MonitorPower, "int", $Power_Off) DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, "int", $SC_MonitorPower, "int", $Power_On) EndFunc;==>screenFlicker ; ---------------------------------------------------------------------- Func screenToggle($keyb, $change) Opt("WinTitleMatchMode", 4) $WM_SYSCommand = 274 $SC_MonitorPower = 61808 $HWND = WinGetHandle("classname=Progman") BlockInput($keyb) DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, "int", $SC_MonitorPower, "int", $change) EndFunc;==>screenToggle ; ---------------------------------------------------------------------- Func isVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc;==>isVisible
-
_Service_UDF v4 : Build your own service with autoit code
GrahamT replied to arcker's topic in AutoIt Example Scripts
Thanks for that - yes I think it was attempting to run. Anyway, I already found a freeware program which will install it as a service: RunAsSvc Graham -
_Service_UDF v4 : Build your own service with autoit code
GrahamT replied to arcker's topic in AutoIt Example Scripts
Anybody got any ideas on how to get this to work? Thanks -
_Service_UDF v4 : Build your own service with autoit code
GrahamT replied to arcker's topic in AutoIt Example Scripts
Great! That worked fine - and its now compiling properly. But, when I run it in Command Prompt window with -i on the end of the file name, I get Error 1063 The program runs - but its not showing in the services list. Thanks, Graham -
_Service_UDF v4 : Build your own service with autoit code
GrahamT replied to arcker's topic in AutoIt Example Scripts
This is just the code I need to run a program on the computers in my school, so the kids can't it stop from running! However, I can't get it to work. When I try to compile I get this error message C:\FREECOM\AutoIt3\GTs Programs\service.au3(178,7) : ERROR: main(): undefined function. main() ~~~~~^ I'm confused. My program doesn't have a Function called "main" - the main code is enclosed in a While/Wend loop. What do I do? Thanks, Graham -
This is part of a program I wrote to stop myself accidentally closing Outlook by clicking the Red "X". Worked fine, until I upgraded to Office 2007. I already made sure the path was to OFFICE12, but it still doesn't work. I presume the dll calls have changed . . . Opt("WinTitleMatchMode", 4) Run("C:\Program Files\Microsoft Office\OFFICE12\outlook.exe") WinWait("Outlook"); tried WinWaitActive also $calcHwnd = WinGetHandle("classname=rctrl_renwnd32"); got classname by using 'AutoIt Window Info' utility $menu = DllCall("user32.dll", "hwnd", "GetSystemMenu", "hwnd", $calcHwnd, "int", 0) DllCall("user32.dll", "int", "RemoveMenu", "hwnd", $menu[0], "int", 0xF060, "int", 0x0); SC_CLOSE Any ideas what I need to change? Thanks, G
-
Thats great!! Thanks very much for your help. G
-
Sorry to be dim with something so simple, but I can't get this one right. I have a folder (D:\database\old_data), and I want to list the subfolders in it in a combo box, so that I can choose one to copy the files from. I think I should be using _GUICtrlComboAddDir ( $h_combobox, $s_Attributes [, $s_file] ), but I just can't figure out the switches from the help file. The example given doesn't help me either. Any help appreciated. Thanks, Graham
-
How to access to Printer Properties Dialog box directly?
GrahamT replied to CH Ng's topic in AutoIt General Help and Support
Is there a way to use something similar to bring up the "Printing Preferences" dialog for a printer? Thanks, Graham -
I'm copying a whole folder from a server to a local hard drive using DirCopy, and I'd like a progress bar to show what's happening (as the folder is around 650Mb!) - similar to when I drag and drop it in Windows I get the time remaining showing. Can this be done? Thanks, Graham
-
If its any help, I wrote this little popup calendar program which copies the selected date to the clipboard so I can paste it into other programs, Word documents, for example. ; AutoIt: v3.1.1.113 (beta) ; Author: Graham Taylor (NIST) ; Name: Quick Calendar ; Version: v 1.0a ; Date: 23/03/2006 ; Function: Quick Calendar, which copies selected date to Clipboard #include <GUIConstants.au3> #Include <Date.au3> #NoTrayIcon GUICreate("Quick Calendar", 210, 210, (@DesktopWidth - 250), 100, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), $WS_EX_TOPMOST) $Date = GUICtrlCreateMonthCal("", 10, 10, 190, 150, $MCS_NOTODAY) ; MENU $mnuFile = GUICtrlCreateMenu("&File") $itmExit = GUICtrlCreateMenuItem("&Exit", $mnuFile) ; Copy to Clipboard $btnSendToClip = GUICtrlCreateButton("Copy to Clipboard", 55, 165, 100, 20) GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $btnSendToClip $TheDate = _DateTimeFormat( GUICtrlRead($Date), 2) ClipPut($TheDate) GUISetState(@SW_MINIMIZE, "Quick Calendar") Case $msg = $GUI_EVENT_CLOSE GUISetState(@SW_MINIMIZE, "Quick Calendar") Case $msg = $itmExit $sure = MsgBox(292, "Quick Calendar", "Are you sure you want to exit?", 10) If $sure = 6 Then ExitLoop EndSelect WEnd Exit
-
Regional Settings In Control Panel
GrahamT replied to GrahamT's topic in AutoIt General Help and Support
Thanks for all your help I couldn't get the Do . . Until loop to work properly, but I got this to work eventually: $Lang1 = "English (United Kingdom)" $Lang2 = "Thai" $prog = "C:\Program Files\LEXiTRON Dictionary\LEXiTRON.exe" $wDir = "C:\Program Files\LEXiTRON Dictionary\" ChangeIt($Lang2) ; change to Thai Run($prog, $wDir) ; Open the Dictionary WinWait("LEXiTRON") ; pause until the program opens WinWaitClose("LEXiTRON") ; and until it closes! ChangeIt($Lang1) ; change back to English ; Function to change the language Func ChangeIt($lang) Run("rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,0") WinWait("Regional and Language Options", "Regional Options") WinActivate("Regional and Language Options", "Regional Options") WinWaitActive("Regional and Language Options", "Regional Options") Send($lang & "{Enter}") EndFunc ;==> Not very pretty, and rather slow - and I've tried everything to get the Regional Options Dialog to hide, but it won't. Anyway, at least I can use my dictionary now Graham -
Stopping A Program From Closing
GrahamT replied to GrahamT's topic in AutoIt General Help and Support
Brilliant! It looks like there is something I can work on there. Thanks, G -
Hi, Is there a way of stopping a program like MS Outlook from closing when someone clicks on the red "X" at the top right, and having it minimise to the Task tray instead. I've stopped it exiting, but only by putting a "fake" email in the outbox, which won't send. Cheers, Graham
-
Regional Settings In Control Panel
GrahamT replied to GrahamT's topic in AutoIt General Help and Support
Changing the Regional Options doesn't require a restart, at least not after you've done it once and everything is installed. Thanks for replying anyway. -
I have a Thai/English Dictionary program, which will only show the correct characters on the screen if the Regional Settings -> Regional Options is set to Thai. I keep it set to English (United Kingdom) for two reasons, I want to have my spelling checker "correct", and as far as I'm concerned, the year is CE 2006, not BE 2549. How, using AutoIt, can I change the regional options to Thai, then run the software, and then reset the Regional Options when the dictionary program exits? Any help appreciated. Thanks, Graham
-
Hi, I understand your problem, I'm a teacher too! Although it won't fool them for very long, you can stop a program showing in the task tray by including this line: #NoTrayIcon at the beginning of the program. If they go to Task Manager they will see it, but it might put them off working out which is your program. Cheers, Graham
-
Thats great - thanks very much for your help! Graham
-
I am using a List box from which I select individual lines of text, to build up a larger block of text in an EditBox. I don't want a horizontal scroll bar, I want the text to wrap when it reaches the right-hand side of the EditBox. I just can't find out how to do it. Any ideas? Thanks, Graham
-
I'm writing a utility to control the computers in a Student lab at my school - to be able to do things like shutdown/logoff/reboot all the workstations from the teacher's computer, I have a function which uses "TCPConnect" to connect to logged-in workstations. Func SetupConnections() ProgressOn("TCP/IP Connection Progress", "Attempting Connections:", "Workstation") For $station = 1 to $numStation $state = "Connected" $i = 100/$numStation * $station $IPAddress = "192.168.15." & $station $connectedSocket[$station] = TCPConnect($IPAddress, $portAddress) If @error Or $connectedSocket[$station] < 1 Then $state = "Failed" ProgressSet( $i, "Workstation " & $station & " (" & $IPAddress & ") : " & $state) Next sleep(500) ProgressSet(100 , "Done", "Complete") sleep(1000) ProgressOff() EndFunc 1 I want to run a client program on the workstations, so that the workstation is "listening" for a connection, even if nobody is logged in at the workstation. Is this possible? Can I run my client program as a Windows Service? 2 At the moment, if a workstation is not logged in, the function takes less than a second to bring up the "failed" message. However, if a workstation is actually switched off, it takes up to ten seconds before it times out and shows the "failed" message. Is there any way of speeding this up. Thanks, Graham New International School of Thailand
-
Been working on it for the last three days, and finally got a workable program! Thanks for the link to Office Poltergeist - the code in that taught me a lot!! Blockinput(1), interestingly, doesn't seem to totally block the keyboard. After putting the computer in Monitor "Off" mode, a key press will bring back the screen, but the keyboard is then locked. I basically used "For -> Next" loops and an array to create the TCP connections to all the workstations: Func SetupConnections() For $station = 1 to $numStation $IPAddress = "192.168.15." & $station $connectedSocket[$station] = TCPConnect($IPAddress, $portAddress) If @error Or $connectedSocket[$station] < 1 THEN MsgBox(64, "TCP/IP Problem", "Could not connect to IP: " & $ipAddress & " and PORT: " & $portAddress, 1) EndIf Next ;MsgBox(64,"Ready", "TCP/IP Connections Ready", 5) EndFunc and then another loop to send the commands: Func SendToAll($wsMsg) For $station = 1 to $numStation TCPSend($connectedSocket[$station],$wsMsg) Next EndFunc Thanks for all your help. Graham
-
Thanks for the ideas - whether or not I get around to it in AutoIT depends on how much time I get to do this. Anyway, some other avenues to explore as well. G
-
I've been looking for a program for the computer labs at my school, to do one specific thing - blackout the screen on the students' computers, at the click of a button on the teachers computer. Another click of the button to bring the screens back on. Software is available, but is very expensive. Would such a thing be possible using AutoIt? Thanks, Graham New International School of Thailand