Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
phodges
Frequent Visitor

AutoHotKey Script for auto-refresh in Power Bi Desktop

Hello Community,

 

I have written a script in AutoHotKey for Power Bi Desktop to auto-refresh by hiting Alt - H - R. This is a combination that does work in Power Bi Desktop when done manually. The AutoHotKey code I wrote is below. This code works within Microsoft Word (r activates the replace command) and Excel (not r, but tried it with x, which activates the Cut command), but will only open the Power Bi window and will not activate the refresh button. Does anyone have an idea as to why it will not work in Power Bi Desktop?

 

--------------------------------------------Code----------------------------------------------------------------------------

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

 

#Persistent
SetTimer, PressTheKey, 30000     ;Refresh every 30 secs (Power Bi Desktop cannot do this and this is important for                                                          ;what I am trying to do)
Return

 

PressTheKey:
if WinExist("Test File")
{
WinActivate       ;Activate the window (if it is not the current window it will reopen it and allow you to work in it)
WinMaximize     ;Maximize window
Send !hr             ;Alt h r keys
}

 

Esc::ExitApp      ;Press "Esc" key to end code
return

-----------------------------------------------------------------------------------------------------------------------------

 

P.S. If anyone knows a shortcut key for refresh in Power Bi Desktop that would be helpful too.

2 ACCEPTED SOLUTIONS
andyclap
Helper II
Helper II

If you're up for a bit of python, there's a scipt here that is quite a useful demo of using pywinauto to do just this sort of thing:

https://github.com/dubravcik/pbixrefresher-python

 

View solution in original post

Oh that is pretty neat! Thank you for sharing! The autohotkeys script works too, but it needs to be run as administrator. I found that out a little after posting this. But thank you for your reply!

View solution in original post

2 REPLIES 2
andyclap
Helper II
Helper II

If you're up for a bit of python, there's a scipt here that is quite a useful demo of using pywinauto to do just this sort of thing:

https://github.com/dubravcik/pbixrefresher-python

 

Oh that is pretty neat! Thank you for sharing! The autohotkeys script works too, but it needs to be run as administrator. I found that out a little after posting this. But thank you for your reply!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.