Sign in to follow this  
Followers 0
jamesch222

Function

22 posts in this topic

#1 ·  Posted (edited)

I would like to know the script to press "F1" and a msgbox would pop up on the screen.  Thanks

Edited..

Example

HotKeySet("{F1}", "Msgboxtest")

Func Msgboxtest()
    MsgBox(0,"Message","This is a message")
    EndFunc
 

Edited by jamesch222

Share this post


Link to post
Share on other sites



HotKeySet("{F1}", "Msgboxtest")


While 3
    ;Keep script alive.
    Sleep(333)
WEnd

Func Msgboxtest()
    MsgBox(0, "Message", "This is a message")
EndFunc   ;==>Msgboxtest

How would I be able to run 2 functions at one time, it seems when I run the 2nd function, it cancels out the first.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Adlibregister, or instead of directly calling msgbox, initiate another script that opens the msgbox (so your script won't be forced to wait for the message box to close)....helpfile, search for command line parameters.

Run(@AutoItExe & ' /AutoIt3ExecuteLine  "MsgBox(0, ''Hello World!'', ''Hi 1 !'')"')
Run(@AutoItExe & ' /AutoIt3ExecuteLine  "MsgBox(0, ''Hello World!'', ''Hi 2 !'')"')
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

AutoIt is not multi-threaded, so no running 2 functions at once. If you have multiple functions to call, you call them sequentially, or do something like this:

HotKeySet("{F1}", "Msgboxtest")
HotKeySet("{F2}", "Msgboxtest2")

While 3
    ;Keep script alive.
    Sleep(333)
WEnd

Func Msgboxtest()
    MsgBox(0, "Message", "This is a message")
EndFunc   ;==>Msgboxtest

Func Msgboxtest2()
    MsgBox(0, "Message", "This is another message")
EndFunc   ;==>Msgboxtest

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

Share this post


Link to post
Share on other sites

Global $iPid
HotKeySet("{F1}", "Msgboxtest")
HotKeySet("{F2}", "Msgboxtest2")
While 3
    ;Keep script alive.
    Sleep(333)
WEnd

Func Msgboxtest()
    Global $iPid = Run(@AutoItExe & ' /AutoIt3ExecuteLine  "MsgBox(0, ''Hello World!'', ''Hi 1 !'')"')
EndFunc   ;==>Msgboxtest

Func Msgboxtest2()
    If $iPid Then ProcessClose($iPid)
    Run(@AutoItExe & ' /AutoIt3ExecuteLine  "MsgBox(0, ''Hello World!'', ''Hi 2 !'')"')
EndFunc   ;==>Msgboxtest


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

 

AutoIt is not multi-threaded, so no running 2 functions at once. If you have multiple functions to call, you call them sequentially, or do something like this:

HotKeySet("{F1}", "Msgboxtest")
HotKeySet("{F2}", "Msgboxtest2")

While 3
    ;Keep script alive.
    Sleep(333)
WEnd

Func Msgboxtest()
    MsgBox(0, "Message", "This is a message")
EndFunc   ;==>Msgboxtest

Func Msgboxtest2()
    MsgBox(0, "Message", "This is another message")
EndFunc   ;==>Msgboxtest

hmm, is there anyway I can have it detect a certain "Text" that may pop up on the screen, that would cause it to stop all functions?

Share this post


Link to post
Share on other sites

jamesch222,

When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - we know what we wrote and it just pads the thread unnecessarily. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Maybe a little clarification on what exactly you're trying to do. All the questions seem rather broad, and we seem to be skipping about. Can you please define what application you're trying to manipulate, and exactly what you want to accomplish? It will greatly assist us in helping you.


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

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

For example, say a word would pop up at a certain area.  like  "Welcome" were to pop up in the middle of the screen.  when that "Welcome" were to pop up, I would like all function to stop so I could control it myself. (or the script to close)

I could also make it work if a color was detected in a specific area.

Edited by jamesch222

Share this post


Link to post
Share on other sites

jamesch222, that is the ambiguity I'm referencing - what causes the word to pop up? Is it a window in an application (if so, what app, or a screenshot of what it looks like), is it in a web page (if so, what web page or a screen shot)? A "certain word" can pop up on screen in a number of scenarios: an embedded control, a windows pop up, a message from a web page, etc. Just saying "if this certain word appears" doesn't really help us help you :)


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

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

AdlibRegister("CheckforWelcome")

Global $iPid
HotKeySet("{F1}", "Msgboxtest")
HotKeySet("{F2}", "Msgboxtest2")
While 3
    ;Keep script alive.
    Sleep(333)
WEnd

Func Msgboxtest()
    Global $iPid = Run(@AutoItExe & ' /AutoIt3ExecuteLine  "MsgBox(0, ''Welcome!'', ''Hi 1 !'')"')
EndFunc   ;==>Msgboxtest

Func CheckForWelcome()
    While WinGetHandle("[CLASS:#32770; REGEXPTITLE:.*[wW]elcome.*]","")
        HotKeySet("{F1}")
        HotKeySet("{F2}")
        Sleep(1000)
        ConsoleWrite("wait for user to close welcome window" & @CRLF)
    WEnd
    HotKeySet("{F1}", "Msgboxtest")
    HotKeySet("{F2}", "Msgboxtest2")
EndFunc

Func Msgboxtest2()
    If $iPid Then ProcessClose($iPid)
    Run(@AutoItExe & ' /AutoIt3ExecuteLine  "MsgBox(0, ''Hello World!'', ''Hi 2 !'')"')
EndFunc   ;==>Msgboxtest

Press F1

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

16ixph5.jpg

Say that text were to pop up on my screen, which would be a chatroom.

Is there a way to stop all functions (or close the script) when that were to pop up. (either by color, or text (prefer text)

Edited by jamesch222

Share this post


Link to post
Share on other sites

Now you are traveling into OCR realm, which is unreliable at best.

The best I've seen OCR work is 85-90% text recognition, and you need to know exactly where to look.

You can download sharepoint designer, and install MODI.  Examples scripts forum to see how it works.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Is it not easy to simply detect when that color were to pop up on a specific spot on the screen?

Like if it were to pop up on a specific pixel at the bottom of the screen, the script would detect the color "Found" and pause, or exit after seeing this color?

Share this post


Link to post
Share on other sites

You can look in the Help file under the Pixel functions, but they too are notoriously unstable. It is best to know the application, as each one is different in how you obtain and manipulate its controls.


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

Share this post


Link to post
Share on other sites
Global $color
 

PixelSearch(1057, 841, 1292, 848, $color)

Send("{ESC 1}")

would something like that work, if so. How to set the color?

Share this post


Link to post
Share on other sites

HotKeySet("{ESC}", "Terminate")

Func Terminate()
Exit 0
EndFunc

Local $iCheckSum = PixelChecksum(1057, 841, 1292, 848)

While $iCheckSum = PixelChecksum(1057, 841, 1292, 848)
    Sleep(100)
    Send("{ESC 1}")
WEnd

 

it seems to end instantly regardless of any changes on the screen.  any ideas?

Share this post


Link to post
Share on other sites

 

Global $color
 

PixelSearch(1057, 841, 1292, 848, $color)

Send("{ESC 1}")

would something like that work, if so. How to set the color?

Use the AutoIT window info tool to get the color...mouse tab when focused on your pixel.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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