Jump to content

Get paid to help me with a basic script!


Recommended Posts

Hello Forum!

I'm looking to create a basic script to automate some tasks at work but I'm not a a programmer. I will outline below what I'm looking for and the rates I'd be paying:-

1. A compiled script that will wait in the background until a shortcut ("CTRL" + "ALT" + "P") is pressed.

2. The script will then simulate pressing "ALT" + "F" to open the 'File' menu of a program I will have open (MicroStation for anyone familiar with it) then simulate pressing "Z" to open the 'Print Organizer' dialogue box.

3. It will then click two precise XY mouse locations to bring up a file dialogue box, as the buttons required to do this do not have keyboard shortcuts (if there is another way to do this let me know).

4. It will then wait for me to click the 'Done' button of the file dialogue box then click another 4 locations/buttons that do not have keyboard shortcuts.

5. If a certain error box occurs it will press "ENTER"

6. It will then press "ALT" + "F" to open another 'File' menu, then "P" to open Print dialogue box.

7. It will then press another button/location without a shortcut, and press down 9 times before finally clicking two more buttons/locations.

Once I have code that works I'll pay AUD$20 to whoever made the best contribution to the thread/script in my mind.

Link to comment
Share on other sites

really? naaa....you can do this yourself in 5 minutes. This isn't hard. Take AutoIt 1 2 3. It can be found in the example section of the forum. Once you take this short class I know you can crank this out in a jiffy.

We like teaching to fish, not handing out fish. Capish?

Link to comment
Share on other sites

While waiting for a real coder I've started on this myself, not as difficult as I thought maybe I can do it after all. :)

Below is the code I have got, features I still havn't been able to implement are automatically minimising the program to the tray when it opens, waiting for CTRL ALT P before running the script, and pausing mid script, and waiting for the ENTER key before resuming. $5 for each option? You guys don't like money lol

;.exe will be opened on startup and minimised to tray, not working.
;

;Wait for CTRL ALT P before running script, not working.
;

;Activate MicroStation window, working.
Opt("WinTitleMatchMode" ,2)
WinActivate ("MicroStation V8i (SELECTseries 2) (1)")

;Hold ALT, press F, release. Press Z. This is also working.
Send("!F")
Send("Z")

;Add Files to Set button, working.
MouseClick ( "left", 2185, 180 ,1, 10)

;Add button, working.
Send("{TAB}")
Send("{Enter}")

;wait for ENTER key, not working
;

;Activate Create Print Definitions and set Print style name:, working enough.
WinActivate ("Create Print Definitions")
Send("{TAB 5}")
Send("{Enter}")

;Activate Print Organizer and print, working enough but can't choose colour/BW yet
WinActivate ("Print Organizer")
Send("!F")
Send("P")
Send("{TAB 3}")
Send("{Enter}")
Send("{DOWN 9}")
Send("{TAB 3}")
Send("{Enter}")
Send("{TAB 3}")
Send("{Enter}")
Edited by AlexanderDunnett
Link to comment
Share on other sites

Send("!F")

Send("P")

Send("{TAB 3}")

Send("{Enter}")

Send("{DOWN 9}")

Send("{TAB 3}")

Send("{Enter}")

Send("{TAB 3}")

Send("{Enter}")

Look up the AutoIt window info tool and use ControlSend() or ControlClick() to directly interact with the window controls that pop up. Much more reliable than tabbing and hoping the receiving program registers the key-presses.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Put all your code in to a function and look up hotkeyset() in the help file

