AutoIt Help would be appreciated

  • Thread starter Thread starter Dos-Man
  • Start date Start date
D

Dos-Man

I'm searching through long listings produced by search engines.
Rather than me pressing PG DOWN every 30 seconds or so, I figure
I can use autoit to do it. I need a program (preferably compiled to
executable)
that has a start and stop button, that will send PG DOWN keystrokes
to the active browser window. Can anyone help me code this?

TYIA
Dos-Man

If I knew where
(I put Rapid-Q, this wouldn't be an issue...)
 
It is rather crude, but I got one working...


#include <GUIConstants.au3>

Global $var1

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
$mainwindow = GUICreate("Page Down", 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

$StopButton = GUICtrlCreateButton("Stop", 10, 20, 80)
GUICtrlSetOnEvent($StopButton, "StopButton")

$okbutton = GUICtrlCreateButton("Start", 10, 50, 80)
GUICtrlSetOnEvent($okbutton, "OKButton")

GUISetState(@SW_SHOW)


While 1
Sleep(1) ; Idle around
If $var1 > 0 Then
sleep(20000)
Send("{PGDN}")
EndIf
WEnd


Func StopButton()
;Note: at this point @GUI_CTRLID would equal $okbutton,and
@GUI_WINHANDLE would equal $mainwindow
$var1 = 0
EndFunc


Func OKButton()
;Note: at this point @GUI_CTRLID would equal $okbutton,
;and @GUI_WINHANDLE would equal $mainwindow
$Var1 = 1
EndFunc


Func CLOSEClicked()
;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
;and @GUI_WINHANDLE would equal $mainwindow
Exit
EndFunc
 
If anyone is interested, here is the finished program.

#include <GUIConstants.au3>

Global $var1

Opt("GUIOnEventMode", 1) ; Change to
OnEvent mode

$mainwindow = GUICreate("Page Down", 100, 100,) ; create the
main window
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; handle the
close event

$StopButton = GUICtrlCreateButton("Stop", 10, 20, 80) ; create Stop
Button
GUICtrlSetOnEvent($StopButton, "StopButton") ; Handle Stop
Button Event

GUICtrlSetState($StopButton,$GUI_DISABLE) ; Initially
disable stop button

$okbutton = GUICtrlCreateButton("Start", 10, 50, 80) ; Create the
start button
GUICtrlSetOnEvent($okbutton, "OKButton") ; Handle Start
Button event

GUICtrlSetState($OKButton,$GUI_FOCUS) ; put focus on
start button
GUISetState(@SW_SHOW) ; show the main window
WinSetOnTop("Page Down", "", 1) ; set the main
window to always on top

While 1
Sleep(1) ; Idle around
If $var1 > 0 Then ; if in Send Keystroke mode
sleep(20000) ; pause for 20 seconds
Send("{PGDN}") ; then send PGDN keystrokes to active window
EndIf
WEnd


Func StopButton()
;Note: at this point @GUI_CTRLID would equal $okbutton,and
@GUI_WINHANDLE would equal $mainwindow
$var1 = 0
GUICtrlSetState($StopButton,$GUI_DISABLE) ; disable stop button
GUICtrlSetState($OKButton,$GUI_ENABLE) ; enable start button
EndFunc


Func OKButton()
;Note: at this point @GUI_CTRLID would equal $okbutton,and
@GUI_WINHANDLE would equal $mainwindow
$Var1 = 1
GUICtrlSetState($StopButton,$GUI_ENABLE) ; enable the stop button
GUICtrlSetState($OKButton,$GUI_DISABLE) ; disable the start
button
EndFunc


Func CLOSEClicked()
;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,and
@GUI_WINHANDLE would equal $mainwindow
Exit
EndFunc


I gotta say it feels like old times :)

dos-man
 
Back
Top