Sign in to follow this  
Followers 0
EmptySpace

Newbie help for hotkeys and few other easy things

7 posts in this topic

I just wrote some basic script like this

#include <IE.au3>
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d
;;;; Body of program would go here ;;;;
$oIE = _IECreate("link")

$i = 0
Do
    _IELinkClickByText ($oIE, "text")
SLEEP(10)
    $i = $i + 1
Until $i = 1000
;;;;;;;;
Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc
Func Terminate()
    Exit 0
EndFunc
Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

Its basic clicker for example.

Firstly these hotkeys works fine but its not too much code? I saw thats its possible to make it more basic with few lines.

Secnodly I want to make one more hotkey, when I press it, it starts doing other thing and so on. Its possible to make that?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Yes, just do it like the hotkeys you already have.

I don't see much that can be shortened.

Maybe a different loop and $i = $i +1 could be $i += 1

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Xeno, maybe he's looking for something like your function :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

I used loop that looked easest to me. I made 3loops in one so big mess... Anyway im happy that this is working!

$i = $i +1 could be $i += 1 ----> It will make my script faster or what?

Also its possible to search for text in browser window? And if there is text do smthg?

(sorry for my bad english)

Share this post


Link to post
Share on other sites

Xeno, maybe he's looking for something like your function :)

I think im searchng that but dont understand it... :/

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Sorry for mulltiple post. Maybe I cuold use

StringInStr? Its possible to do like

#include <IE.au3>
$oIE = _IECreate ("www.google.com")
If StringInStr($sText,"text") Then _IELinkClickByText ($IE, "Security")

I get error about variable :/ I dont understand these variables when I have to use it when not ...

Edit: Iwill only ask questions after google search. I think it will work

; Read the contents of the body of a webpage and search for a string. If the string is found, replace it
; with a new string and write it back to the webpage.
#include <IE.au3>
$oIE = _IECreate()
_IENavigate($oIE, "http://www.autoitscript.com/")
$body = _IEBodyReadHTML($oIE)
If StringInStr($body, "automation") Then
    MsgBox(0, "Success", "The string was found")
    $newbody = StringReplace($body, "automation", "AUTOMATION - Yeah!")
    _IEBodyWriteHTML($oIE, $newbody)
Else
    MsgBox(0, "Fail", "The string was NOT found")
EndIf
Exit
Edited by sirfearless

Share this post


Link to post
Share on other sites

You mean something like this?

; Read the contents of the body of a webpage and search for a string. If the string is found, replace it
; with a new string and write it back to the webpage.
#include <IE.au3>
Global $sMyString = "Image"
Global $sUrl = "http://www.google.de/#sclient=psy-ab&hl=de&site=&source=hp&q=sirfearless+site:www.autoitscript.com&pbx=1&oq=sirfearless+site:www.autoitscript.com&aq=f&aqi=&aql=&gs_sm=e&gs_upl=681l681l0l1813l1l1l0l0l0l0l164l164l0.1l1l0&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=bc7df6d7bcac9ef4&biw=1184&bih=687"
Global $oIE = _IECreate($sUrl, 0, 1, 1, 1)
Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
For $oLink In $oLinks
;~  ConsoleWrite($oLink.href & @LF)
;~  ConsoleWrite(_IEPropertyGet($oLink, "innerText") & @LF)
If StringInStr($oLink.href, $sMyString) Then
  ConsoleWrite($oLink.href & @LF)
  ConsoleWrite(_IEPropertyGet($oLink, "innerText") & @LF)
  _IEAction($oLink, "click")
EndIf
Next

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0