For example..... (

hotkeyset("A","_mynewfunction"); when you press "A" do the function called _mynewfunction()
Hotkeyset("{esc}","_quit"); press escape to quit

While 1 ;keep program running
  Sleep(250)
Wend

Func _mynewfunction()

  ControlClick("windowTitle","","&Yes")
  ControlSend("windowTitle","","Input1","abcdef")

EndFunc

Func _quit()

  Exit

EndFunc
Link to comment
Share on other sites

So instead of mouse click co-ordinates how do I get it to click something that doesn't have a keyboard shortcut or a tab feature?

Use autoit window info tool to get control id or name or if a button or something you can use the text on the control &Yes would be a key that responded to a Y key press to answer Yes if it doesn't respond to keyboard response drop the & (assuming the button text was Yes)

Link to comment
Share on other sites

So instead of mouse click co-ordinates how do I get it to click something that doesn't have a keyboard shortcut or a tab feature?

I already told you. ControlClick() and ControlSend(). Help file, man ... help file! You already looked up how to properly use Send() and WinActivate().

AutoIt Window Info Tool. AKA WinSpy. Tells you nifty things about the window you're trying to fool with. Find it under Start --> All Programs --> AutoIt3 --> AutoIt Window Info

We're not getting paid to write it for you... we're doing something much more valuable. We're helping you learn to pay yourself.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

It's working okay like this..

;Activate MicroStation window, working.
Opt("WinTitleMatchMode" ,2)
WinActivate ("MicroStation V8i (SELECTseries 2) (1)")
;Hold ALT, press F, release. Press Z. Working.
Send("!F")
Send("Z")
;Add Files to Set button, working.
MouseClick ( "left", 2185, 180 ,1, 10)
;Add button, working.
Send("{TAB}")
Send("{Enter}")
;wait for ENTER key, not working
;WinWaitActive("[CLASS:Notepad]")
;Activate Create Print Definitions and press enter, working enough.
WinActivate ("Create Print Definitions")
;set Print style name:
Send("{TAB 5}")
Send("{Enter}")
;Activate Print Organizer and print, working enough but can't choose colour/BW yet
WinActivate ("Print Organizer")
Send("!F")
Send("P")
Send("{TAB 3}")
Send("{Enter}")
Send("{DOWN 9}")
Send("{TAB 3}")
Send("{Enter}")
Send("{TAB 3}")
Send("{Enter}")

But when I enclose it in a function the .exe either isn't opening, or isn't staying open and doing what it did previously

;Add .exe to startup, on startup and minimised to tray, not sure if it works.
WinSetState("BatchPDF.exe", "text?", @SW_HIDE)
;Wait for CTRL ALT P before running script, not working.
HotKeySet("^!P", "_function");
Func _function()
;Activate MicroStation window, working.
Opt("WinTitleMatchMode" ,2)
WinActivate ("MicroStation V8i (SELECTseries 2) (1)")
;Hold ALT, press F, release. Press Z. Working.
Send("!F")
Send("Z")
;Add Files to Set button, working.
MouseClick ( "left", 2185, 180 ,1, 10)
;Add button, working.
Send("{TAB}")
Send("{Enter}")
;wait for ENTER key, not working
;WinWaitActive("[CLASS:Notepad]")
;Activate Create Print Definitions and press enter, working enough.
WinActivate ("Create Print Definitions")
;set Print style name:
Send("{TAB 5}")
Send("{Enter}")
;Activate Print Organizer and print, working enough but can't choose colour/BW yet
WinActivate ("Print Organizer")
Send("!F")
Send("P")
Send("{TAB 3}")
Send("{Enter}")
Send("{DOWN 9}")
Send("{TAB 3}")
Send("{Enter}")
Send("{TAB 3}")
Send("{Enter}")
EndFunc

Any ideas?

Link to comment
Share on other sites

Try this:

#RequireAdmin
WinActivate("[CLASS:Notepad]")
If Not WinWaitActive("[CLASS:Notepad]", "", 30) Then Exit
Send("^p")
If Not WinWait("Print", "", 30) Then Exit
$hwnd_Print = WinGetHandle("Print", "")
ControlClick($hwnd_Print, "", "[CLASS:Button; INSTANCE:13]", "primary", 1)

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

;wait for ENTER key, not working

It's commented out, but what does that mean?

WinSetState("BatchPDF.exe", "text?", @SW_HIDE)

I don't know what text? is or means, but it's probably not needed. Empty quotes should be fine. I don't think this function will do anything for you here anyway, your program doesn't have a GUI to minimize. Unless there's more code than what's been posted so far.

edit: nevermind that, I realize what's happening here. I'll write 'I should practice reading..' 1000 times now.

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...